[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-devel
Subject:    Re: string return result conventions
From:       Tim Janik <timj () imendio ! com>
Date:       2008-09-16 8:38:06
Message-ID: alpine.DEB.1.00.0809161036260.7886 () clinker ! birnet ! private
[Download RAW message or body]

On Mon, 15 Sep 2008, Luke Kenneth Casson Leighton wrote:

>> ok - can i ask people a favour?  could you kindly review e.g.... this:
>>     http://lkcl.net/webkit/DerivedSources/GdomAttr.cpp
>
>> just looking at it myself, i think where i use fromUTF8 i have a
>> memory leak,
>
> ... but after looking at it again i don't think i have..
>
>> there, but key question: in the use of
>> g_value_set_string() - that "takes over" the memory passed in to it,
>> right?
>
> ... i should be using g_value_take_string(), shouldn't i?

g_value_set_string() duplicates your string internally.
g_value_take_string() takes over ownership of your string and
frees it with g_free(). That is, you might only pass in strings
that have been allocated with g_malloc/g_new/g_strdup/g_*,
because only those require a matching g_free() call.

---
ciaoTJ
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic