Re: Question About Hash



try rewriting as:
if you look at the documentation for g_hash_table_foreach_remove() you might notice that the element will only be removed if the function called returns true.  except you provide NULL for the function which i have serious doubts returns TRUE.

look at it another way: why are you expecting the elements you insert will be deleted when you make no accomodations for such in your code and the documentation clearly states that you are responsible for (somehow) arranging for the data to be freed?

richard

On Fri, Apr 9, 2010 at 12:22 PM, Tata <leleshan gmail com> wrote:
Thank you, Some code like this:

func1()
{
..
table_3= g_hash_table_new(g_direct_hash, g_direct_equal);
..
}
func2()
{
...
g_hash_table_insert(table_3, GUINT_TO_POINTER(key_3), value);
....
}
func3()
{
...
g_hash_table_foreach_remove(table_3, NULL, NULL);
g_hash_table_destroy(table_3);
...
}



2010/4/9 richard boaz <ivor boaz gmail com>

show your code, without it your comment is an opinion and not likely to get much of an interesting response.

why?  because there are multiple ways of setting up hash tables, their contents, and the automatic (or not) destroy functions which should be used.

try again,

richard

On Fri, Apr 9, 2010 at 12:03 PM, Tata <leleshan gmail com> wrote:
HELLO:

   When i destroy a GHashTable by g_hash_table_destroy, i found some memory leak. Hash func is g_direct_hash. Key equal func is g_direct_equal. There are more than 100,000 record in my GHashTable.

   Thanks.

Austin

_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]