Quick fix for qsort off-by-one error.
authorSam Lantinga <slouken@libsdl.org>
Fri, 11 Mar 2016 08:30:18 -0800
changeset 10116 418691d83f6a
parent 10115 4f54ed649bf7
child 10117 7552aa4c1c6d
Quick fix for qsort off-by-one error.
src/stdlib/SDL_qsort.c
--- a/src/stdlib/SDL_qsort.c	Fri Mar 11 22:10:35 2016 +0100
+++ b/src/stdlib/SDL_qsort.c	Fri Mar 11 08:30:18 2016 -0800
@@ -427,7 +427,7 @@
       Recurse(trunc)
     }
   }
-  PreInsertion(SWAP_nonaligned,TRUNC_nonaligned-1,size);
+  PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size);
   Insertion(SWAP_nonaligned);
   free(pivot);
 }
@@ -458,7 +458,7 @@
       Recurse(trunc)
     }
   }
-  PreInsertion(SWAP_aligned,TRUNC_aligned-1,size);
+  PreInsertion(SWAP_aligned,TRUNC_aligned,size);
   Insertion(SWAP_aligned);
   free(pivot);
 }
@@ -499,7 +499,7 @@
       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) {