aboutsummaryrefslogtreecommitdiff
path: root/src/util/container_heap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/container_heap.c')
-rw-r--r--src/util/container_heap.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/container_heap.c b/src/util/container_heap.c
index 1e7077c80..b5ccd7950 100644
--- a/src/util/container_heap.c
+++ b/src/util/container_heap.c
@@ -331,6 +331,8 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *root,
331 331
332 if (del_node == NULL) 332 if (del_node == NULL)
333 return NULL; 333 return NULL;
334 else if (del_node == root->root)
335 return GNUNET_CONTAINER_heap_remove_root (root);
334 336
335 ret = del_node->element; 337 ret = del_node->element;
336 last = getPos (root, root->size); 338 last = getPos (root, root->size);
@@ -410,6 +412,15 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *root)
410 ret = root_node->element; 412 ret = root_node->element;
411 last = getPos (root, root->size); 413 last = getPos (root, root->size);
412 414
415 if ((root_node == last) && (root->size == 1))
416 {
417 /* We are removing the last node in the heap! */
418 root->root = NULL;
419 root->traversal_pos = NULL;
420 root->size = 0;
421 return ret;
422 }
423
413 if (last->parent->left_child == last) 424 if (last->parent->left_child == last)
414 last->parent->left_child = NULL; 425 last->parent->left_child = NULL;
415 else if (last->parent->right_child == last) 426 else if (last->parent->right_child == last)