repo.or.cz
/
musl.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
netinet/tcp.h: add TCP_NLA_* values up to linux v5.12
[musl.git]
/
src
/
search
/
tfind.c
blob
9e1cf98f5c51140d81108189bceaab73a6c9756d
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
}