@@ -46,4 +46,7 @@ namespace list
} // namespace list
+#define list_for_each(cur, head) \
+ for (cur = (head)->next; cur != (head); cur = cur->next)
+
} // namespace crown
@@ -75,12 +75,11 @@ void UnitManager::unregister_destroy_callback(UnitDestroyCallback* udc)
void UnitManager::trigger_destroy_callbacks(UnitId id)
{
- ListNode* cur = _callbacks.node.next;
- while (cur != &_callbacks.node)
+ ListNode* cur;
+ list_for_each(cur != &_callbacks.node)
UnitDestroyCallback* udc = (UnitDestroyCallback*)container_of(cur, UnitDestroyCallback, node);
udc->destroy(id, udc->user_data);
- cur = cur->next;
}
@@ -66,11 +66,10 @@ World::World(Allocator& a, ResourceManager& rm, ShaderManager& sm, MaterialManag
World::~World()
// Destroy loaded levels
- ListNode* cur = _levels.next;
- while (cur != &_levels)
+ list_for_each(cur != &_levels)
Level* level = (Level*)container_of(cur, Level, _node);
CE_DELETE(*_allocator, level);