if (del_node == NULL)
return NULL;
+ else if (del_node == root->root)
+ return GNUNET_CONTAINER_heap_remove_root (root);
ret = del_node->element;
last = getPos (root, root->size);
ret = root_node->element;
last = getPos (root, root->size);
+ if ((root_node == last) && (root->size == 1))
+ {
+ /* We are removing the last node in the heap! */
+ root->root = NULL;
+ root->traversal_pos = NULL;
+ root->size = 0;
+ return ret;
+ }
+
if (last->parent->left_child == last)
last->parent->left_child = NULL;
else if (last->parent->right_child == last)