[10643] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: potential problems with malloc/free vs. C++ ne w/delete ???

daemon@ATHENA.MIT.EDU (Rostedt, Steven)
Thu Dec 3 09:17:32 1998

Date: Thu, 03 Dec 1998 09:16:25 -0500
From: "Rostedt, Steven" <steven.rostedt@lmco.com>
To: "'gtk-list@redhat.com'" <gtk-list@redhat.com>
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


> >   gchar **text;
> >   text = new gchar*[8];
> >   for (i=0; i<8; i++) {
> >     text[i] = new char[100];
> >   }
> >         // set values of text[i]
> >   gtk_clist_insert(clist, location, text);
> 
> > Should I instead be using malloc and free (or the glib wrappers) for
> > any allocation for gtk even though my program has to use new and
> > delete for the C++ class alocations?
> 
> If there already isn't, there should be a gtk_alloc/gtk_free pair that
> you should use for any allocations that gtk will use, and for any
> deallocations of gtk-allocated memory you will do. This is similar to
> Xt's XtMalloc and XtFree, which merely wrap malloc/free. This way, there
> is no question as to which api to use.
> 
> In the time being, if gtk uses malloc/free then you should do so as well
> for gtk-related memory as above. It's best not to take chances!
> 
> 
	I've gotten into the habit of using glib's g_malloc and g_free.  
	I'm guessing that gtk would use this also.
	I did notice in the header of glib.h that their is a g_new defined
	as g_malloc. But I didn't find any g_delete :(


-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post