X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fcontainer_heap.c;h=78881d8081d898aa8b67c357cc17081b7dfa0cd6;hb=0ea8e006d5f5ef84e31e000607bd24a23f8fc1ed;hp=dbb391ac4e5e949feaf802af40993be7c9195f47;hpb=0acc583b6e411a5f1ebd6172458baaad992c456e;p=oweals%2Fgnunet.git diff --git a/src/util/container_heap.c b/src/util/container_heap.c index dbb391ac4..78881d808 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c @@ -267,6 +267,7 @@ GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap) * Insert the given node 'node' into the subtree starting * at 'pos' (while keeping the tree somewhat balanced). * + * @param heap heap to modify * @param pos existing tree * @param node node to insert (which may be a subtree itself) */ @@ -278,7 +279,9 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap, struct GNUNET_CONTAINER_HeapNode *parent; GNUNET_assert (node->parent == NULL); - while ( (pos->cost < node->cost) ^ (heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) ) + while ( (heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) + ? (pos->cost >= node->cost) + : (pos->cost <= node->cost) ) { /* node is descendent of pos */ pos->tree_size += (1 + node->tree_size);