long int children;
children = 0;
+ if (!node) {
+ printf("Attempted to validate a null pointer\n");
+ fflush(stdout);
+ trap();
+ }
+
for (i = 0; i < 4; i++) {
if (!node->child[i])
continue;
if (node->child[i]->parent != node) {
- printf("%s:%d Fatal! Tree inconsistency detected "
- "at child %d in node %p\n",
- __func__, __LINE__, i, node);
+ printf("%s:%d Fatal! Tree inconsistency detected at "
+ "child %d %p in node %p, incorrent parent %p\n",
+ __func__, __LINE__, i, node->child[i], node,
+ node->child[i]->parent);
+ fflush(stdout);
trap();
}
printf("%s:%d Fatal! Tree loop detected "
"at child %d in node %p\n",
__func__, __LINE__, i, node);
+ fflush(stdout);
trap();
}
}
printf("%s:%d Tree statistics inconsistency detected! "
"child count mismatch. Expected %ld, got %ld\n",
__func__, __LINE__, children, node->children);
+ fflush(stdout);
trap();
}
printf("%s:%d Tree statistics inconsistency detected! "
"child depth mismatch.",
__func__, __LINE__);
+ fflush(stdout);
trap();
}
}
parent->child[ret] = new;
new->parent = parent;
+ if (debug) {
+ printf("adding node %p to parent %p\n", new, parent);
+ fflush(stdout);
+ }
+
quadtree_recalculate_parent_stats(new, ops);
validate_tree(new);
struct quadtree *parent = 0;
int i;
+ if (debug) {
+ printf("Deleting node %p under parent %p\n",
+ node, node->parent);
+ fflush(stdout);
+ }
/*
* We are deleting the root node. This means we have to select
* a new root node and reconstruct the entire tree under it