X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Futils_avltree.c;h=da793b32d0fdf51d7e3bf98f041c9a99c3d6669f;hb=f5adf265a374e5e0dba89a4a9903e7719dc57039;hp=04e540327fcbae05542cb5da6661b8ca88f904f0;hpb=2a8ee0dbb694eac183fff0306ea9c41c46facad7;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;