Re: [gtk-list] Re: Freeing memory allocated with gtk_*_new()




The tutorial, sadly, makes no mention of freeing memory...

Sean C. Rhea
http://www.ece.utexas.edu/~srhea

                  --- Please respond to srhea@ieee.org ---

On 27 Jan 1999, Elliot Lee wrote:

> 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.
> 
> However, most of the time you do not have to free it up at all. When you
> add the label into a container, for example, the container assumes
> ownership of the label via a refcount, and the label is destroyed when the
> container is destroyed.
> 
> I'm sure there's a good gtk+ tutorial out there somewhere,
> -- Elliot
> "In film you will find four basic story lines. Man versus man, man
>  versus nature, nature versus nature, and dog versus vampire."
>     - Steven Spielberg
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 



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