sandbox: btree: fix replace_node_with_one_subtree() not updating tree root
This commit is contained in:
@@ -243,10 +243,6 @@ static void delete_fixup(btree_t *tree, btree_node_t *w)
|
|||||||
|
|
||||||
z = z->b_parent;
|
z = z->b_parent;
|
||||||
nr_rotations++;
|
nr_rotations++;
|
||||||
|
|
||||||
if (nr_rotations > 10) {
|
|
||||||
assert(0 && "too many rotations");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +334,9 @@ static btree_node_t *replace_node_with_one_subtree(btree_t *tree, btree_node_t *
|
|||||||
}
|
}
|
||||||
|
|
||||||
btree_node_t *w = z;
|
btree_node_t *w = z;
|
||||||
if (IS_LEFT_CHILD(p, node)) {
|
if (!p) {
|
||||||
|
tree->b_root = z;
|
||||||
|
} else if (IS_LEFT_CHILD(p, node)) {
|
||||||
p->b_left = z;
|
p->b_left = z;
|
||||||
} else if (IS_RIGHT_CHILD(p, node)) {
|
} else if (IS_RIGHT_CHILD(p, node)) {
|
||||||
p->b_right = z;
|
p->b_right = z;
|
||||||
|
|||||||
Reference in New Issue
Block a user