Re: Why there's still ONE element left after g_slist_free () ?

2009-05-14 Thread Robert Pearce
On Thu, 14 May 2009 20:27:18 + american.communist.pa...@gmail.com wrote: > You should quote the object of the comment ENTIRELY before commenting, > shouldn't you? Nobody misquoted you, nor did they strip any of your comment out. And nobody was objecting to your comment as a result of lack o

Re: Re: Why there's still ONE element left after g_slist_free () ?

2009-05-14 Thread american . communist . party
You should quote the object of the comment ENTIRELY before commenting, shouldn't you? The actual comment by PenT does state as much: "to assign NULL to it after g_slist_free ()..." AFTER g_slist_free. I don't see that I was mutually exclusive in my reply. On May 14, 2009 11:51am, Chris Moller

Re: Why there's still ONE element left after g_slist_free () ?

2009-05-14 Thread Chris Moller
american.communist.pa...@gmail.com wrote: > Its old hat to C programmers that you set any object to NULL when > you're done with it, which returns the memory used to the heap. That's specifically /not/ true in C: You have to explicitly free allocated space--setting a pointer to null doesn't auto

Re: Re: Why there's still ONE element left after g_slist_free () ?

2009-05-14 Thread Tor Lillqvist
> Its old hat to C programmers that you set any object to NULL when you're done > with it, > which returns the memory used to the heap. That's not necessary with > languages that > have garbage collection like Java, Python, etc. Yes and no. One could say that on the contrary, in languages with g

Re: Re: Why there's still ONE element left after g_slist_free () ?

2009-05-14 Thread american . communist . party
Its old hat to C programmers that you set any object to NULL when you're done with it, which returns the memory used to the heap. That's not necessary with languages that have garbage collection like Java, Python, etc. On May 13, 2009 3:56am, PenT wrote: Thanks to Yeti, tml and Pfeiffer, I

Re: Why there's still ONE element left after g_slist_free () ?

2009-05-13 Thread PenT
Thanks to Yeti, tml and Pfeiffer, I finally realized what happend to the GSList. May be I'm spoiled by Python, Java that I had the strange SHOULD-BE-NULL thought, now I know if I need to reuse the GSList* variable, the first thing is to assign NULL to it after g_slist_free (), also surprised g_s

Re: Why there's still ONE element left after g_slist_free () ?

2009-05-13 Thread Szilard Pfeiffer
If you give a pointer to g_slist_length() which is not null the result must be at least 1, because only the null value shows the end of the list. The g_slist_free function does not set it's parameter to null (as it can not do it) so your GSList * variable after the function call points to a fre

Re: Why there's still ONE element left after g_slist_free () ?

2009-05-13 Thread Tor Lillqvist
> I thought after g_slist_free (), the GSList should be empty(NULL), why still When you say "the GSList should be NULL", what do you mean? You have a GSList* variable that used to point to the list? Do you assign NULL to that variable yourself? If not, it is not going to become NULL magically by i

Re: Why there's still ONE element left after g_slist_free () ?

2009-05-13 Thread David Nečas
On Wed, May 13, 2009 at 02:34:35PM +0800, PenT wrote: > I created a GSList and then free it using g_slist_free (), then I call > g_slist_length() and it return 1, surprising! > > I thought after g_slist_free (), the GSList should be empty(NULL), why still > 1 left? Stop using the invalid pointer

Why there's still ONE element left after g_slist_free () ?

2009-05-12 Thread PenT
I created a GSList and then free it using g_slist_free (), then I call g_slist_length() and it return 1, surprising! I thought after g_slist_free (), the GSList should be empty(NULL), why still 1 left? ___ gtk-list mailing list gtk-list@gnome.org http://