Fixes for #79347, Ron Arts.

Tue May  7 11:24:22 2002  Owen Taylor  <otaylor@redhat.com>

        Fixes for #79347, Ron Arts.

        * glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
        don't g_return_if_fail().

        * tests/qsort-test.c (main): Add a 0 element test.

        * glib/garray.c (g_[ptr_]array_sort_with[_data]):
        Remove invalid assertions that array->pdata != NULL ..
        it's NULL for 0 elements which is a valid case.
This commit is contained in:
Owen Taylor 2002-05-07 15:32:08 +00:00 committed by Owen Taylor
parent 0522bb588b
commit 053a1ce434
10 changed files with 99 additions and 6 deletions

View File

@ -1,3 +1,16 @@
Tue May 7 11:24:22 2002 Owen Taylor <otaylor@redhat.com>
Fixes for #79347, Ron Arts.
* glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
don't g_return_if_fail().
* tests/qsort-test.c (main): Add a 0 element test.
* glib/garray.c (g_[ptr_]array_sort_with[_data]):
Remove invalid assertions that array->pdata != NULL ..
it's NULL for 0 elements which is a valid case.
Mon May 6 16:00:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/gbacktrace.h: Exclude OSF from alpha definition

View File

@ -1,3 +1,16 @@
Tue May 7 11:24:22 2002 Owen Taylor <otaylor@redhat.com>
Fixes for #79347, Ron Arts.
* glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
don't g_return_if_fail().
* tests/qsort-test.c (main): Add a 0 element test.
* glib/garray.c (g_[ptr_]array_sort_with[_data]):
Remove invalid assertions that array->pdata != NULL ..
it's NULL for 0 elements which is a valid case.
Mon May 6 16:00:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/gbacktrace.h: Exclude OSF from alpha definition

View File

@ -1,3 +1,16 @@
Tue May 7 11:24:22 2002 Owen Taylor <otaylor@redhat.com>
Fixes for #79347, Ron Arts.
* glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
don't g_return_if_fail().
* tests/qsort-test.c (main): Add a 0 element test.
* glib/garray.c (g_[ptr_]array_sort_with[_data]):
Remove invalid assertions that array->pdata != NULL ..
it's NULL for 0 elements which is a valid case.
Mon May 6 16:00:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/gbacktrace.h: Exclude OSF from alpha definition

View File

@ -1,3 +1,16 @@
Tue May 7 11:24:22 2002 Owen Taylor <otaylor@redhat.com>
Fixes for #79347, Ron Arts.
* glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
don't g_return_if_fail().
* tests/qsort-test.c (main): Add a 0 element test.
* glib/garray.c (g_[ptr_]array_sort_with[_data]):
Remove invalid assertions that array->pdata != NULL ..
it's NULL for 0 elements which is a valid case.
Mon May 6 16:00:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/gbacktrace.h: Exclude OSF from alpha definition

View File

@ -1,3 +1,16 @@
Tue May 7 11:24:22 2002 Owen Taylor <otaylor@redhat.com>
Fixes for #79347, Ron Arts.
* glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
don't g_return_if_fail().
* tests/qsort-test.c (main): Add a 0 element test.
* glib/garray.c (g_[ptr_]array_sort_with[_data]):
Remove invalid assertions that array->pdata != NULL ..
it's NULL for 0 elements which is a valid case.
Mon May 6 16:00:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/gbacktrace.h: Exclude OSF from alpha definition

View File

@ -1,3 +1,16 @@
Tue May 7 11:24:22 2002 Owen Taylor <otaylor@redhat.com>
Fixes for #79347, Ron Arts.
* glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
don't g_return_if_fail().
* tests/qsort-test.c (main): Add a 0 element test.
* glib/garray.c (g_[ptr_]array_sort_with[_data]):
Remove invalid assertions that array->pdata != NULL ..
it's NULL for 0 elements which is a valid case.
Mon May 6 16:00:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/gbacktrace.h: Exclude OSF from alpha definition

View File

@ -1,3 +1,16 @@
Tue May 7 11:24:22 2002 Owen Taylor <otaylor@redhat.com>
Fixes for #79347, Ron Arts.
* glib/gqsort.c (g_qsort_with_data): Handle 0 elements,
don't g_return_if_fail().
* tests/qsort-test.c (main): Add a 0 element test.
* glib/garray.c (g_[ptr_]array_sort_with[_data]):
Remove invalid assertions that array->pdata != NULL ..
it's NULL for 0 elements which is a valid case.
Mon May 6 16:00:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/gbacktrace.h: Exclude OSF from alpha definition

View File

@ -276,7 +276,6 @@ g_array_sort (GArray *farray,
GRealArray *array = (GRealArray*) farray;
g_return_if_fail (array != NULL);
g_return_if_fail (array->data != NULL);
qsort (array->data,
array->len,
@ -292,7 +291,6 @@ g_array_sort_with_data (GArray *farray,
GRealArray *array = (GRealArray*) farray;
g_return_if_fail (array != NULL);
g_return_if_fail (array->data != NULL);
g_qsort_with_data (array->data,
array->len,
@ -570,7 +568,6 @@ g_ptr_array_sort (GPtrArray *array,
GCompareFunc compare_func)
{
g_return_if_fail (array != NULL);
g_return_if_fail (array->pdata != NULL);
qsort (array->pdata,
array->len,
@ -584,7 +581,6 @@ g_ptr_array_sort_with_data (GPtrArray *array,
gpointer user_data)
{
g_return_if_fail (array != NULL);
g_return_if_fail (array->pdata != NULL);
g_qsort_with_data (array->pdata,
array->len,

View File

@ -120,10 +120,13 @@ g_qsort_with_data (gconstpointer pbase,
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;

View File

@ -23,5 +23,8 @@ main ()
for (i = 0; i < SIZE - 1; i++)
g_assert (array[i] <= array[i+1]);
/* 0 elemenents is a valid case */
g_qsort_with_data (array, 0, sizeof (guint32), sort, NULL);
return 0;
}