diff --git a/src/tree.c b/src/tree.c index 7ea77aa..ee7073d 100644 --- a/src/tree.c +++ b/src/tree.c @@ -1339,7 +1339,7 @@ bool tree_rb_delete_fix(struct _tree* self, struct _tree_node* node) } else { - if(father->color = RBT_BLACK) + if(father->color == RBT_BLACK) { // case 4 // father is black, brother has no children @@ -1388,7 +1388,7 @@ bool tree_rb_delete_fix(struct _tree* self, struct _tree_node* node) } else { - if(father->color = RBT_BLACK) + if(father->color == RBT_BLACK) { // case4 brother->color = RBT_RED; @@ -1406,7 +1406,7 @@ bool tree_rb_delete_fix(struct _tree* self, struct _tree_node* node) if(tmp != NULL && tmp->parent == NULL) { - self->_root = node; + self->_root = tmp; } } diff --git a/test/test_tree.c b/test/test_tree.c index b165529..42f676d 100644 --- a/test/test_tree.c +++ b/test/test_tree.c @@ -155,6 +155,10 @@ static bool tree_rb_check_color(struct _tree *self, struct _tree_node* root, int static bool tree_rb_check(struct _tree* self) { assert(self != NULL); + if(self->_root == NULL) + { + return true; + } if(self->_root->color != RBT_BLACK) {