From 5333deab1cc249684f2f6de5168c252bb56672ad Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 11 Mar 2016 08:30:18 -0800 Subject: [PATCH] Quick fix for qsort off-by-one error. --- src/stdlib/SDL_qsort.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stdlib/SDL_qsort.c b/src/stdlib/SDL_qsort.c index 035dc20ac..2ef33b15e 100644 --- a/src/stdlib/SDL_qsort.c +++ b/src/stdlib/SDL_qsort.c @@ -427,7 +427,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, Recurse(trunc) } } - PreInsertion(SWAP_nonaligned,TRUNC_nonaligned-1,size); + PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size); Insertion(SWAP_nonaligned); free(pivot); } @@ -458,7 +458,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size, Recurse(trunc) } } - PreInsertion(SWAP_aligned,TRUNC_aligned-1,size); + PreInsertion(SWAP_aligned,TRUNC_aligned,size); Insertion(SWAP_aligned); free(pivot); } @@ -499,7 +499,7 @@ fprintf(stderr, "after partitioning first=#%lu last=#%lu\n", (first-(char*)base) Recurse(TRUNC_words) } } - PreInsertion(SWAP_words,(TRUNC_words/WORD_BYTES)-1,WORD_BYTES); + PreInsertion(SWAP_words,(TRUNC_words/WORD_BYTES),WORD_BYTES); /* Now do insertion sort. */ last=((char*)base)+nmemb*WORD_BYTES; for (first=((char*)base)+WORD_BYTES;first!=last;first+=WORD_BYTES) {