-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've just been running a program through valgrind, and looking for memory 
leaks. There appears to be one concerning hashes:

int main(int argc, char ** argv)
{
        Ecore_Hash * hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
        ecore_hash_set_free_key(hash, free);
        ecore_hash_set_free_value(hash, free);
        ecore_hash_set(hash, strdup("yo"), strdup("mofo"));
        free(ecore_hash_remove(hash, "yo"));
        ecore_hash_destroy(hash);

        return 0;
}

I don't know if this is because I haven't used the library properly, but it 
appears that upon ecore_hash_remove the original string strdup'ed "yo" isn't 
freed. However, the following diff causes double free's when 
ecoree_hash_destroy is called:

Index: ecore_hash.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore/ecore_hash.c,v
retrieving revision 1.3
diff -u -r1.3 ecore_hash.c
- --- ecore_hash.c        30 Apr 2004 03:10:15 -0000      1.3
+++ ecore_hash.c        1 May 2004 15:12:35 -0000
@@ -347,6 +347,7 @@
                        ecore_list_remove(list);

                        ret = node->value;
+                       hash->free_key(node->key);
                        FREE(node);
                }
        }

I traced the problem into _ecore_hash_node_destroy, but I don't know what 
other functions call it, so I'm a bit disinclined to just take the free out 
of there.

Genneth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAk7961N42u6LLBTERAplrAJ4hg3qtMt3jjwzMSv/llbKca9oelgCgrcR5
wrVziCbqdjbqxz5FccvEe4g=
=6VHQ
-----END PGP SIGNATURE-----


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click
_______________________________________________
enlightenment-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to