Browse Source

Asserting that inserted nodes are red

tree_alloc
Cameron Weinfurt 1 year ago
parent
commit
1c51fba904
  1. 4
      tree_alloc.c

4
tree_alloc.c

@ -331,7 +331,7 @@ void insert_singleton(TreeAlloc **root_ptr, TreeAlloc *to_insert) {
#endif
*root_ptr = to_insert;
to_insert->parent = NULL;
repair_tree_after_insert(root_ptr, to_insert);
to_insert->color = COLOR_BLACK;
}
void insert_right(TreeAlloc** root_ptr, TreeAlloc* to_insert, TreeAlloc* after) {
@ -347,6 +347,7 @@ void insert_right(TreeAlloc** root_ptr, TreeAlloc* to_insert, TreeAlloc* after)
}
after->right = to_insert;
to_insert->parent = after;
to_insert->color = COLOR_RED;
repair_tree_after_insert(root_ptr, to_insert);
}
@ -363,6 +364,7 @@ void insert_left(TreeAlloc** root_ptr, TreeAlloc* to_insert, TreeAlloc* before)
}
before->left = to_insert;
to_insert->parent = before;
to_insert->color = COLOR_RED;
repair_tree_after_insert(root_ptr, to_insert);
}

Loading…
Cancel
Save