[OpenWrt-Devel] [PATCH libubox] vlist: add more macros for loop iteration

Yousong Zhou yszhou4tech at gmail.com
Tue Oct 29 09:08:49 EDT 2019


Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 vlist.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/vlist.h b/vlist.h
index 8170abf..ff6b138 100644
--- a/vlist.h
+++ b/vlist.h
@@ -72,4 +72,19 @@ 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_reverse(tree, element, node_member) \
+	avl_for_each_element_reverse(&(tree)->avl, element, node_member.avl)
+
+#define vlist_for_first_to_element(tree, last, element, node_member) \
+	avl_for_element_range(avl_first_element(&(tree)->avl, element, node_member.avl), last, element, node_member.avl)
+
+#define vlist_for_first_to_element_reverse(tree, last, element, node_member) \
+	avl_for_element_range_reverse(avl_first_element(&(tree)->avl, element, node_member.avl), last, element, node_member.avl)
+
+#define vlist_for_element_to_last(tree, first, element, node_member) \
+	avl_for_element_range(first, avl_last_element(&(tree)->avl, element, node_member.avl), element, node_member.avl)
+
+#define vlist_for_element_to_last_reverse(tree, first, element, node_member) \
+	avl_for_element_range_reverse(first, avl_last_element(&(tree)->avl, element, node_member.avl), element, node_member.avl)
+
 #endif

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list