Re: string return result conventions



On Sun, 14 Sep 2008, Luke Kenneth Casson Leighton wrote:

folks, hi,
i'm looking for advice on memory return result conventions - who is
responsible for maintaining andd/or freeing memory, in particular
strings, as return results from pproperrty getting for example.  the
webkit-glib bindings are going extremely well, pywebkitgtk has them in
use, however, the conventions for webkit are that the library
maintains responsibility for any string management, such that users of
the library do not have to worry about malloc or free.
therefore it's important for me to find out what glib / gobject memory
conventions are, for strings.

Strings querried through the property interfacem e.g.:

gchar *string = NULL;
g_object_get (label, "label", &string, NULL);

is always duplicated and needs to be a freed by the caller,
because the returned string might have been dynmically
constructed in the objects proeprty getter (i.e. not
correspond to memroy actually allocted for object member storage).

much appreciated your advice.
l.

---
ciaoTJ


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