hash: better handling of NULL, add magic checking.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 7 Dec 2008 13:28:29 +0000 (13:28 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 7 Dec 2008 13:28:29 +0000 (13:28 +0000)
 * 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

src/lib/Evas_Data.h

index 41743c1..48445e4 100644 (file)
@@ -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
 
   /*