Re: g_slist_foreach and g_list_foreach functions

Darin Adler <darin eazel com> writes:

> on 9/20/00 9:56 PM, Tim Janik at timj gtk org wrote:
> > we generally don't support full reentrancy for everything, e.g.
> > things like list walks. but we at least try to care about the
> > case where the _current_ element is being removed.
> > the point in doing that trade, is that simply walking a list,
> > check elements and remove them, is a pretty common operation.
> > that's why pretty much all *_forall() implementations of our
> > containers conatin code ala:
> > 
> > GList *nnode = node->next;
> > callback (node->data);
> > node = nnode;
> > 
> > to cover up for that case. based on that, the proposed changes
> > for slist/list make a lot of sense.
> OK. Then the function in Nautilus called nautilus_g_list_safe_for_each can
> go for GNOME 2 then! I assumed it was considered too dangerous to change
> such things without changing the function name.

What's the danger? All currently working code will continue to work,
and we don't guarnatee that code that works with GLib-1.2 will work
with GLib-2.0.

(I would say that if you are planning to remove elements, then doing
g_list_foreach() and g_list_remove() is a poor way to do it. If you
don't simply write it as a loop, which I would tend to do, you really
want a g_list_remove_all_custom() which takes a predicate. I forget if
Maciej's suggested additions have anything like that.)



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