]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/search/tfind.c
WASI libc prototype implementation.
[wasi-libc.git] / libc-top-half / musl / src / search / tfind.c
1 #include <search.h>
2 #include "tsearch.h"
3
4 void *tfind(const void *key, void *const *rootp,
5 int(*cmp)(const void *, const void *))
6 {
7 if (!rootp)
8 return 0;
9
10 struct node *n = *rootp;
11 for (;;) {
12 if (!n)
13 break;
14 int c = cmp(key, n->key);
15 if (!c)
16 break;
17 n = n->a[c>0];
18 }
19 return n;
20 }