提交 d197d642 编写于 作者: N nsz

search: add tdestroy (gnu extension)

上级 b47fdcde
......@@ -38,6 +38,8 @@ struct qelem {
struct qelem *q_forw, *q_back;
char q_data[1];
};
void tdestroy(void *, void (*)(void *));
#endif
#ifdef __cplusplus
......
#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);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册