heap: fix node removal

This commit is contained in:
Keno Fischer 2014-02-23 02:18:33 -05:00 committed by Fedor Indutny
parent 0943d3cb33
commit d4f904b0e7

View File

@ -219,9 +219,9 @@ HEAP_EXPORT(void heap_remove(struct heap* heap,
*/
for (;;) {
smallest = child;
if (child->left != NULL && less_than(smallest, child))
if (child->left != NULL && less_than(child->left, smallest))
smallest = child->left;
if (child->right != NULL && less_than(smallest, child))
if (child->right != NULL && less_than(child->right, smallest))
smallest = child->right;
if (smallest == child)
break;