rbtree.c: fixed bug with tree not being empty when removing root node.
This commit is contained in:
parent
3671888b8b
commit
246ea7854e
1 changed files with 7 additions and 7 deletions
12
src/rbtree.c
12
src/rbtree.c
|
|
@ -263,10 +263,6 @@ int rbtree_delete(rbtree *tree, const void *key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tree->root = head.child[1];
|
|
||||||
if (tree->root)
|
|
||||||
tree->root->color = RB_BLACK;
|
|
||||||
|
|
||||||
/* remove if found */
|
/* remove if found */
|
||||||
if (f) {
|
if (f) {
|
||||||
if (tree->delete_fn)
|
if (tree->delete_fn)
|
||||||
|
|
@ -276,7 +272,11 @@ int rbtree_delete(rbtree *tree, const void *key) {
|
||||||
f->key = q->key;
|
f->key = q->key;
|
||||||
swap(p, 1, q) = swap(q, 0, NULL);
|
swap(p, 1, q) = swap(q, 0, NULL);
|
||||||
xfree(q);
|
xfree(q);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
tree->root = head.child[1];
|
||||||
|
if (tree->root)
|
||||||
|
tree->root->color = RB_BLACK;
|
||||||
|
|
||||||
|
return f != NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue