master
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#include <assert.h>
8#define _SEARCH_PRIVATE
9#define _GNU_SOURCE
10#include <stdlib.h>
11#include <search.h>
12
13
14/* destroy tree recursively and call free_node on each node key */
15void tdestroy(void *root, void (*free_node)(void *))
16{
17 node_t *p = (node_t *)root;
18 if (!p)
19 return;
20
21 tdestroy(p->llink , free_node);
22 tdestroy(p->rlink, free_node);
23 free_node((void*)p->key);
24 free(p);
25}