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



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 that points to the memory freed by
g_slist_free() and your problem will be gone.

There is no way g_slist_free() could change your pointer -- it does not
take a reference to it -- it just frees the list.

Yeti



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