blob: 5f9e197dcd1ea57869a0aa74f3c57d010ec163c6 (
plain) (
tree)
|
|
#define _GNU_SOURCE
#include <stdlib.h>
#include <search.h>
struct node {
void *key;
struct node *left;
struct node *right;
};
void tdestroy(void *root, void (*freekey)(void *))
{
struct node *r = root;
if (r == 0)
return;
tdestroy(r->left, freekey);
tdestroy(r->right, freekey);
if (freekey) freekey(r->key);
free(r);
}
|