* at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include "config.h"
+
#include <string.h>
+#include "galias.h"
#include "glib.h"
+
/* Byte-wise swap two items of size SIZE. */
#define SWAP(a, b, size) \
do \
void
g_qsort_with_data (gconstpointer pbase,
gint total_elems,
- size_t size,
+ gsize size,
GCompareDataFunc compare_func,
gpointer user_data)
{
/* Allocating SIZE bytes for a pivot buffer facilitates a better
* algorithm below since we can do comparisons directly on the pivot.
*/
- char *pivot_buffer = (char *) alloca (size);
+ char *pivot_buffer = (char *) g_alloca (size);
const size_t max_thresh = MAX_THRESH * size;
- g_return_if_fail (total_elems > 0);
- g_return_if_fail (pbase != NULL);
+ g_return_if_fail (total_elems >= 0);
+ g_return_if_fail (pbase != NULL || total_elems == 0);
g_return_if_fail (compare_func != NULL);
+ if (total_elems == 0)
+ return;
+
if (total_elems > MAX_THRESH)
{
char *lo = base_ptr;