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



> 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



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