diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
commit | 8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch) | |
tree | df55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-top-half/musl/src/search/twalk.c | |
parent | Initial commit. (diff) | |
download | wasi-libc-upstream/0.0_git20221206.8b7148f.tar.xz wasi-libc-upstream/0.0_git20221206.8b7148f.zip |
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-top-half/musl/src/search/twalk.c')
-rw-r--r-- | libc-top-half/musl/src/search/twalk.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/search/twalk.c b/libc-top-half/musl/src/search/twalk.c new file mode 100644 index 0000000..53821cd --- /dev/null +++ b/libc-top-half/musl/src/search/twalk.c @@ -0,0 +1,22 @@ +#include <search.h> +#include "tsearch.h" + +static void walk(const struct node *r, void (*action)(const void *, VISIT, int), int d) +{ + if (!r) + return; + if (r->h == 1) + action(r, leaf, d); + else { + action(r, preorder, d); + walk(r->a[0], action, d+1); + action(r, postorder, d); + walk(r->a[1], action, d+1); + action(r, endorder, d); + } +} + +void twalk(const void *root, void (*action)(const void *, VISIT, int)) +{ + walk(root, action, 0); +} |