}
static int add_to_relocation_list(struct quadtree *node,
- struct list_head *head)
+ struct list_head **head)
{
int nodes = 0;
nodes += add_to_relocation_list(node->child[1], head);
if (debug) {
- printf("Adding node %p to relocation list\n", node);
+ printf("Adding node %p to relocation list %p\n",
+ node, *head);
fflush(stdout);
}
- list_add(&node->list, head);
+ if (!*head) {
+ *head = &node->list;
+ INIT_LIST_HEAD(*head);
+ }
+
+ list_add(&node->list, *head);
nodes++;
if (node->child[2])
struct quadtree *tmp = start, *node;
int i, d = nodes / 2;
- for (i = 0; i < nodes; i++) {
- printf("Node %p, prev %p, next %p\n",
- list_to_tree(&tmp->list),
- list_to_tree(tmp->list.prev),
- list_to_tree(tmp->list.next));
- fflush(stdout);
- tmp = list_to_tree(tmp->list.next);
- };
-
for (; nodes > 0; nodes--) {
if (debug) {
printf("stepping %d, %d nodes left\n", d, nodes);
fflush(stdout);
}
-/*
for (i = 0; i < d; i++)
tmp = list_to_tree(tmp->list.next);
-*/
if (debug) {
- printf("Now moving node %p\n", tmp);
+ printf("Now moving node %p, next %p , prev %p\n",
+ tmp,
+ list_to_tree(tmp->list.prev),
+ list_to_tree(tmp->list.next));
fflush(stdout);
}
node = tmp;
parent->parent = 0;
continue;
}
- if (!head) {
- head = &node->child[i]->list;
- INIT_LIST_HEAD(head);
- }
- nodes += add_to_relocation_list(node->child[i], head);
+ nodes += add_to_relocation_list(node->child[i], &head);
}
start = list_to_tree(head);
if (!node->child[i])
continue;
- if (!head) {
- head = &node->child[i]->list;
- INIT_LIST_HEAD(head);
- }
-
- nodes += add_to_relocation_list(node->child[i], head);
+ nodes += add_to_relocation_list(node->child[i], &head);
}
start = list_to_tree(head);