Re: Freeing memory allocated with gtk_*_new()




sopwith@redhat.com (Elliot Lee) writes:

> On Wed, 27 Jan 1999 12:47:14 -0600 (CST), Sean Christopher Rhea
> <srhea@ece.utexas.edu> wrote:
> 
> >What is the "proper" way to free memory allocated with gtk_*_new()?
> >For instance:
> >
> >GtkWidget * foo = gtk_label_new ( "bar" );
> >
> >/* use foo */
> >
> >free ( foo );  /* this is wrong, right? */
> >
> >gtktypes.h declares gtk_type_free, but do I use that or is there some
> >other (preferred) way to do it?
> 
> 	gtk_object_destroy(GTK_OBJECT(foo));
> 
> For widgets,
> 	gtk_widget_destroy(GTK_WIDGET(foo));
> 
> will do almost exeactly the same thing, but hide the widget before
> destroying it.

Actually, gtk_widget_destroy() and gtk_object_destroy() are
completely synonymous. gtk_widget_destroy() is there for
compatibility purposes, because in the past, you had to
call gtk_widget_destroy() on widgets.

                                        Owen



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