summaryrefslogtreecommitdiff
path: root/filter/tree.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2021-02-07 19:21:42 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2021-02-07 19:21:42 +0100
commitd06a875b042b608e61b2d5a2bb594641d3e1322f (patch)
treea4eae99c62b0b2349a42f229ac558e11f2f445d5 /filter/tree.c
parent5d414309ec5a01024d4de4c4f9521f8daa5c06ff (diff)
Filter: Recursive filter iteration code
Add macros for recursive filter iteration that allows to examine all instructions reachable from a filter.
Diffstat (limited to 'filter/tree.c')
-rw-r--r--filter/tree.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/filter/tree.c b/filter/tree.c
index 2bbc84bb..5da86b9d 100644
--- a/filter/tree.c
+++ b/filter/tree.c
@@ -170,3 +170,14 @@ tree_format(const struct f_tree *t, buffer *buf)
buffer_puts(buf, "]");
}
+
+void
+tree_walk(const struct f_tree *t, void (*hook)(const struct f_tree *, void *), void *data)
+{
+ if (!t)
+ return;
+
+ tree_walk(t->left, hook, data);
+ hook(t, data);
+ tree_walk(t->right, hook, data);
+}