X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_avltree.c;h=3e258e95d8c6834271823cab5aa5cddfc3a4845a;hb=4858a84e3e51830a103a5ff4aee6b844b708ce62;hp=83821fe99c37671ad36ece3ab3d14ddcba84f1d1;hpb=f71467d9c2097ddd9eb772a4fdb985663168ec71;p=collectd.git diff --git a/src/utils_avltree.c b/src/utils_avltree.c index 83821fe9..3e258e95 100644 --- a/src/utils_avltree.c +++ b/src/utils_avltree.c @@ -264,7 +264,7 @@ static void rebalance (c_avl_tree_t *t, c_avl_node_t *n) } /* while (n != NULL) */ } /* void rebalance */ -static c_avl_node_t *c_avl_node_next (c_avl_tree_t *t, c_avl_node_t *n) +static c_avl_node_t *c_avl_node_next (c_avl_node_t *n) { c_avl_node_t *r; /* return node */ @@ -309,7 +309,7 @@ static c_avl_node_t *c_avl_node_next (c_avl_tree_t *t, c_avl_node_t *n) return (r); } /* c_avl_node_t *c_avl_node_next */ -static c_avl_node_t *c_avl_node_prev (c_avl_tree_t *t, c_avl_node_t *n) +static c_avl_node_t *c_avl_node_prev (c_avl_node_t *n) { c_avl_node_t *r; /* return node */ @@ -364,13 +364,13 @@ static int _remove (c_avl_tree_t *t, c_avl_node_t *n) if (BALANCE (n) > 0) /* left subtree is higher */ { assert (n->left != NULL); - r = c_avl_node_prev (t, n); + r = c_avl_node_prev (n); } else /* right subtree is higher */ { assert (n->right != NULL); - r = c_avl_node_next (t, n); + r = c_avl_node_next (n); } assert ((r->left == NULL) || (r->right == NULL)); @@ -518,7 +518,7 @@ int c_avl_insert (c_avl_tree_t *t, void *key, void *value) if (cmp == 0) { free_node (new); - return (-1); + return (1); } else if (cmp < 0) { @@ -581,6 +581,8 @@ int c_avl_get (c_avl_tree_t *t, const void *key, void **value) { c_avl_node_t *n; + assert (t != NULL); + n = search (t, key); if (n == NULL) return (-1); @@ -662,7 +664,7 @@ int c_avl_iterator_next (c_avl_iterator_t *iter, void **key, void **value) } else { - n = c_avl_node_next (iter->tree, iter->node); + n = c_avl_node_next (iter->node); } if (n == NULL) @@ -691,7 +693,7 @@ int c_avl_iterator_prev (c_avl_iterator_t *iter, void **key, void **value) } else { - n = c_avl_node_prev (iter->tree, iter->node); + n = c_avl_node_prev (iter->node); } if (n == NULL)