[10671] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Re: potential problems with malloc/free vs. C++ new/delete ???
daemon@ATHENA.MIT.EDU (Havoc Pennington)
Thu Dec 3 20:31:54 1998
Date: Thu, 3 Dec 1998 19:30:15 -0600 (CST)
From: Havoc Pennington <rhpennin@midway.uchicago.edu>
Reply-To: Havoc Pennington <rhpennin@midway.uchicago.edu>
To: gtk-list@redhat.com
In-Reply-To: <199812040125.UAA09637@fourier.capital.edu.capital.edu>
Resent-From: gtk-list@redhat.com
On Thu, 3 Dec 1998, Dave Reed wrote:
> Should I be freeing anything here after it gets added to the combo?
> What part of the documentation should I be looking in to find the
> answers to these kind of memory questions?
>
You can look for a comment in the header files; other than that, you
pretty much have to read the source code for the function, and see if the
string is copied or kept.
In the GtkCombo case, the string is used in this context:
list = strings;
while (list)
{
li = gtk_list_item_new_with_label ((gchar *) list->data);
gtk_widget_show (li);
gtk_container_add (GTK_CONTAINER (combo->list), li);
list = list->next;
}
gtk_list_item_new_with_label() copies the string I think, so you are
responsible for freeing it. (I think Gtk probably is consistent about
copying strings rather than using the ones you pass in, at least I can't
think of an exception right now.)
Someday we will have documentation. :-)
Havoc
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null