diff options
Diffstat (limited to 'src/trie.cpp')
-rw-r--r-- | src/trie.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/trie.cpp b/src/trie.cpp index 2a21a5f..baa5c8d 100644 --- a/src/trie.cpp +++ b/src/trie.cpp @@ -43,8 +43,11 @@ xs::trie_t::trie_t () : xs::trie_t::~trie_t () { - if (count == 1) + if (count == 1) { + xs_assert (next.node); delete next.node; + next.node = 0; + } else if (count > 1) { for (unsigned short i = 0; i != count; ++i) if (next.table [i]) @@ -154,8 +157,10 @@ bool xs::trie_t::rm (unsigned char *prefix_, size_t size_) if (next_node->is_redundant ()) { delete next_node; - if (count == 1) + if (count == 1) { next.node = 0; + count = 0; + } else next.table [c - min] = 0; --live_nodes; @@ -242,7 +247,7 @@ void xs::trie_t::apply_helper ( } } -bool xs::trie_t::is_redundant() const +bool xs::trie_t::is_redundant () const { return refcnt == 0 && live_nodes == 0; } |