diff options
author | nsz <nsz@port70.net> | 2012-05-13 01:34:20 +0200 |
---|---|---|
committer | nsz <nsz@port70.net> | 2012-05-13 01:34:20 +0200 |
commit | d197d6421c317145e2aff89dd41de9d03eeaa00b (patch) | |
tree | 7d908d68391a592e9843d49443874f0461bc9f51 /src | |
parent | b47fdcdef8e88452914636ce23ee6792f259b5dc (diff) | |
download | musl-d197d6421c317145e2aff89dd41de9d03eeaa00b.tar.gz musl-d197d6421c317145e2aff89dd41de9d03eeaa00b.tar.bz2 musl-d197d6421c317145e2aff89dd41de9d03eeaa00b.tar.xz musl-d197d6421c317145e2aff89dd41de9d03eeaa00b.zip |
search: add tdestroy (gnu extension)
Diffstat (limited to 'src')
-rw-r--r-- | src/search/tdestroy.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/search/tdestroy.c b/src/search/tdestroy.c new file mode 100644 index 00000000..6f430bda --- /dev/null +++ b/src/search/tdestroy.c @@ -0,0 +1,21 @@ +#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); + freekey(r->key); + free(r); +} |