Re: g_list_insert_sorted bug

Patrick Rogan <> writes:

> Sorry Owen, you are incorrect.

Well, it wouldn't be the first time. (One only learns by being
wrong occasionally...) But, in this case I'm pretty sure
of myself. ;-)


> int some_func(gpointer data, gpointer user_data) {
>   printf ("*: %s, %s\n", data, user_data);
> }
> int main (){
> GSList       *Llist;
> Llist = g_slist_alloc();

Here is your problem. g_slist_alloc() does not allocate
a singly-linked-list, it allocates one node of a singly
linked note. [ And one very seldom has to call that function
directly, since nodes are usually allocated by g_slist_prepend()
or g_slist_append() ]

As in my example last time, the correct way to allocate
an empty GSlist is.

 GSList *Llist;
 llist = NULL;

Yep, a empty GSList is just a NULL pointer. (There are no
nodes, so nothing to point to.)

Hope this clears things up,

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