Browse Source

Fixes some compile errors and switched to gnu11 standard

Cameron Weinfurt 5 months ago
parent
commit
09bacea6df
2 changed files with 6 additions and 6 deletions
  1. 1
    1
      Makefile
  2. 5
    5
      tree_alloc.c

+ 1
- 1
Makefile View File

@@ -1,7 +1,7 @@
1 1
 objs = main.o tree_alloc.o util.o
2 2
 
3 3
 CC = clang
4
-COMMON_FLAGS = -std=c11
4
+COMMON_FLAGS = -std=gnu11
5 5
 OUT_NAME = the_alloc
6 6
 
7 7
 dev: CFLAGS= $(COMMON_FLAGS) -g -D UNIT_TESTS

+ 5
- 5
tree_alloc.c View File

@@ -188,7 +188,7 @@ void repair_after_remove(TreeAlloc **root_ptr, TreeAlloc *node) {
188 188
 		if (sibling->left->color == COLOR_BLACK && sibling->right->color == COLOR_BLACK) {
189 189
 			node->color = COLOR_BLACK;
190 190
 			sibling->color = COLOR_RED;
191
-			repair_after_remove(root_ptr, parent);
191
+			repair_after_remove(root_ptr, node->parent);
192 192
 		} else {
193 193
 			if (node->parent->left == node && sibling->right->color == COLOR_BLACK) {
194 194
 				rotate_right(root_ptr, sibling);
@@ -196,7 +196,7 @@ void repair_after_remove(TreeAlloc **root_ptr, TreeAlloc *node) {
196 196
 				sibling->color = COLOR_RED;
197 197
 				sibling->right->color = COLOR_RED;
198 198
 
199
-				rotate_left(root_ptr, parent);
199
+				rotate_left(root_ptr, node->parent);
200 200
 				node->color = get_sibling(node->parent)->color = COLOR_BLACK;
201 201
 			} else if (node->parent->right == node && sibling->left->color == COLOR_BLACK) {
202 202
 				rotate_left(root_ptr, sibling);
@@ -220,17 +220,17 @@ void remove_node(TreeAlloc **root_ptr, TreeAlloc *node) {
220 220
 	TreeAlloc *parent = node->parent;
221 221
 	if (!node->left) {
222 222
 		replace = node->right;
223
-		do_fix = node->color == COLOR_BLACK;
223
+		do_repair = node->color == COLOR_BLACK;
224 224
 		replace_node(root_ptr, node, replace);
225 225
 	} else if (!node->right) {
226 226
 		replace = node->left;
227
-		do_fix = node->color == COLOR_BLACK;
227
+		do_repair = node->color == COLOR_BLACK;
228 228
 		replace_node(root_ptr, node, replace);
229 229
 	} else {
230 230
 		TreeAlloc *tmp = node->right;
231 231
 		while (tmp->left) tmp = tmp->left;
232 232
 		replace = tmp->right;
233
-		do_fix = tmp == COLOR_BLACK;
233
+		do_repair = tmp->color == COLOR_BLACK;
234 234
 		if (tmp != node->right) {
235 235
 			replace_node(root_ptr, tmp, replace);
236 236
 			tmp->right = node->right;

Loading…
Cancel
Save