summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/tfind.c
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
committercvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
commiteb8dd9dca1228af0cd132f515509051ecfabf6f6 (patch)
treeedb6da6af7e865d488dc1a29309f1e1ec226e603 /src/lib/libc/stdlib/tfind.c
parent247f0352e0ed72a4f476db9dc91f4d982bc83eb2 (diff)
downloadopenbsd-tb_20250414.tar.gz
openbsd-tb_20250414.tar.bz2
openbsd-tb_20250414.zip
This commit was manufactured by cvs2git to create tag 'tb_20250414'.tb_20250414
Diffstat (limited to 'src/lib/libc/stdlib/tfind.c')
-rw-r--r--src/lib/libc/stdlib/tfind.c40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/lib/libc/stdlib/tfind.c b/src/lib/libc/stdlib/tfind.c
deleted file mode 100644
index 49f9dbc17a..0000000000
--- a/src/lib/libc/stdlib/tfind.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/* $OpenBSD: tfind.c,v 1.7 2015/09/26 16:03:48 guenther Exp $ */
2
3/*
4 * Tree search generalized from Knuth (6.2.2) Algorithm T just like
5 * the AT&T man page says.
6 *
7 * The node_t structure is for internal use only
8 *
9 * Written by reading the System V Interface Definition, not the code.
10 *
11 * Totally public domain.
12 */
13#include <search.h>
14
15typedef struct node_t
16{
17 char *key;
18 struct node_t *llink, *rlink;
19} node;
20
21/* find a node, or return 0 */
22void *
23tfind(const void *vkey, void * const *vrootp,
24 int (*compar)(const void *, const void *))
25{
26 char *key = (char *)vkey;
27 node **rootp = (node **)vrootp;
28
29 if (rootp == (struct node_t **)0)
30 return ((struct node_t *)0);
31 while (*rootp != (struct node_t *)0) { /* T1: */
32 int r;
33 if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
34 return (*rootp); /* key found */
35 rootp = (r < 0) ?
36 &(*rootp)->llink : /* T3: follow left branch */
37 &(*rootp)->rlink; /* T4: follow right branch */
38 }
39 return (node *)0;
40}