Re: GSList corruption?



rhfreeman <rhfreeman micron com> writes:
> 
> Anyway, it goes like this...
> 
>   g_slist_foreach(wl->signals, remove_signal, wl);

You can't currently remove list nodes inside a foreach. In GLib 2.0,
this works though.

The function changed as follows:

1.2:

void
g_slist_foreach (GSList   *list,
                 GFunc     func,
                 gpointer  user_data)
{
  while (list)
    {
      (*func) (list->data, user_data);
      list = list->next;
    }
}

2.0:

void
g_slist_foreach (GSList   *list,
                 GFunc     func,
                 gpointer  user_data)
{
  while (list)
    {
      GSList *next = list->next;
      (*func) (list->data, user_data);
      list = next;
    }
}

So you see the issue in 1.2 with removing the node you're currently on.

Havoc




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