blob: 699a901c6a8e628a5465c82a7b48837139d4b751 [file] [log] [blame]
#define _GNU_SOURCE
#include <stdlib.h>
#include <search.h>
#include "tsearch.h"
void tdestroy(void *root, void (*freekey)(void *))
{
struct node *r = root;
if (r == 0)
return;
tdestroy(r->a[0], freekey);
tdestroy(r->a[1], freekey);
if (freekey) freekey((void *)r->key);
free(r);
}