mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-10 05:08:42 +00:00
Extend remove_node() with deleting root node
This commit is contained in:
parent
26ac6dca5c
commit
7657d05592
@ -95,9 +95,11 @@ static void
|
||||
remove_node(struct trie_node *node)
|
||||
{
|
||||
assert(node != NULL);
|
||||
assert(node->parent != NULL);
|
||||
assert(node->child[0] == NULL && node->child[1] == NULL);
|
||||
|
||||
if (node->parent == NULL)
|
||||
goto free_node;
|
||||
|
||||
if (node->parent->child[0] == node)
|
||||
node->parent->child[0] = NULL;
|
||||
else if (node->parent->child[1] == node)
|
||||
@ -105,6 +107,7 @@ remove_node(struct trie_node *node)
|
||||
else
|
||||
bug("Invalid child pointer");
|
||||
|
||||
free_node:
|
||||
sl_free(node);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user