[telepathy-glib-0.20] telepathy-glib: TpHeap: comparator results are not guaranteed to be -1, 0 and 1
Simon McVittie
smcv at kemper.freedesktop.org
Wed Sep 4 06:11:34 PDT 2013
Module: telepathy-glib
Branch: telepathy-glib-0.20
Commit: 883d8878ea635baffd869ab548a1c736404dd682
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=883d8878ea635baffd869ab548a1c736404dd682
Author: Debarshi Ray <rishi at gnu.org>
Date: Wed Sep 4 13:49:24 2013 +0200
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 at collabora.co.uk>
---
telepathy-glib/heap.c | 8 ++++----
1 files 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);
More information about the telepathy-commits
mailing list