Proper wrapper for evas_hash around eina_hash.

Eina hash api must get non NULL pointer allocated with
eina_hash_new(), but Evas hash started with NULL and would allocate
and destroy the hash as required by operations.

To do a proper wrapper we must ensure we don't call Eina hash API with
NULL, we must handle that outside Eina.

PLEASE do not remove this code again (it's the second time I add it),
this is the correct approach. Other than that is going after evas_hash
usage and converting directly to eina_hash.




SVN revision: 38091
This commit is contained in:
Gustavo Sverzut Barbieri 2008-12-10 21:26:17 +00:00
parent 89937e8cf5
commit 3e9459fd60
1 changed files with 24 additions and 4 deletions

View File

@ -102,10 +102,30 @@ 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;
eina_hash_free(hash);
}
static inline void evas_hash_foreach(const Eina_Hash *hash, Eina_Bool (*cb)(const Eina_Hash *hash, const char *key, void *data, void *fdata), const void *fdata)
{
if (!hash) return;
eina_hash_foreach(hash, (Eina_Hash_Foreach)cb, fdata);
}
#define evas_hash_alloc_error eina_error_get
/*