hwdb: make trie_node_cleanup() can take NULL

This commit is contained in:
Yu Watanabe 2018-09-18 12:49:51 +09:00
parent 124b3686f9
commit bf84dc168c
1 changed files with 4 additions and 3 deletions

View File

@ -113,6 +113,9 @@ static struct trie_node *node_lookup(const struct trie_node *node, uint8_t c) {
static void trie_node_cleanup(struct trie_node *node) {
size_t i;
if (!node)
return;
for (i = 0; i < node->children_count; i++)
trie_node_cleanup(node->children[i].child);
free(node->children);
@ -124,9 +127,7 @@ static void trie_free(struct trie *trie) {
if (!trie)
return;
if (trie->root)
trie_node_cleanup(trie->root);
trie_node_cleanup(trie->root);
strbuf_cleanup(trie->strings);
free(trie);
}