From: barbieri Date: Sun, 7 Dec 2008 13:28:29 +0000 (+0000) Subject: hash: better handling of NULL, add magic checking. X-Git-Tag: submit/trunk/20120815.174732~3554 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f33b30237871dc81b57c29a188466c28c7ab988;p=profile%2Fivi%2Fevas.git 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. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@37982 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/Evas_Data.h b/src/lib/Evas_Data.h index 41743c1..48445e4 100644 --- a/src/lib/Evas_Data.h +++ b/src/lib/Evas_Data.h @@ -102,10 +102,29 @@ extern "C" { return 255; } - #define evas_hash_find eina_hash_find - #define evas_hash_modify eina_hash_modify - #define evas_hash_free eina_hash_free - #define evas_hash_foreach eina_hash_foreach + static inline void *evas_hash_find(const Eina_Hash *hash, const void *key) + { + if (!hash) return NULL; + return eina_hash_find(hash, key); + } + + static inline void *evas_hash_modify(Eina_Hash *hash, const void *key, const void *data) + { + if (!hash) return NULL; + return eina_hash_modify(hash, key, data); + } + static inline void evas_hash_free(Eina_Hash *hash) + { + if (!hash) return NULL; + return eina_hash_free(hash); + } + + static inline void evas_hash_foreach(const Eina_Hash *hash, Eina_Hash_Foreach cb, const void *fdata) + { + if (!hash) return; + eina_hash_foreach(hash, cb, fdata); + } + #define evas_hash_alloc_error eina_error_get /*