From bcabb2be6053a9651fbfabde572a6ad8ac661107 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 19 Sep 2008 09:36:48 +0000 Subject: [PATCH] and when deleting a hash item - if hash data != NULL delete EXACTLY that entry (if there are duplicates... this will avoid removing the wrong one) SVN revision: 36092 --- legacy/evas/src/lib/data/evas_hash.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/legacy/evas/src/lib/data/evas_hash.c b/legacy/evas/src/lib/data/evas_hash.c index 9d36648a58..17a0baa61d 100644 --- a/legacy/evas/src/lib/data/evas_hash.c +++ b/legacy/evas/src/lib/data/evas_hash.c @@ -249,15 +249,18 @@ evas_hash_del(Evas_Hash *hash, const char *key, const void *data) el = (Evas_Hash_El *)l; if (!strcmp(el->key, key)) { - hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el); - free(el); - hash->population--; - if (hash->population <= 0) + if ((!data) || (el->data == data)) { - free(hash); - hash = NULL; + hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el); + free(el); + hash->population--; + if (hash->population <= 0) + { + free(hash); + hash = NULL; + } + return hash; } - return hash; } } }