SDL_qsort.c: fix calling conventions of private functions' compare args

This commit is contained in:
Ozkan Sezer
2024-06-14 14:50:10 +03:00
parent bd06e43b87
commit 499bff9c3a

View File

@@ -28,7 +28,7 @@
#include "SDL_stdinc.h"
#if defined(HAVE_QSORT)
void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
void SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *))
{
if (!base) {
return;
@@ -368,7 +368,7 @@ typedef struct { char * first; char * last; } stack_entry;
/* ---------------------------------------------------------------------- */
static char * pivot_big(char *first, char *mid, char *last, size_t size,
int compare(const void *, const void *)) {
int (SDLCALL * compare)(const void *, const void *)) {
size_t d=(((last-first)/size)>>3)*size;
#ifdef DEBUG_QSORT
fprintf(stderr, "pivot_big: first=%p last=%p size=%lu n=%lu\n", first, (unsigned long)last, size, (unsigned long)((last-first+1)/size));
@@ -409,7 +409,7 @@ fprintf(stderr,"-> %d %d %d @ %p %p %p\n",*(int*)m1,*(int*)m2,*(int*)m3, m1,m2,m
/* ---------------------------------------------------------------------- */
static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *)) {
int (SDLCALL * compare)(const void *, const void *)) {
stack_entry stack[STACK_SIZE];
int stacktop=0;
@@ -440,7 +440,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
}
static void qsort_aligned(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *)) {
int (SDLCALL * compare)(const void *, const void *)) {
stack_entry stack[STACK_SIZE];
int stacktop=0;
@@ -471,7 +471,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size,
}
static void qsort_words(void *base, size_t nmemb,
int (*compare)(const void *, const void *)) {
int (SDLCALL * compare)(const void *, const void *)) {
stack_entry stack[STACK_SIZE];
int stacktop=0;
@@ -523,7 +523,7 @@ fprintf(stderr, "after partitioning first=#%lu last=#%lu\n", (first-(char*)base)
/* ---------------------------------------------------------------------- */
extern void qsortG(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *)) {
int (SDLCALL * compare)(const void *, const void *)) {
if (nmemb<=1) return;
if (((size_t)base|size)&(WORD_BYTES-1))
@@ -536,7 +536,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size,
#endif /* HAVE_QSORT */
void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL * compare)(const void *, const void *))
{
#if defined(HAVE_BSEARCH)
return bsearch(key, base, nmemb, size, compare);
@@ -569,4 +569,3 @@ void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
}
/* vi: set ts=4 sw=4 expandtab: */