Browse Source

Added more debug prints

Thomas Johnson 5 months ago
parent
commit
37b5465a05
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      tree_alloc.c

+ 12
- 0
tree_alloc.c View File

@@ -171,6 +171,12 @@ void rotate_right(TreeAlloc **root_ptr, TreeAlloc *ta) {
171 171
 
172 172
 void repair_tree_after_insert(TreeAlloc **root_ptr, TreeAlloc *ta) {
173 173
 	TreeAlloc *parent = ta->parent;
174
+#ifdef DEBUG
175
+      printf("=== PRE-INSERT-FIXUP ===\n");
176
+      printf("===== CURRENT TREE =====\n");
177
+      debug_print_tree(0, *root_ptr);
178
+      printf("===== END OF TREES =====\n");
179
+#endif
174 180
 
175 181
 	if (parent == NULL) {
176 182
 		ta->color = COLOR_BLACK;
@@ -206,6 +212,12 @@ void repair_tree_after_insert(TreeAlloc **root_ptr, TreeAlloc *ta) {
206 212
 			grandparent->color = COLOR_RED;
207 213
 		}
208 214
 	}
215
+#ifdef DEBUG
216
+      printf("== POST-INSERT-FIXUP ===\n");
217
+      printf("===== CURRENT TREE =====\n");
218
+      debug_print_tree(0, *root_ptr);
219
+      printf("===== END OF TREES =====\n");
220
+#endif
209 221
 }
210 222
 
211 223
 void replace_node(TreeAlloc **root_ptr, TreeAlloc *node, TreeAlloc *replace) {

Loading…
Cancel
Save