From 2fc3c7810f0282f855137d39ebbb0ce8db2ef46f Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 4 Sep 2013 13:49:24 +0200 Subject: [PATCH] TpHeap: comparator results are not guaranteed to be -1, 0 and 1 A GCompareFunc might return any negative or positive value if the two values are not equal. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68932 --- telepathy-glib/heap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telepathy-glib/heap.c b/telepathy-glib/heap.c index 92d7b7b..318f161 100644 --- a/telepathy-glib/heap.c +++ b/telepathy-glib/heap.c @@ -143,7 +143,7 @@ tp_heap_add (TpHeap *heap, gpointer element) { gpointer parent = HEAP_INDEX (heap, m / 2); - if (heap->comparator (element, parent) == -1) + if (heap->comparator (element, parent) < 0) { HEAP_INDEX (heap, m / 2) = element; HEAP_INDEX (heap, m) = parent; @@ -204,13 +204,13 @@ extract_element (TpHeap * heap, int index) if ((i * 2 + 1 <= m) && (heap-> comparator (HEAP_INDEX (heap, i * 2), - HEAP_INDEX (heap, i * 2 + 1)) == 1)) + HEAP_INDEX (heap, i * 2 + 1)) > 0)) j = i * 2 + 1; else j = i * 2; - if (heap->comparator (HEAP_INDEX (heap, i), HEAP_INDEX (heap, j)) == - 1) + if (heap->comparator (HEAP_INDEX (heap, i), HEAP_INDEX (heap, j)) > + 0) { gpointer tmp = HEAP_INDEX (heap, i); HEAP_INDEX (heap, i) = HEAP_INDEX (heap, j); -- 1.8.3.1