summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/search/tfind.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libc-top-half/musl/src/search/tfind.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/search/tfind.c b/libc-top-half/musl/src/search/tfind.c
new file mode 100644
index 0000000..9e1cf98
--- /dev/null
+++ b/libc-top-half/musl/src/search/tfind.c
@@ -0,0 +1,20 @@
+#include <search.h>
+#include "tsearch.h"
+
+void *tfind(const void *key, void *const *rootp,
+ int(*cmp)(const void *, const void *))
+{
+ if (!rootp)
+ return 0;
+
+ struct node *n = *rootp;
+ for (;;) {
+ if (!n)
+ break;
+ int c = cmp(key, n->key);
+ if (!c)
+ break;
+ n = n->a[c>0];
+ }
+ return n;
+}