- Call g_queue_insert_sorted() instead of duplicating the code. - Call

* glib/gasyncqueue.c:
- Call g_queue_insert_sorted() instead of duplicating the code.
- Call g_queue_sort() instead of duplicating the code.
- Invert sort function results to make sure the same sort function
gives the same results across glist, gslist, gqueue and
gasyncqueue.

* tests/asyncqueue-test.c:
- Updated the sort function to reflect the example in the
documentation for gasyncqueue.c.
This commit is contained in:
Martyn James Russell
2005-12-07 12:09:44 +00:00
parent 9763367246
commit c6ad7b7ac8
5 changed files with 72 additions and 23 deletions

View File

@@ -37,16 +37,16 @@ static GAsyncQueue *async_queue = NULL;
static gint
sort_compare (gconstpointer p1, gconstpointer p2, gpointer user_data)
{
gint id1;
gint id2;
gint32 id1;
gint32 id2;
id1 = GPOINTER_TO_INT (p1);
id2 = GPOINTER_TO_INT (p2);
d(g_print ("comparing #1:%d and #2:%d, returning %d\n",
id1, id2, (id2 - id1)));
id1, id2, (id1 > id2 ? +1 : id1 == id2 ? 0 : -1)));
return (id2 - id1);
return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
}
static gboolean