Re: GSList* memory management.

Emmanuele Bassi <[email protected]> Wed, 16 May 2007 12:24:25 +0100
Newsgroups gmane.comp.gnome.lib.gconf
Message-ID <1179314665.8345.9.camel@localhost>
On Wed, 2007-05-16 at 13:08 +0200, Murray Cumming wrote:
> I'd like to improve the documentation for functions that return GSLists
> and GList*. The documentation needs to specify how they should be freed:
> - with just g_slist_free() - a shallow delete.
> or
> - with a g_free() (or appropriate) on each item, and then a
> g_slist_free() - a deep delete.

> For instance, which should it be for these functions?
> gconf_client_all_dirs()

 * returns a list of allocated strings
 * requires a deep free: g_slist_foreach (dirs, (GFunc) g_free, NULL);

> gconf_client_all_entries()

 * returns a list of referenced GConfEntry objects
 * requires a deep free: g_slist_foreach (entries, (GFunc) gconf_entry_unref, NULL);

> gconf_client_get_list()

 * exactly lkke the other getters, this returns a list of copies of the
   actual value stored inside the GConf database
 * requires a deep free depending on the type contained inside the list;
   the conversion is indeed quite weird: ints and booleans are simply
   put inside the returnes list using GINT_TO_POINTER(), but doubles
   are allocated, like are schemas and strings.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,  E: [email protected]
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net