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 // Do not implement tdestroy if that's the only missing t* function
26 /* Walk the nodes of a tree */
28 trecurse(node_t* root, void (*free_action)(void *))
30 if (root->llink != NULL)
31 trecurse(root->llink, free_action);
32 if (root->rlink != NULL)
33 trecurse(root->rlink, free_action);
35 (*free_action) ((void *) root->key);
40 tdestroy(vrootp, freefct)
42 void (*freefct)(void *);
44 node_t *root = (node_t *) vrootp;
47 trecurse(root, freefct);