1 /* $NetBSD: tdestroy.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
4 * Tree search generalized from Knuth (6.2.2) Algorithm T just like
5 * the AT&T man page says.
7 * The node_t structure is for internal use only, lint doesn't grok it.
9 * Written by reading the System V Interface Definition, not the code.
11 * Totally public domain.
14 #define _SEARCH_PRIVATE
20 #include <sys/cdefs.h>
24 /* Walk the nodes of a tree */
26 trecurse(node_t* root, void (*free_action)(void *))
28 if (root->llink != NULL)
29 trecurse(root->llink, free_action);
30 if (root->rlink != NULL)
31 trecurse(root->rlink, free_action);
33 (*free_action) ((void *) root->key);
38 tdestroy(vrootp, freefct)
40 void (*freefct)(void *);
42 node_t *root = (node_t *) vrootp;
45 trecurse(root, freefct);