#include <sys/cdefs.h>
#if 0
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
#endif
#endif
#define _SEARCH_PRIVATE
#include <stdlib.h>
#include <search.h>
posix_tnode *
tfind(const void *vkey, posix_tnode * const *rootp,
int (*compar)(const void *, const void *))
{
if (rootp == NULL)
return NULL;
while (*rootp != NULL) {
int r;
if ((r = (*compar)(vkey, (*rootp)->key)) == 0)
return *rootp;
rootp = (r < 0) ?
&(*rootp)->llink :
&(*rootp)->rlink;
}
return NULL;
}