1 #include <search.h> 2 #include "tsearch.h" 3 tfind(const void * key,void * const * rootp,int (* cmp)(const void *,const void *))4void *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 } 21