Archived
1
0
Fork 0

rbtree.c: fixed bug with tree not being empty when removing root node.

This commit is contained in:
Henrik Hautakoski 2010-12-28 18:29:06 +01:00
parent 3671888b8b
commit 246ea7854e

View file

@ -262,11 +262,7 @@ int rbtree_delete(rbtree *tree, const void *key) {
}
}
}
tree->root = head.child[1];
if (tree->root)
tree->root->color = RB_BLACK;
/* remove if found */
if (f) {
if (tree->delete_fn)
@ -276,7 +272,11 @@ int rbtree_delete(rbtree *tree, const void *key) {
f->key = q->key;
swap(p, 1, q) = swap(q, 0, NULL);
xfree(q);
return 1;
}
return 0;
tree->root = head.child[1];
if (tree->root)
tree->root->color = RB_BLACK;
return f != NULL;
}