Commit Graph

42 Commits

Author SHA1 Message Date
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
Gustavo Sverzut Barbieri 5939d76d9c Fix couple of issues with MAGIC handling.
eina_magic.h MUST include eina_config.h, otherwise it will not
consider EINA_MAGIC stuff. Worse than that, some files were including
that directly and were considering EINA_MAGIC attribute even if the
file that alloc'ed the memory were not!

Also add missing EINA_MAGIC_SET() to iterators and accessors.



SVN revision: 37960
2008-12-06 06:17:11 +00:00
Gustavo Sverzut Barbieri b023145eed shut up gcc warning, with comment.
SVN revision: 37953
2008-12-06 03:02:30 +00:00
Gustavo Sverzut Barbieri f8868ffa96 Fix namespace: Eina_Foreach -> Eina_Hash_Foreach.
SVN revision: 37950
2008-12-06 02:21:17 +00:00
Cedric BAIL 9a5b397a3e Fix a little memory leak when iterating.
SVN revision: 37718
2008-11-20 13:26:18 +00:00
Cedric BAIL aa82395cc1 Fix order of free during hash free.
SVN revision: 37572
2008-11-10 14:32:14 +00:00
Cedric BAIL 93711c814e Fix hash iterator to iterate with only one element.
SVN revision: 36858
2008-10-20 14:45:01 +00:00
Cedric BAIL 550ebc9ab1 Add hash and rbtree delete callback, cleanup the code and improve performance (hash as a new internal structure).
We still need a hash function for removing a node from the hash and destroying it at the same time.



SVN revision: 36222
2008-09-24 17:14:29 +00:00
Cedric BAIL 80a227ff13 We have now a defined behaviour when we have more than one entry with the same
key in the hash table.


SVN revision: 36096
2008-09-19 12:19:06 +00:00
Vincent Torri f50feadeae * add benchmark and file documentation
* reorganize a bit more. it's not finished
 * fix spellingg and formatting 
 * gnuplot file names generated by our bechmarks tests have an
   absolute time description and not H:M:S description, as this
   breaks the check out of the repo on Windows.


SVN revision: 36090
2008-09-19 05:22:43 +00:00
Cedric BAIL 9638ded27f Fix initialisation logic.
SVN revision: 35806
2008-09-03 12:06:50 +00:00
Cedric BAIL 6bbb9bf821 Remove useless indirection and useless tests.
SVN revision: 35733
2008-08-29 13:52:16 +00:00
Cedric BAIL 78e7047377 Use rbtree instead of inlist and make hash way faster.
SVN revision: 35720
2008-08-28 16:35:43 +00:00
Vincent Torri dafd079639 * move standard header files from eina_private.h to source files
* minor formatting


SVN revision: 35705
2008-08-28 07:46:42 +00:00
Vincent Torri 9824a1a86c Update documentation:
* run 'make doc' to generate the documentation. Hence
   gendoc disappear. Doxyfile is moved to doc/
 * update main page and doc of hash table, but it has to
   be filled.



SVN revision: 35692
2008-08-27 13:34:04 +00:00
Cedric BAIL 3878e945fb Some cleanup. Add EAPI in the .c file and move the locale function up in the file.
SVN revision: 35678
2008-08-26 08:59:25 +00:00
Cedric BAIL e360e1b2b9 Cleanup.
SVN revision: 35446
2008-08-12 16:01:10 +00:00
Cedric BAIL a46c20d137 Easier API and follow gustavo's remark.
SVN revision: 35440
2008-08-11 17:22:36 +00:00
Cedric BAIL 43cc2dca6f Add first try for an accessor and iterator API, comment welcome (lack inlist and list currently).
Rewrite EINA_ARRAY_ITER_NEXT, still fast, need one more parameter, but no more EINA_ARRAY_ITER_END.


SVN revision: 35438
2008-08-11 16:30:16 +00:00
doursse bbf9b05530 fix doxy doc
SVN revision: 35416
2008-08-09 05:47:15 +00:00
Cedric BAIL cf5bc3129d Use the common out of memory error.
SVN revision: 35379
2008-08-07 13:11:13 +00:00
Cedric BAIL ddaa7d4d8f License changes (BSD -> LGPL)
SVN revision: 35360
2008-08-06 18:15:24 +00:00
Cedric BAIL 69945bf4ec Major cleanup. Eina_Hash now support other key than string. All code except
allocation failure and foreach is covered by the test.


SVN revision: 35351
2008-08-06 15:46:57 +00:00
Cedric BAIL 86f58ba639 Use only the needed headers per file and remove some warning.
SVN revision: 35253
2008-07-30 13:35:49 +00:00
Cedric BAIL a92e3d6c83 Adding turran work to unify EFL data types and functions.
SVN revision: 35248
2008-07-30 12:46:55 +00:00