Re: Freeing data connected to a widget via signals...

>take a look at                      
>  guint       gtk_signal_connect_full         (GtkObject *object,   
>                                               const gchar *name,
>                                               GtkSignalFunc func,
>                                               GtkCallbackMarshal marshal,
>                                               gpointer data,
>                                               GtkDestroyNotify
>                                               gint object_signal,           
>                                               gint after);
>where GtkDestroyNotify is
>  void        (*GtkDestroyNotify)             (gpointer data);
Worked like a charm, thanks.  (Well, after a bit of experimenting, anyway)
It's always nice to locate and fix those 400KB memory leaks.  :)  (aaaah!)

Now pretty much the only other memory issue I have with GTK+ is how and
when it chooses to allocate new memory for the purpose of returning a
value.  I.e. if you do gtk_editable_get_chars() it returns dynamically
allocated memory, which you have to g_free() after you use, but with some
other widgets, you really shouldn't free the result of functions that
return the widget's "contents" because instead of newly allocated memory,
it's just returning one of the widgets fields.  I tend to think of it
conceptually, as in, "this function returns malloc'd memory when you ask
for the contents of the widget, and here's a similar function (different
widget) that doesn't return malloc'd memory (or at least not memory you
should free)".  Conceptually, they're both functions that "return
something that's 'in' the widget".

Any chance of those types of things ending up in the RDP?  (generally,
when I free the return value of a GTK+ call when I'm done with it, I only
did it because I checked out the gtk+ source and saw that it was
g_strdup'ing a value on return.  Something like

David Free Software Development
Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das
nennen sie ihren Standpunkt.
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'

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