1 #define _GNU_SOURCE 2 #include <stdlib.h> 3 #include <search.h> 4 #include "tsearch.h" 5 tdestroy(void * root,void (* freekey)(void *))6void 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