void hattrie_clear(hattrie_t* T) { hattrie_free_node(T->root); node_ptr node; node.b = ahtable_create(); node.b->flag = NODE_TYPE_HYBRID_BUCKET; node.b->c0 = 0x00; node.b->c1 = 0xff; T->root.t = alloc_trie_node(T, node); }
static void hattrie_free_node(node_ptr node) { if (*node.flag & NODE_TYPE_TRIE) { size_t i; for (i = 0; i < NODE_CHILDS; ++i) { if (i > 0 && node.t->xs[i].t == node.t->xs[i - 1].t) continue; /* XXX: recursion might not be the best choice here. It is possible * to build a very deep trie. */ if (node.t->xs[i].t) hattrie_free_node(node.t->xs[i]); } free(node.t); } else { ahtable_free(node.b); } }
void hattrie_free(hattrie_t* T) { hattrie_free_node(T->root); free(T); }
/* Deinitialize hat-trie. */ static void hattrie_deinit(hattrie_t * T) { if (T->bsize > 0 || T->mm.free) hattrie_free_node(T->root, T->mm.free); }