static void
third_pass(struct trie_node *node)
{
- if (!node)
- return;
-
+ assert(node != NULL);
assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT);
/* Root is assigned any of its potential buckets */
}
else
{
+ // Internal nodes should not have a bucket since it was deleted during first pass
+ if (!is_leaf(node))
+ assert(node->bucket == NULL);
+
const struct aggregator_bucket *inherited_bucket = get_ancestor_bucket(node);
/*
}
/* Preorder traversal */
- third_pass(node->child[0]);
- third_pass(node->child[1]);
+ if (node->child[0])
+ third_pass(node->child[0]);
+
+ if (node->child[1])
+ third_pass(node->child[1]);
/* Leaves with no assigned bucket are removed */
if (!node->bucket && is_leaf(node))