WWW-www.enlightenment.org pushed a commit to branch master. http://git.enlightenment.org/website/www-content.git/commit/?id=af3e5f95c2bb5afce63abb834713319569b70b3d
commit af3e5f95c2bb5afce63abb834713319569b70b3d Author: Xavi Artigas <xavierarti...@yahoo.es> Date: Mon Apr 30 02:34:21 2018 -0700 Wiki page hash-tables.md changed with summary [prevent leaks in hash_set] by Xavi Artigas --- pages/develop/guides/c/eina/hash-tables.md.txt | 11 ++++++++--- 1 file 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 ```c char *old_phone = NULL; -char *phone = NULL; // Replace the phone number of Richard Strauss old_phone = eina_hash_modify(phone_book, "Richard Georg Strauss", strdup("+23 45 111-11111")); -phone = eina_hash_set(phone_book, "Philippe de Magalhães", strdup("+33 6 111-11111")); -eina_hash_set(phone_book, "Richard Georg Strauss", strdup("+23 45 111-117711")); +// ... +old_phone = eina_hash_set(phone_book, "Philippe de Magalhães", strdup("+33 6 111-11111")); +// ... +old_phone = eina_hash_set(phone_book, "Richard Georg Strauss", strdup("+23 45 111-117711")); +// ... ``` +> **NOTE**: +> 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! + ### Change the key associated with data ### Use 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``. --