src/stdlib/SDL_qsort.c
changeset 10116 418691d83f6a
parent 10085 a8e53dc3c5a1
equal deleted inserted replaced
10115:4f54ed649bf7 10116:418691d83f6a
   425       Partition(SWAP_nonaligned,size);
   425       Partition(SWAP_nonaligned,size);
   426       /* Prepare to recurse/iterate. */
   426       /* Prepare to recurse/iterate. */
   427       Recurse(trunc)
   427       Recurse(trunc)
   428     }
   428     }
   429   }
   429   }
   430   PreInsertion(SWAP_nonaligned,TRUNC_nonaligned-1,size);
   430   PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size);
   431   Insertion(SWAP_nonaligned);
   431   Insertion(SWAP_nonaligned);
   432   free(pivot);
   432   free(pivot);
   433 }
   433 }
   434 
   434 
   435 static void qsort_aligned(void *base, size_t nmemb, size_t size,
   435 static void qsort_aligned(void *base, size_t nmemb, size_t size,
   456       Partition(SWAP_aligned,size);
   456       Partition(SWAP_aligned,size);
   457       /* Prepare to recurse/iterate. */
   457       /* Prepare to recurse/iterate. */
   458       Recurse(trunc)
   458       Recurse(trunc)
   459     }
   459     }
   460   }
   460   }
   461   PreInsertion(SWAP_aligned,TRUNC_aligned-1,size);
   461   PreInsertion(SWAP_aligned,TRUNC_aligned,size);
   462   Insertion(SWAP_aligned);
   462   Insertion(SWAP_aligned);
   463   free(pivot);
   463   free(pivot);
   464 }
   464 }
   465 
   465 
   466 static void qsort_words(void *base, size_t nmemb,
   466 static void qsort_words(void *base, size_t nmemb,
   497 #endif
   497 #endif
   498       /* Prepare to recurse/iterate. */
   498       /* Prepare to recurse/iterate. */
   499       Recurse(TRUNC_words)
   499       Recurse(TRUNC_words)
   500     }
   500     }
   501   }
   501   }
   502   PreInsertion(SWAP_words,(TRUNC_words/WORD_BYTES)-1,WORD_BYTES);
   502   PreInsertion(SWAP_words,(TRUNC_words/WORD_BYTES),WORD_BYTES);
   503   /* Now do insertion sort. */
   503   /* Now do insertion sort. */
   504   last=((char*)base)+nmemb*WORD_BYTES;
   504   last=((char*)base)+nmemb*WORD_BYTES;
   505   for (first=((char*)base)+WORD_BYTES;first!=last;first+=WORD_BYTES) {
   505   for (first=((char*)base)+WORD_BYTES;first!=last;first+=WORD_BYTES) {
   506     /* Find the right place for |first|. My apologies for var reuse */
   506     /* Find the right place for |first|. My apologies for var reuse */
   507     int *pl=(int*)(first-WORD_BYTES),*pr=(int*)first;
   507     int *pl=(int*)(first-WORD_BYTES),*pr=(int*)first;