aboutsummaryrefslogtreecommitdiff
path: root/src/util/container_heap.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-08 18:54:19 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-08 18:54:19 +0000
commita6e9fbbab174e1c8142827fa5624aa0e59156298 (patch)
tree4a6690aaea9f90a766222764e35302fcee842774 /src/util/container_heap.c
parenta8e3c5873feed7a356f503af48669cb043d80e19 (diff)
downloadgnunet-a6e9fbbab174e1c8142827fa5624aa0e59156298.tar.gz
gnunet-a6e9fbbab174e1c8142827fa5624aa0e59156298.zip
forward-porting heap bugfixes
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)