On Thu, 21 Dec 2000, Jeff Shipman wrote:
> On Tue, 5 Dec 2000, Elias Athanasopoulos wrote:
>
>>
>> Hi,
>>
>> Is there a known problem when removing the first element of a double
>> linked list (GList)? I am facing a core dump, when I loop the
>> list (after I have removed the first element), something that is not
>> happening if I remove the nth element (n != 1).
>>
>> I can show you my code, if you like. I'm asking, just in case there is a
>> known issue, or maybe it's better to have a second look in my work. :-)
>>
>> Regards,
>> Elias
>>
>> PS. Please cc me, as I am not subscribed.
>>
> I've never experienced anything like this. Would you
> mind sending your code to the list?
I couldn't find the original post, but I suspect you forget to reassign the
list. Note the return type of the prototype:
GList* g_list_remove (GList *list, gpointer data);
The new list is returned, because the list pointer points to the first
element to the list. So if you do
GList *my_list = make_list_somehow(some_data, some_other_data);
g_list_remove(my_list, some_data);
do_something(g_list_next(my_list));
you're passing a NULL pointer to do_something (at best). You must reassign
the list to take care of the case when you remove the first element:
GList *my_list = make_list_somehow(some_data, some_other_data);
my_list = g_list_remove(my_list, some_data);
do_something(g_list_next(my_list));
HTH. HAND.
-Lars
--
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause) | H�rdgrim of Numenor
"I do not agree with a word that you say, but I | Retainer of Sir Kegg
will defend to the death your right to say it." | of Westfield
--Evelyn Beatrice Hall paraphrasing Voltaire | Chaos Berserker of Khorne
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list