X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_avltree.c;h=da793b32d0fdf51d7e3bf98f041c9a99c3d6669f;hb=d6491cfcf52a74498e1becd7ef94fc8e0a5938b9;hp=04e540327fcbae05542cb5da6661b8ca88f904f0;hpb=b49d4e33978d4c9508b68e931a7a27773f0348e1;p=collectd.git diff --git a/src/daemon/utils_avltree.c b/src/daemon/utils_avltree.c index 04e54032..da793b32 100644 --- a/src/daemon/utils_avltree.c +++ b/src/daemon/utils_avltree.c @@ -617,10 +617,18 @@ int c_avl_pick (c_avl_tree_t *t, void **key, void **value) n = t->root; while ((n->left != NULL) || (n->right != NULL)) { - int height_left = (n->left == NULL) ? 0 : n->left->height; - int height_right = (n->right == NULL) ? 0 : n->right->height; + if (n->left == NULL) + { + n = n->right; + continue; + } + else if (n->right == NULL) + { + n = n->left; + continue; + } - if (height_left > height_right) + if (n->left->height > n->right->height) n = n->left; else n = n->right;