Re: GList strange behavior



Thank you! I almost understand bahavior of GList.

I need to save newly created list poiner. So, i need to use g_list_last() to 
save it? Is there another method to save created list pointer?

Ð ÑÐÐÐÑÐÐÐÐ ÐÑ ÐÐÑÐÐÑÐ 16 ÐÐÐÑÑÑÐ 2012 15:51:22 ÐÑ ÐÐÐÐÑÐÐÐ:
Hi.

Not sure what is troubling you here. GList is represented by pointer
to first element or NULL if list is empty. And when you append items
to the list, the address of the list stays the same, since first
element of the list is unchanged (exception to this is when append
first element to an empty list).

Some code to explain some things:

GList *list = NULL /* Empty list */
list = g_list_append (list, GINT_TO_POINTER (1)); /* Add first
element, list points to some ADDR1 */
list = g_list_append (list, GINT_TO_POINTER (2)); /* Add second
element, list still points to ADDR1 */
...

Cheers,
Tadej



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