diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-16 11:24:30 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-16 11:24:30 +0100 |
commit | d473582634ea55c2a412da1360b05a2898ed568d (patch) | |
tree | 39ca0098ac657e5dbc0960469ae05195e2506f60 /src/util/container_heap.c | |
parent | 301693904d07a063711bfc1ff4c5505c61eaf821 (diff) | |
download | gnunet-d473582634ea55c2a412da1360b05a2898ed568d.tar.gz gnunet-d473582634ea55c2a412da1360b05a2898ed568d.zip |
simplify GNUNET_CONTAINER_heap_update_cost API
Diffstat (limited to 'src/util/container_heap.c')
-rw-r--r-- | src/util/container_heap.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/util/container_heap.c b/src/util/container_heap.c index 4f82fb076..1ead5ec6d 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c | |||
@@ -541,36 +541,23 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node) | |||
541 | /** | 541 | /** |
542 | * Updates the cost of any node in the tree | 542 | * Updates the cost of any node in the tree |
543 | * | 543 | * |
544 | * @param heap heap to modify | ||
545 | * @param node node for which the cost is to be changed | 544 | * @param node node for which the cost is to be changed |
546 | * @param new_cost new cost for the node | 545 | * @param new_cost new cost for the node |
547 | */ | 546 | */ |
548 | void | 547 | void |
549 | GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, | 548 | GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_HeapNode *node, |
550 | struct GNUNET_CONTAINER_HeapNode *node, | ||
551 | GNUNET_CONTAINER_HeapCostType new_cost) | 549 | GNUNET_CONTAINER_HeapCostType new_cost) |
552 | { | 550 | { |
553 | #if EXTRA_CHECKS | 551 | struct GNUNET_CONTAINER_Heap *heap = node->heap; |
554 | GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || | 552 | |
555 | (heap->size == heap->root->tree_size + 1)); | ||
556 | CHECK (heap->root); | ||
557 | #endif | ||
558 | remove_node (node); | 553 | remove_node (node); |
559 | #if EXTRA_CHECKS | ||
560 | CHECK (heap->root); | ||
561 | GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) || | ||
562 | (heap->size == heap->root->tree_size + 2)); | ||
563 | #endif | ||
564 | node->cost = new_cost; | 554 | node->cost = new_cost; |
565 | if (heap->root == NULL) | 555 | if (NULL == heap->root) |
566 | heap->root = node; | 556 | heap->root = node; |
567 | else | 557 | else |
568 | insert_node (heap, heap->root, node); | 558 | insert_node (heap, |
569 | #if EXTRA_CHECKS | 559 | heap->root, |
570 | CHECK (heap->root); | 560 | node); |
571 | GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || | ||
572 | (heap->size == heap->root->tree_size + 1)); | ||
573 | #endif | ||
574 | } | 561 | } |
575 | 562 | ||
576 | 563 | ||