summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 52c636c)
raw | patch | inline | side by side (parent: 52c636c)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 9 Jul 2014 09:34:10 +0000 (11:34 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 9 Jul 2014 09:34:10 +0000 (11:34 +0200) |
src/utils/avltree.c | patch | blob | history |
diff --git a/src/utils/avltree.c b/src/utils/avltree.c
index 8c13233b2eabb6dd7f3fbfd3e408eaccf99f5a0f..6189d1716131cbbc3b00cd4321b43a1de3cdaede 100644 (file)
--- a/src/utils/avltree.c
+++ b/src/utils/avltree.c
return next;
} /* node_next */
+static node_t *
+node_smallest(sdb_avltree_t *tree)
+{
+ node_t *n;
+
+ if (! tree)
+ return NULL;
+
+ n = tree->root;
+ while (n && n->left)
+ n = n->left;
+ return n;
+} /* node_smallest */
+
static void
tree_clear(sdb_avltree_t *tree)
{
pthread_rwlock_rdlock(&tree->lock);
iter->tree = tree;
- iter->node = tree->root->left;
- while (iter->node && iter->node->left)
- iter->node = iter->node->left;
+ iter->node = node_smallest(tree);
pthread_rwlock_unlock(&tree->lock);
return iter;