From: Arnaud Legrand Date: Wed, 21 Aug 2013 18:42:09 +0000 (+0200) Subject: Avoid stupid segfault on DEBUG when heap is empty. X-Git-Tag: v3_9_90~123^2~43 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0c63bb7b7e2986962a19ce3f95b4a374da055c71?ds=sidebyside Avoid stupid segfault on DEBUG when heap is empty. --- diff --git a/src/xbt/heap.c b/src/xbt/heap.c index c795b76f8f..e035a3ab10 100644 --- a/src/xbt/heap.c +++ b/src/xbt/heap.c @@ -123,11 +123,11 @@ void *xbt_heap_pop(xbt_heap_t H) int size = H->size; void *max; - XBT_DEBUG("Heap has %d elements before extraction and max elem was %g",xbt_heap_size(H),xbt_heap_maxkey(H)); - if (H->count == 0) return NULL; + XBT_DEBUG("Heap has %d elements before extraction and max elem was %g",xbt_heap_size(H),xbt_heap_maxkey(H)); + max = CONTENT(H, 0); items[0] = items[(H->count) - 1];