mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-12 13:48:30 +00:00
nic_router: destroy list items during for_each
The for_each method of the List wrapper remembers the next list item before calling the functor on the current one, so, the current one can be destroyed during the functor. Ref #2670
This commit is contained in:
parent
930c29a50c
commit
4e8453b7bf
@ -29,10 +29,11 @@ struct Net::List : Genode::List<LT>
|
||||
template <typename FUNC>
|
||||
void for_each(FUNC && functor)
|
||||
{
|
||||
for (LT * elem = Base::first(); elem;
|
||||
elem = elem->Base::Element::next())
|
||||
for (LT *elem = Base::first(); elem; )
|
||||
{
|
||||
LT *const next = elem->Base::Element::next();
|
||||
functor(*elem);
|
||||
elem = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user