projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix building with xfsprogs 4.5.0
[collectd.git]
/
src
/
utils_avltree.c
diff --git
a/src/utils_avltree.c
b/src/utils_avltree.c
index
6a25fb5
..
a9b3862
100644
(file)
--- a/
src/utils_avltree.c
+++ b/
src/utils_avltree.c
@@
-142,6
+142,9
@@
static c_avl_node_t *rotate_right (c_avl_tree_t *t, c_avl_node_t *x)
c_avl_node_t *y;
c_avl_node_t *b;
c_avl_node_t *y;
c_avl_node_t *b;
+ assert (x != NULL);
+ assert (x->left != NULL);
+
p = x->parent;
y = x->left;
b = y->right;
p = x->parent;
y = x->left;
b = y->right;
@@
-166,7
+169,7
@@
static c_avl_node_t *rotate_right (c_avl_tree_t *t, c_avl_node_t *x)
y->height = calc_height (y);
return (y);
y->height = calc_height (y);
return (y);
-} /* void rotate_
lef
t */
+} /* void rotate_
righ
t */
/*
* (x) (y)
/*
* (x) (y)
@@
-183,6
+186,9
@@
static c_avl_node_t *rotate_left (c_avl_tree_t *t, c_avl_node_t *x)
c_avl_node_t *y;
c_avl_node_t *b;
c_avl_node_t *y;
c_avl_node_t *b;
+ assert (x != NULL);
+ assert (x->right != NULL);
+
p = x->parent;
y = x->right;
b = y->left;
p = x->parent;
y = x->right;
b = y->left;
@@
-235,7
+241,7
@@
static void rebalance (c_avl_tree_t *t, c_avl_node_t *n)
{
assert (n->right != NULL);
b_bottom = BALANCE (n->right);
{
assert (n->right != NULL);
b_bottom = BALANCE (n->right);
- assert ((b_bottom >= -1)
||
(b_bottom <= 1));
+ assert ((b_bottom >= -1)
&&
(b_bottom <= 1));
if (b_bottom == 1)
n = rotate_right_left (t, n);
else
if (b_bottom == 1)
n = rotate_right_left (t, n);
else
@@
-245,7
+251,7
@@
static void rebalance (c_avl_tree_t *t, c_avl_node_t *n)
{
assert (n->left != NULL);
b_bottom = BALANCE (n->left);
{
assert (n->left != NULL);
b_bottom = BALANCE (n->left);
- assert ((b_bottom >= -1)
||
(b_bottom <= 1));
+ assert ((b_bottom >= -1)
&&
(b_bottom <= 1));
if (b_bottom == -1)
n = rotate_left_right (t, n);
else
if (b_bottom == -1)
n = rotate_left_right (t, n);
else
@@
-642,6
+648,7
@@
int c_avl_pick (c_avl_tree_t *t, void **key, void **value)
*value = n->value;
free_node (n);
*value = n->value;
free_node (n);
+ --t->size;
rebalance (t, p);
return (0);
rebalance (t, p);
return (0);