Re: string return result conventions



Hi,

On Sun, Sep 14, 2008 at 7:37 AM, Luke Kenneth Casson Leighton
<lkcl lkcl net> wrote:
> 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.

There's no strict rule; glib-style APIs usually return a caller-owned
string if the string is or is likely to become allocated on the fly,
and return a const (or G_CONST_RETURN) string if the string is likely
to be kept around in the object. The only strict rule is that if the
string should not be freed, it needs to have G_CONST_RETURN or const
on it.

Havoc


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