diff --git a/src/utils/avltree.c b/src/utils/avltree.c
index 7397a34fdbb56dfd54d4db07c82f797cf3d93b76..54c1895673a8dd68e6aeccf4655615db00078930 100644 (file)
--- a/src/utils/avltree.c
+++ b/src/utils/avltree.c
{
node_t *n;
- n = node_smallest(tree);
+ if ((! tree) || (! tree->root))
+ return;
+
+ /* do a depth-first iteration and delete the leafs */
+ n = tree->root;
while (n) {
- node_t *tmp = node_next(n);
+ node_t *tmp;
+
+ if (n->left) {
+ n = n->left;
+ continue;
+ }
+ else if (n->right) {
+ n = n->right;
+ continue;
+ }
+
+ tmp = n->parent;
+ if (tmp) {
+ if (tmp->left == n)
+ tmp->left = NULL;
+ else
+ tmp->right = NULL;
+ }
node_destroy(n);
n = tmp;
free(iter);
} /* sdb_avltree_iter_destroy */
-_Bool
+bool
sdb_avltree_iter_has_next(sdb_avltree_iter_t *iter)
{
if (! iter)
return tree ? tree->size : 0;
} /* sdb_avltree_size */
-_Bool
+bool
sdb_avltree_valid(sdb_avltree_t *tree)
{
node_t *n;
- _Bool status = 1;
+ bool status = 1;
size_t size = 0;
if (! tree)