Re: [gtk-list] potential problems with malloc/free vs. C++ new/delete ???
- From: Paul Miller <Paul_Miller avid com>
- To: Dave Reed <dreed capital edu>
- CC: gtk-list redhat com
- Subject: Re: [gtk-list] potential problems with malloc/free vs. C++ new/delete ???
- Date: Thu, 03 Dec 1998 09:13:08 -0500
> 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!
-Paul
--
Paul T. Miller | paul@elastic.avid.com
Principal Engineer | Opinions expressed here are my own.
Avid Technology, Inc. - Graphics and Effects Software Group
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]