sandbox: btree: fix replace_node_with_one_subtree() not updating tree root

This commit is contained in:
2023-01-24 21:35:32 +00:00
parent dbf3ad101d
commit 2b099142e3

View File

@@ -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;