Re: freeing gslist data ?
- From: Ali Akcaagac <aliakc web de>
- To: gtk-app-devel-list gnome org
- Subject: Re: freeing gslist data ?
- Date: 23 Jun 2003 01:14:03 +0200
On Mon, 2003-06-23 at 00:04, Mohammed Sameer wrote:
Hi,
suppose that i have a GSList *foo and a gchar *bar
and i've used something like this:
foo = g_slist_append(foo, g_strdup(bar));
now when i free the list, Do i have to manually iterate over the list
and free the ->data ?
i've browsed the code but i didn't understand well the gallocator things
yes you do, g_strdup returns a new string which requires to be free'd
after usage
http://developer.gnome.org/doc/API/2.0/glib/glib-String-Utility-Functions.html#g-strdup
as you can reed here. when you free the list then you only remove
elements from your linked list but the allocated strings are still
showing up somewhere in memory. thus it's really required to iterate
through the list, g_free all the ->data and then remove the list.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]