summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-04-30 02:34:21 -0700
committerapache <apache@e5-web1.enlightenment.org>2018-04-30 02:34:21 -0700
commitaf3e5f95c2bb5afce63abb834713319569b70b3d (patch)
tree314182c3c3414485f8321df51c50ec2abc509147
parent82629984a2844bdd1ab77b48528127ea45d5b348 (diff)
Wiki page hash-tables.md changed with summary [prevent leaks in hash_set] by Xavi Artigas
-rw-r--r--pages/develop/guides/c/eina/hash-tables.md.txt11
1 files changed, 8 insertions, 3 deletions
diff --git a/pages/develop/guides/c/eina/hash-tables.md.txt b/pages/develop/guides/c/eina/hash-tables.md.txt
index 9650e192a..ff0cb886a 100644
--- a/pages/develop/guides/c/eina/hash-tables.md.txt
+++ b/pages/develop/guides/c/eina/hash-tables.md.txt
@@ -119,13 +119,18 @@ The ``eina_hash_set()`` function does the same work as ``eina_hash_modify()`` bu
119 119
120```c 120```c
121char *old_phone = NULL; 121char *old_phone = NULL;
122char *phone = NULL;
123// Replace the phone number of Richard Strauss 122// Replace the phone number of Richard Strauss
124old_phone = eina_hash_modify(phone_book, "Richard Georg Strauss", strdup("+23 45 111-11111")); 123old_phone = eina_hash_modify(phone_book, "Richard Georg Strauss", strdup("+23 45 111-11111"));
125phone = eina_hash_set(phone_book, "Philippe de Magalhães", strdup("+33 6 111-11111")); 124// ...
126eina_hash_set(phone_book, "Richard Georg Strauss", strdup("+23 45 111-117711")); 125old_phone = eina_hash_set(phone_book, "Philippe de Magalhães", strdup("+33 6 111-11111"));
126// ...
127old_phone = eina_hash_set(phone_book, "Richard Georg Strauss", strdup("+23 45 111-117711"));
128// ...
127``` 129```
128 130
131> **NOTE**:
132> Remember to check the return value of ``eina_hash_modify()`` and ``eina_hash_set()`` and free it if required, or you might be leaking the previous entry in the hash!
133
129### Change the key associated with data ### 134### Change the key associated with data ###
130 135
131Use the ``eina_hash_move()`` function to change the key without freeing and creating a new entry . You need only pass the hash, the old key and the new key. If the operation succeeds, the function returns ``EINA_TRUE``, if not it returns ``EINA_FALSE``. 136Use the ``eina_hash_move()`` function to change the key without freeing and creating a new entry . You need only pass the hash, the old key and the new key. If the operation succeeds, the function returns ``EINA_TRUE``, if not it returns ``EINA_FALSE``.