vlist: define vlist_for_each_element_safe
authorDaniel Golle <daniel@makrotopia.org>
Fri, 12 Nov 2021 20:04:29 +0000 (20:04 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 20 Nov 2021 17:44:11 +0000 (17:44 +0000)
Yet another macro wrapper around the corresponding avl_* macro.
This new macro makes it possible to iterate over vlists in ways which
may have destructive consequences without being punished by segfault.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
vlist.h

diff --git a/vlist.h b/vlist.h
index ff6b138c19b7a3748dfae18db518b47f18a199cb..381fd970d798f8cccfbb64a30cde2f578ad677d6 100644 (file)
--- a/vlist.h
+++ b/vlist.h
@@ -72,6 +72,9 @@ void vlist_flush_all(struct vlist_tree *tree);
 #define vlist_for_each_element(tree, element, node_member) \
        avl_for_each_element(&(tree)->avl, element, node_member.avl)
 
+#define vlist_for_each_element_safe(tree, element, node_member, ptr) \
+       avl_for_each_element_safe(&(tree)->avl, element, node_member.avl, ptr)
+
 #define vlist_for_each_element_reverse(tree, element, node_member) \
        avl_for_each_element_reverse(&(tree)->avl, element, node_member.avl)