[10666] 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++ new/delete ???

daemon@ATHENA.MIT.EDU (Dave Reed)
Thu Dec 3 19:09:27 1998

Date: Thu, 3 Dec 1998 17:37:10 -0500
From: Dave Reed <dreed@capital.edu>
To: gtk-list@redhat.com
In-Reply-To: <Pine.GSO.3.95.981203114101.22549B-100000@harper.uchicago.edu>
	(message from Havoc Pennington on Thu, 3 Dec 1998 11:48:14 -0600 (CST))
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com

> From: Havoc Pennington <rhpennin@midway.uchicago.edu>
> 
> On Thu, 3 Dec 1998, Dave Reed wrote:
> > 
> >   gtk_clist_insert(clist, location, text);
> > 
> > When I clear the clist, I assume the code deallocates the space for
> > the strings (correct?)
> 
> No, it copies them, which you would know if the function had the right
> signature, but Tim is stubbornly wrong about this. ;-) 

So do I have a memory leak then?  What is the proper way around this?
Do I have to remember to delete all the strings myself after calling
the gtk_clist_clear() function.  Or can I delete them after adding
them to the clist?  I thought I tried using the same string with
different values each time I added them to the clist and I ended up
with all the entries being the same as the last one I had set the
string to.

e.g,

sprintf(str, "a");
// add to clist
sprintf(str, "b");
// add to clist

and both entries would be b.

So I assumed the clist just had a pointer that it would free when the
list is cleared.


Thanks,
Dave
dreed@capital.edu

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


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