mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-10 22:44:30 +00:00
nic_router: destroy_each for list wrapper
List method to destruct and deallocate each item of a list. Ref #2670
This commit is contained in:
parent
8fff7df438
commit
d5f645ee69
@ -16,23 +16,33 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/list.h>
|
||||
#include <base/allocator.h>
|
||||
|
||||
namespace Net { template <typename> class List; }
|
||||
|
||||
namespace Net {
|
||||
template <typename> class List;
|
||||
}
|
||||
|
||||
template <typename LT>
|
||||
struct Net::List : Genode::List<LT>
|
||||
{
|
||||
using Base = Genode::List<LT>;
|
||||
|
||||
template <typename FUNC>
|
||||
void for_each(FUNC && functor)
|
||||
{
|
||||
for (LT * elem = Genode::List<LT>::first(); elem;
|
||||
elem = elem->Genode::List<LT>::Element::next())
|
||||
for (LT * elem = Base::first(); elem;
|
||||
elem = elem->Base::Element::next())
|
||||
{
|
||||
functor(*elem);
|
||||
}
|
||||
}
|
||||
|
||||
void destroy_each(Genode::Deallocator &dealloc)
|
||||
{
|
||||
while (LT *elem = Base::first()) {
|
||||
Base::remove(elem);
|
||||
destroy(dealloc, elem);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _LIST_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user