Re: where to use a g_free ?



Cevat Ustun <ustun glue umd edu> writes:
I am slightly confused by some (er, at least one) of the examples I've
seen in the
archives: they seem to suggest that a structure defined within a
function
(so as to be able to pass  more than one widget to a callback for
example)
needs to give up its memory through a  g_free statement at the end of
the _function_  itself .
This confuses me because regardless of whether the callback is called or
not,
one ends up freeing the memory anyway (thereby causing a crash) when the
program
execution reaches the end of the function.  Perhaps an alternative is to
write another
_callback_ so that g_free is called before the dialog in question
destroys itself but
introducing another callback doesn't seem like a very elegant
solution...


You might look at gtk_signal_connect_full(), which lets you pass in
a free function for the callback data.

Havoc




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