Browse Source

Asserting that inserted nodes are red

Cameron Weinfurt 5 months ago
parent
commit
1c51fba904
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      tree_alloc.c

+ 3
- 1
tree_alloc.c View File

@@ -331,7 +331,7 @@ void insert_singleton(TreeAlloc **root_ptr, TreeAlloc *to_insert) {
331 331
 #endif
332 332
   *root_ptr = to_insert;
333 333
   to_insert->parent = NULL;
334
-  repair_tree_after_insert(root_ptr, to_insert);
334
+  to_insert->color = COLOR_BLACK;
335 335
 }
336 336
 
337 337
 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)
347 347
   }
348 348
   after->right = to_insert;
349 349
   to_insert->parent = after;
350
+  to_insert->color = COLOR_RED;
350 351
   repair_tree_after_insert(root_ptr, to_insert);
351 352
 }
352 353
 
@@ -363,6 +364,7 @@ void insert_left(TreeAlloc** root_ptr, TreeAlloc* to_insert, TreeAlloc* before)
363 364
   }
364 365
   before->left = to_insert;
365 366
   to_insert->parent = before;
367
+  to_insert->color = COLOR_RED;
366 368
 	repair_tree_after_insert(root_ptr, to_insert);
367 369
 }
368 370
 

Loading…
Cancel
Save