Re: g_list_first()
- From: Elmano Carvalho <elmano carvalho gmail com>
- To: Mathieu LUGIEZ <mathmath_07 hotmail com>
- Cc: gtk-devel-list gnome org
- Subject: Re: g_list_first()
- Date: Fri, 2 Dec 2005 13:36:23 -0400
Hello guys,
thanks for the help as I was able to get a better idea of how to solve this problem.
And indeed I was able to devise something that seems to do the job.
B.R., Elmano
On 11/30/05, Mathieu LUGIEZ <mathmath_07 hotmail com> wrote:
Hello, What did you need to do exactly????
If you need to test all elements in a single list and delete elements you
whish you can use this type of code, it isn't optimised but it work's, else
you can use g_list_foreach to apply a personnal function at each element of
your GSList but it doesn't work for deleting GSList.
If you need any explanation mail me.
static GSList* _your_function(GSList* list, gint X)
{
GSList *saveList=list,*buflist=list;
while(list)
{
if( your_test ) //(list->data < X) for example
{
gfree(list->data);
if(list==buflist) //
case of first element of the list, we don't loose
the begin of the list
{
saveList=list->next;
buflist=list->next;
gfree(list);
list=buflist;
}
else
{
buflist->next=list->next; //if
you need to free the list,
update the next element of the preceding list
gfree(list);
list=buflist->next;
}
}
else
{
buflist=list;
list=list->next;
}
}
return saveList;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]