#include <string.h>
#include <search.h>
+#ifndef weak_alias
+# define __tsearch tsearch
+# define __tfind tfind
+# define __tdelete tdelete
+# define __twalk twalk
+# define __tdestroy tdestroy
+#endif
+
+#ifndef _LIBC
+# define weak_alias(f,g)
+# define internal_function
+#endif
+
typedef struct node_t
{
/* Callers expect this to be the first element in the structure - do not
/* Routines to check tree invariants. */
-#include <assert.h>
+# include <assert.h>
-#define CHECK_TREE(a) check_tree(a)
+# define CHECK_TREE(a) check_tree(a)
static void
check_tree_recurse (node p, int d_sofar, int d_total)
#else
-#define CHECK_TREE(a)
+# define CHECK_TREE(a)
#endif
return q;
}
+#ifdef weak_alias
weak_alias (__tsearch, tsearch)
+#endif
/* Find datum in search tree.
}
return NULL;
}
+#ifdef weak_alias
weak_alias (__tfind, tfind)
+#endif
/* Delete node with given key.
free (unchained);
return retval;
}
+#ifdef weak_alias
weak_alias (__tdelete, tdelete)
+#endif
/* Walk the nodes of a tree.
if (root != NULL && action != NULL)
trecurse (root, action, 0);
}
+#ifdef weak_alias
weak_alias (__twalk, twalk)
+#endif
if (root != NULL)
tdestroy_recurse (root, freefct);
}
+#ifdef weak_alias
weak_alias (__tdestroy, tdestroy)
+#endif