From 8336422c8ad72b98e3af9c038468b62a9eafac3c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 14 Feb 2015 19:34:49 +0100 Subject: Add first btree test ; fix first btree test. --- src/common/libalgo/btree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/libalgo/btree.c b/src/common/libalgo/btree.c index da0e25b..08a43ef 100644 --- a/src/common/libalgo/btree.c +++ b/src/common/libalgo/btree.c @@ -24,7 +24,7 @@ btree_t* create_btree(key_cmp_fun_t cf, kv_iter_fun_t relf) { if (t == 0) return 0; t->cf = cf; - t->releasef = relf; + if (t->releasef) t->releasef = relf; t->root = 0; t->nitems = 0; @@ -39,7 +39,7 @@ void delete_btree(btree_t *t) { delete_item_rec(i->left, relf); delete_item_rec(i->right, relf); - relf(i->key, i->val); + if (relf) relf(i->key, i->val); free(i); } @@ -182,7 +182,7 @@ void btree_remove(btree_t *t, const void* key) { new_i = equilibrate(new_i); } - t->releasef(i->key, i->val); + if (t->releasef) t->releasef(i->key, i->val); free(i); t->nitems--; -- cgit v1.2.3