nic_router: destroy_each for domain tree

List method to destruct and deallocate each item of a domain tree.

Ref #2670
This commit is contained in:
Martin Stein 2018-03-07 13:57:49 +01:00 committed by Christian Helmuth
parent d5f645ee69
commit 44dd55a268
2 changed files with 13 additions and 0 deletions

View File

@ -266,6 +266,7 @@ Domain &Domain_tree::domain(Avl_string_base const &node)
return static_cast<Domain_avl_member const *>(&node)->domain();
}
Domain &Domain_tree::find_by_name(Domain_name name)
{
if (name == Domain_name() || !first()) {
@ -277,3 +278,13 @@ Domain &Domain_tree::find_by_name(Domain_name name)
return domain(*node);
}
void Domain_tree::destroy_each(Deallocator &dealloc)
{
while (Avl_string_base *first_ = first()) {
Domain &domain_ = domain(*first_);
remove(first_);
destroy(dealloc, &domain_);
}
}

View File

@ -203,6 +203,8 @@ struct Net::Domain_tree : Genode::Avl_tree<Genode::Avl_string_base>
}
void insert(Domain &domain) { Avl_tree::insert(&domain.avl_member()); }
void destroy_each(Genode::Deallocator &dealloc);
};
#endif /* _DOMAIN_H_ */