}
/*
- * We are not deleting the parent. Just relocate the children
- * and detach the node from the tree.
+ * We are not deleting the parent. Detach the node from the
+ * parent abd relocate the children. The node will be then
+ * detached from the tree.
*/
+
+ for (i = 0; i < 4; i++) {
+ if (node->parent->child[i] == node) {
+ node->parent->child[i] = 0;
+ break;
+ }
+ }
+ if (i == 4) {
+ printf("%s:%d Fatal! Tree inconsistency detected\n",
+ __FUNCTION__, __LINE__);
+ trap();
+ }
+
+ /*
+ * The sub branch is now detached from the main tree. Continue
+ * relocating the detached branch.
+ */
+
for (i = 0; i < 4; i++) {
if (!node->child[i])
continue;
_quadtree_reposition_reqursively(node->parent, node->child[i],
compare);
+ node->child[i] = 0;
}
parent = quadtree_find_parent(node);
return count;
}
-
int walk_tree(const struct quadtree_iterator *it)
{
return _walk_tree(it->head, it);