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
23 #include <sys/cdefs.h>
27 /* Walk the nodes of a tree */
29 trecurse(node_t* root, void (*free_action)(void *))
31 if (root->llink != NULL)
32 trecurse(root->llink, free_action);
33 if (root->rlink != NULL)
34 trecurse(root->rlink, free_action);
36 (*free_action) ((void *) root->key);
41 tdestroy(vrootp, freefct)
43 void (*freefct)(void *);
45 node_t *root = (node_t *) vrootp;
48 trecurse(root, freefct);