Re: string return result conventions

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

ok - can i ask people a favour?  could you kindly review e.g.... this:

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,

... 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.


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