Commit Graph

74 Commits

Author SHA1 Message Date
Lucas De Marchi 5a8a8c9014 Convert (hopefully) all comparisons to NULL
Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;


other cases:

a == NULL                         !a
a != NULL                         a




SVN revision: 51487
2010-08-21 13:52:25 +00:00
Cedric BAIL e6f9cee051 * eina: fix structure content to be more futur proof and reduce
risk of ABI breakage.


SVN revision: 51390
2010-08-19 12:02:28 +00:00
Cedric BAIL f75eab161d * eina: remove thread safe data type for now. They will be back !
SVN revision: 51179
2010-08-16 09:32:09 +00:00
Mike Blumenkrantz ad00478247 fix threadsafe api
SVN revision: 51118
2010-08-14 16:10:19 +00:00
Cedric BAIL 3b269d6f04 * eina: don't direct people in the wrong direction.
SVN revision: 51117
2010-08-14 15:50:07 +00:00
Mike Blumenkrantz 689a24559c add threadsafety for hashes
SVN revision: 51106
2010-08-14 03:05:35 +00:00
Iván Briano 02031b60bf Remark that data being deleted from the hash will be mercilessly killed if a blackops free function was given to the hash on creation.
SVN revision: 51079
2010-08-13 14:34:36 +00:00
Mike Blumenkrantz c8f669a27f more variable renames, null check alloc, malloc+memset0 -> calloc, rwlocks in structs
SVN revision: 51066
2010-08-13 06:58:43 +00:00
Mike Blumenkrantz 3618cf1227 rename variables and typedefs to sane values
SVN revision: 51064
2010-08-13 05:22:33 +00:00
Cedric BAIL a6645cb746 * eina: fix eina array threadsafe version.
Also add iterator and accessor ability to walk threadsafely.
	Rename EINA_EACH to EINA_EACH_CB to match other callback cast.


SVN revision: 51000
2010-08-11 14:32:30 +00:00
Mike Blumenkrantz d409884148 incomplete doxy!
cedric SPANK SPANK SPANK!!!


SVN revision: 50694
2010-07-30 21:18:40 +00:00
Cedric BAIL c9d5d8a62e * eina: add a way to move a key to another without triggering the Free_Cb.
SVN revision: 50683
2010-07-30 09:06:58 +00:00
Carsten Haitzler ddc6ba2c2a uncrustify eina.
SVN revision: 50573
2010-07-28 02:37:05 +00:00
Mike Blumenkrantz 2f183fa194 eina_hash_modify_or_add -> eina_hash_set
SVN revision: 50448
2010-07-23 13:04:21 +00:00
Mike Blumenkrantz 489cae4eee +eina_hash_modify_or_add to always add a value to the hash at the specified key
SVN revision: 50402
2010-07-21 03:15:39 +00:00
Mike Blumenkrantz 0c983ac8d8 dox fixes
SVN revision: 50355
2010-07-18 18:59:01 +00:00
Mike Blumenkrantz d3982d4b5c +eina_hash_free_buckets to free buckets without freeing a hash
SVN revision: 50315
2010-07-18 04:24:24 +00:00
Mike Blumenkrantz af32bf04f0 well this was just plain wrong
SVN revision: 50314
2010-07-18 03:55:53 +00:00
Mike Blumenkrantz 7d3bf122ac on the fifth day the rasterman said "let there be docs for hash tables!"
but there were no docs for hash tables because k-s and cedric were busy writing new functions for hash tables. so rasterman again said "let there be docs for hash tables! really guys, I mean it this time!"
and this time there were docs, but these docs were incomplete and in some places vague and misleading.
these docs frustrated little discomfitor, who had just healed up after learning to ride his edje bicycle and was just starting to read. so he read all that he could, and then he started to write. he wrote his little heart out until finally there were more docs for hash tables like the rasterman had wanted.
then he went and got ice cream.

The End.


SVN revision: 50313
2010-07-18 03:29:10 +00:00
Brett Nash 2677b8d493 Minor doc update: It's nice when examples compile without warnings ;-)
SVN revision: 49091
2010-05-21 09:48:46 +00:00
Vincent Torri b64d398ffd warnings--
SVN revision: 46079
2010-02-11 15:29:20 +00:00
Iván Briano 044f05ca69 Fix docs for hash_free
SVN revision: 43237
2009-10-24 04:30:52 +00:00
Gustavo Sverzut Barbieri e4af7c100c EINA API BREAK: no more individual modules init/shutdown.
Being able to indivually initialize individual modules was initially
"good", but at end it's putting complexities on users that would try
to "optimize" by doing just what they used, but in the end most people
would get them wrong, users would have to do lots of code and etc. At
the end it does not worth.

Most module init just register handful errors and log domains, so are
cheap. The exception is mempool users, that would dlopen() stuff, but
people that are concerned (embedded) can just compile those statically
in eina.

Since at the end any real application would use most of modules, we
actually end saving lots of function calls that would do nothing other
than increment a global counter.

I also did the init/shutdown use an array, making it easier to
maintain. The inital dependencies were analysed by a script I wrote, I
hope it's all right.

Please fix any breakages you find!



SVN revision: 42300
2009-09-06 22:21:56 +00:00
Gustavo Sverzut Barbieri 07d2bde900 eina_safety_checks_init()
All these individual init functions are getting messy, some modules
lack them and it's easy to get inconsistent. Safety check needs error
and log, but these need safety checks as well, some modules (lalloc,
rbtree and others) use safety checks but provide no _init().

I want to know if we really gain something to init individual
modules. It should not be that expensive as init should not allocate
heavy resources and the recommendation is to call eina_init() so most
users will do that anyway.

If people agree I'll unmark all *_init() as EAPI and make them private
to eina lib.



SVN revision: 42214
2009-09-04 00:53:19 +00:00
Vincent Torri 72b87160a2 * add eina_config.h in all source files. Fix linking with Visual Studio
* move eina_private.h and eina_safety_checks.h just after eina_config.h


SVN revision: 42077
2009-08-28 12:03:34 +00:00
Gustavo Sverzut Barbieri c8534587f2 do not check for data, eina_iterator_next/eina_accessor_data_get() does that.
SVN revision: 41984
2009-08-25 21:05:00 +00:00
Vincent Torri 9110d8d574 fix a bit the documentation, but there are still
a lot of doc to write...


SVN revision: 41164
2009-06-22 20:03:58 +00:00
Cedric BAIL 7a18ab5ebc * eina: Add an eina_hash_stringshare_new.
SVN revision: 41112
2009-06-19 14:44:23 +00:00
Cedric BAIL bba26ef811 * eina: Improve eina hash manipulation for int.
- Faster int key comparison.
	- Key Length callback could now be NULL and 0 will be assumed.


SVN revision: 41100
2009-06-18 12:08:52 +00:00
Cedric BAIL 5aeb9bbe82 * Fix some init/shutdown procedure.
SVN revision: 40892
2009-06-04 09:02:29 +00:00
Vincent Torri 309606b2dd use variadic macros, as suggested by Gustavo
SVN revision: 39663
2009-03-24 07:10:46 +00:00
Vincent Torri 7e809db9c8 fix some llvm report
SVN revision: 39657
2009-03-23 20:36:10 +00:00
Gustavo Sverzut Barbieri e3cce7b79d New macros, documentation and consistency for iterators and accessors.
EINA_ITERATOR_FOREACH() and EINA_ACCESSOR_FOREACH() are new macros to
help us forget about nasty C details (like cast to (void **)).

Document most iterators and accessors.

All iterators now set EINA_ERROR_OUT_OF_MEMORY if it's the case.



SVN revision: 39267
2009-02-27 16:32:22 +00:00
rephorm 0f053605b9 don't leak
SVN revision: 38806
2009-01-27 05:11:16 +00:00
Vincent Torri c166854ae1 * minor formatting
* add some doc in eina_array
 * in eina_main.c, include only the necessary headers
 * fix some warnings (size_t <-> int)


SVN revision: 38740
2009-01-23 16:11:45 +00:00
Cedric BAIL 0dda30daf6 * eina/src/include/eina_array.h,
* eina/src/include/eina_f16p16.h,
	* eina/src/include/eina_accessor.h,
	* eina/src/include/eina_list.h,
	* eina/src/include/eina_iterator.h,
	* eina/src/lib/eina_rectangle.c,
	* eina/src/lib/eina_list.c,
	* eina/src/lib/eina_array.c,
	* eina/src/lib/eina_hash.c,
	* eina/src/lib/eina_module.c,
	* eina/src/lib/eina_stringshare.c,
	* eina/src/lib/eina_benchmark.c: Fix for windows compilation.



SVN revision: 38663
2009-01-20 15:56:48 +00:00
Cedric BAIL f2037c5c6f Don't generate warning in some little case.
SVN revision: 38348
2008-12-29 12:41:46 +00:00
Gustavo Sverzut Barbieri ab95d9183d eina safety checks.
safety checks will report null pointers and other error conditions on
public api's and can be disabled by compile time check.

note that in order to have these checks working we need to make
EINA_ARG_NONNULL() void, otherwise GCC can remove these checks since
they're known to be false.

