Re: GList strange behavior



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

-- 
Tadej BorovÅak
blog.borovsak.si
tadeboro gmail com
tadej borovsak gmail com



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