Browse Source

Merge branch 'tree_alloc' of gitea:cameron/cs241-project into tree_alloc

Thomas Johnson 5 months ago
parent
commit
2c0d27f7d7
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      tree_alloc.c

+ 3
- 1
tree_alloc.c View File

@@ -341,7 +341,7 @@ void insert_singleton(TreeAlloc **root_ptr, TreeAlloc *to_insert) {
341 341
 #endif
342 342
   *root_ptr = to_insert;
343 343
   to_insert->parent = NULL;
344
-  repair_tree_after_insert(root_ptr, to_insert);
344
+  to_insert->color = COLOR_BLACK;
345 345
 }
346 346
 
347 347
 void insert_right(TreeAlloc** root_ptr, TreeAlloc* to_insert, TreeAlloc* after) {
@@ -357,6 +357,7 @@ void insert_right(TreeAlloc** root_ptr, TreeAlloc* to_insert, TreeAlloc* after)
357 357
   }
358 358
   after->right = to_insert;
359 359
   to_insert->parent = after;
360
+  to_insert->color = COLOR_RED;
360 361
   repair_tree_after_insert(root_ptr, to_insert);
361 362
 }
362 363
 
@@ -373,6 +374,7 @@ void insert_left(TreeAlloc** root_ptr, TreeAlloc* to_insert, TreeAlloc* before)
373 374
   }
374 375
   before->left = to_insert;
375 376
   to_insert->parent = before;
377
+  to_insert->color = COLOR_RED;
376 378
 	repair_tree_after_insert(root_ptr, to_insert);
377 379
 }
378 380
 

Loading…
Cancel
Save