This commit also make two minor changes:

  * list and hash accessors and iterators are created even for empty
    entities. This is correct in my point of view since NULL should
    indicate error. Having these in were an optimziation, but not
    worth it, these are not the most common case and hitting this path
    is not of much cost.

 * unmarked some parameters as nonnull, mainly on list and inlist.



SVN revision: 38327
2008-12-26 18:31:14 +00:00
Gustavo Sverzut Barbieri b0ee5696a6 eina gets lots of gcc attributes to its api.
this should help with optimizations and code correctness, please see
"info gcc" for detailed explanation on these.

if you experience some functions not working as expected, please
double check if they're not marked with EINA_PURE or EINA_CONST, maybe
I misused them. Remove the macro and try again.

brief explanation:

 * EINA_WARN_UNUSED_RESULT: if you forgot to use the return of some
   function, it will emit a warning (and -Werror will make it an
   error). This way it will be harder to miss the attribution
   "l = eina_list_append(l, v)".

 * EINA_ARG_NONNULL(index, index...): if you give it an explicit NULL
   argument, or some tool (ie: clang) finds it could get a NULL but
   this is not accepted by API, then a warning will be emitted.  This
   will help those that still use eina_hash_add() as if it is
   evas_hash_add().

 * EINA_MALLOC: any non-NULL pointer it returns cannot alias any other
   pointer valid when function returns.

 * EINA_PURE: function have no effects other than the return and this
   return just depend on parameters and/or globals. You might call
   this function in a loop a thousand times and it will return the
   same value, thus you may move this function outside the loop and
   remove it.

 * EINA_CONST: stricter version of EINA_PURE, it will not check for
   global parameters, that is, you cannot consider pointer
   arguments. Use it for math things like "int sqrt(int)".

 * EINA_PRINTF(fmt, arg): will check format parameter specified in
   position "fmt" and passed arguments starting at position "arg", it
   will check for things like giving integers where short or strings
   were expected.

 * EINA_SCANF(fmt, arg): similar to eina_printf().

 * EINA_FORMAT(fmt): for use with things like dgettext(), it will get
   a printf-like format string and modifies it.

Please review and test it with your software, make sure you make clean
before you install the new version so it has any effect.

If you find some functions are missing EINA_WARN_UNUSED_RESULT and
EINA_ARG_NONNULL or others, please add them.



SVN revision: 38323
2008-12-26 13:17:51 +00:00
Cedric BAIL c8714d04cc Declaration should be done before any code.
SVN revision: 38286
2008-12-23 10:02:27 +00:00
Cedric BAIL c80a55ee14 Add small bucket support.
SVN revision: 38168
2008-12-16 16:49:29 +00:00
Cedric BAIL b8d721ac05 If we set the data free callback of a hash, we expect it to be called when
calling all eina_hash_del functions.


SVN revision: 38102
2008-12-11 13:47:58 +00:00
Cedric BAIL 9b9f752379 Only allocate hash bucket when needed.
Make eina_hash_del_by_key really different from eina_hash_del.


SVN revision: 38064
2008-12-09 17:39:48 +00:00
Cedric BAIL 00e8fba9ba All eina_hash_find* functions should not report problem when hash or key is NULL.
SVN revision: 38059
2008-12-09 14:59:30 +00:00
Cedric BAIL b0e1863871 eina_hash_find should not complain when hash or key is NULL.
SVN revision: 38057
2008-12-09 14:24:08 +00:00
Cedric BAIL af30207725 eina_hash_del must honor the data parameter when the key is passed. Propagate
it correctly.


SVN revision: 38054
2008-12-09 13:52:09 +00:00
Cedric BAIL d19801f7c2 Prevent warning from Eina Magic when hash population is 0.
SVN revision: 38049
2008-12-09 13:05:33 +00:00
Cedric BAIL 5358b1f84f Add integer and pointer hash table helper.
SVN revision: 38026
2008-12-08 17:31:55 +00:00
Gustavo Sverzut Barbieri 8ea28f64b7 hash: better handling of NULL, add magic checking.
* evas: if we automatically destroy hash, check for NULL before
   handling it to eina api, which expect elements to be created with
   eina_hash_new() and thus will fail on NULL.
 * eina: add magic checking for eina_hash and eina_hash_iterator, this will
   help spot when NULL is used.
 * eina_hash_foreach: do not try to create the iterator if hash is NULL.



SVN revision: 37982
2008-12-07 13:28:29 +00:00
Gustavo Sverzut Barbieri b21c687f61 refactor eina_hash_del*, expose simpler functions and avoid GCC hack.
By using simpler functions for hash element deletion we can avoid the
hack to shut up GCC warking about hash_num not being used. As these
simple functions are more often needed than the catch-all, expose them
as well.



SVN revision: 37962
2008-12-06 06:58:56 +00:00