Since we don't support adding an entire subtree, it is better to zero
out the child pointers to ensure there are no leftover child nodes
that might corrupt the tree integrity.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
struct quadtree *quadtree_add(struct quadtree *parent, struct quadtree *new,
struct quadtree_ops *ops)
{
- int ret;
+ int ret, i;
if (parent == new)
trap();
parent->child[ret] = new;
new->parent = parent;
+ for (i = 0; i < 4; i++)
+ new->child[i] = 0;
if (debug) {
printf("adding node %p to parent %p\n", new, parent);