xref: /haiku/src/system/libroot/posix/musl/search/tdestroy.c (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
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 }
17