forked from enlightenment/efl
eina: fix eina_hash_set to act when data == NULL like eina_hash_del.
SVN revision: 59849
This commit is contained in:
parent
191c79c9e1
commit
a0ea6c5130
|
@ -97,3 +97,7 @@
|
||||||
2011-05-30 Cedric Bail
|
2011-05-30 Cedric Bail
|
||||||
|
|
||||||
* Add eina_condition_timedwait.
|
* Add eina_condition_timedwait.
|
||||||
|
|
||||||
|
2011-05-31 Cedric Bail
|
||||||
|
|
||||||
|
* Fix eina_hash_set to handle data == NULL like eina_hash_del.
|
||||||
|
|
|
@ -379,7 +379,7 @@ EAPI void *eina_hash_modify(Eina_Hash *hash,
|
||||||
*/
|
*/
|
||||||
EAPI void *eina_hash_set(Eina_Hash *hash,
|
EAPI void *eina_hash_set(Eina_Hash *hash,
|
||||||
const void *key,
|
const void *key,
|
||||||
const void *data) EINA_ARG_NONNULL(1, 2, 3);
|
const void *data) EINA_ARG_NONNULL(1, 2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Change the key associated with a data without triggering the
|
* @brief Change the key associated with a data without triggering the
|
||||||
|
|
|
@ -1103,7 +1103,6 @@ eina_hash_set(Eina_Hash *hash, const void *key, const void *data)
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
|
|
||||||
EINA_MAGIC_CHECK_HASH(hash);
|
EINA_MAGIC_CHECK_HASH(hash);
|
||||||
|
|
||||||
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
|
key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
|
||||||
|
@ -1119,10 +1118,21 @@ eina_hash_set(Eina_Hash *hash, const void *key, const void *data)
|
||||||
void *old_data = NULL;
|
void *old_data = NULL;
|
||||||
|
|
||||||
old_data = hash_element->tuple.data;
|
old_data = hash_element->tuple.data;
|
||||||
hash_element->tuple.data = (void *)data;
|
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
hash_element->tuple.data = (void *)data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_eina_hash_del_by_hash_el(hash, hash_element, hash_head, key_hash);
|
||||||
|
}
|
||||||
|
|
||||||
return old_data;
|
return old_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!data) return NULL;
|
||||||
|
|
||||||
eina_hash_add_alloc_by_hash(hash,
|
eina_hash_add_alloc_by_hash(hash,
|
||||||
key,
|
key,
|
||||||
key_length,
|
key_length,
|
||||||
|
|
Loading…
Reference in New Issue