summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebarshi Ray <rishi@gnu.org>2013-09-04 13:49:24 +0200
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-04 14:01:22 +0100
commit883d8878ea635baffd869ab548a1c736404dd682 (patch)
tree2d25263b2c6eb17ef98309205166f3d8cc599f9b
parent2ebe4dff95aea5d9c6485f6fa3c64b86b2930a36 (diff)
downloadtelepathy-glib-883d8878ea635baffd869ab548a1c736404dd682.tar.gz
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 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--telepathy-glib/heap.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/telepathy-glib/heap.c b/telepathy-glib/heap.c
index 92d7b7bdc..318f16107 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);