# HG changeset patch # User Will Thompson # Date 1198623627 0 # Node ID 63ebd65857f8f7dd0490a4e4f3bd88cfb60dc74d # Parent 8daec0ca3218695a251ed5f14b0659f30b300841# Parent 5bf38e411fda37a9e8782a9af96311e661fcc923 merge of 'c000ab1012a7be103452c357fb103e5bddeb99d7' and 'd56abb1283e79d4ca866e8cf22e0d30e13145e7a' diff -r 8daec0ca3218 -r 63ebd65857f8 libpurple/protocols/qq/group_opt.c --- a/libpurple/protocols/qq/group_opt.c Tue Dec 25 06:38:17 2007 +0000 +++ b/libpurple/protocols/qq/group_opt.c Tue Dec 25 23:00:27 2007 +0000 @@ -39,37 +39,12 @@ #include "packet_parse.h" #include "utils.h" -/* TODO: can't we use qsort here? */ -/* This implement quick sort algorithm (low->high) */ -static void _quick_sort(gint *numbers, gint left, gint right) +static int _compare_guint32(const void *a, + const void *b) { - gint pivot, l_hold, r_hold; - - l_hold = left; - r_hold = right; - pivot = numbers[left]; - while (left < right) { - while ((numbers[right] >= pivot) && (left < right)) - right--; - if (left != right) { - numbers[left] = numbers[right]; - left++; - } - while ((numbers[left] <= pivot) && (left < right)) - left++; - if (left != right) { - numbers[right] = numbers[left]; - right--; - } - } - numbers[left] = pivot; - pivot = left; - left = l_hold; - right = r_hold; - if (left < pivot) - _quick_sort(numbers, left, pivot - 1); - if (right > pivot) - _quick_sort(numbers, pivot + 1, right); + const guint32 *x = a; + const guint32 *y = b; + return (*x - *y); } static void _sort(guint32 *list) @@ -77,7 +52,7 @@ gint i; for (i = 0; list[i] < 0xffffffff; i++) {; } - _quick_sort((gint *) list, 0, i - 1); + qsort (list, i, sizeof (guint32), _compare_guint32); } static void _qq_group_member_opt(PurpleConnection *gc, qq_group *group, gint operation, guint32 *members)