]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/search/tdestroy.c
WASI libc prototype implementation.
[wasi-libc.git] / libc-top-half / musl / src / search / tdestroy.c
1 #define _GNU_SOURCE
2 #include <stdlib.h>
3 #include <search.h>
4 #include "tsearch.h"
5
6 void tdestroy(void *root, void (*freekey)(void *))
7 {
8 struct node *r = root;
9
10 if (r == 0)
11 return;
12 tdestroy(r->a[0], freekey);
13 tdestroy(r->a[1], freekey);
14 if (freekey) freekey((void *)r->key);
15 free(r);
16 }