Re: [gtk-list] Re: g_list_insert_sorted bug
- From: Some Guy <guy mikepery pr mcs net>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: g_list_insert_sorted bug
- Date: Wed, 1 Jul 1998 23:56:29 -0500 (CDT)
> No, no, no. This is entirely wrong.
Oops, sorry :)
> An _empty_ GList is represented by NULL. This is entirely different
> from a list node with the data member equal to NULL.
>
> GList *list = NULL; /* empty */
>
> list = g_list_append (list, "one"); /* now has one element */
> list = g_list_append (list, "two"); /* now has two elements */
I always thought g_list_alloc() allocated a GList (almost makes sense,
doesn't it? :) Because of that I'd always get a first item of NULL (since
I would always alloc a list, then append items). But you're right, if you
just append to a NULL list, glib automatically creates the list for you.
The reason I got confused was because using a NULL first item is usually
the way I implement a linked list. It makes logic easier by just having
to add to list->next, and not worrying about whether 'list' is the head
pointer.
Sorry for the mistake.
---
Matt Perry [guy@mikepery.linuxos.org]
Join the army, see the world, meet interesting, exciting people, and kill them.
---
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]