Mercurial > sdl-ios-xcode
changeset 1337:c687f06c7473
Don't touch code that we brought in from other sources
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 07:03:29 +0000 |
parents | 3692456e7b0f |
children | 604d73db6802 |
files | src/stdlib/SDL_qsort.c |
diffstat | 1 files changed, 20 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/stdlib/SDL_qsort.c Tue Feb 07 06:59:48 2006 +0000 +++ b/src/stdlib/SDL_qsort.c Tue Feb 07 07:03:29 2006 +0000 @@ -47,10 +47,17 @@ #include <stdlib.h> #include <string.h> */ -#define assert(X) #include "SDL_stdlib.h" #include "SDL_string.h" +#define assert(X) +#define malloc SDL_malloc +#define free SDL_free +#define memcpy SDL_memcpy +#define memmove SDL_memmove +#define qsort SDL_qsort + + #ifndef HAVE_QSORT static char _ID[]="<qsort.c gjm 1.12 1998-03-19>"; @@ -233,9 +240,9 @@ /* Shift everything in [test,first) \ * up by one, and place |first| \ * where |test| is. */ \ - SDL_memcpy(pivot,first,size); \ - SDL_memmove(test+size,test,first-test); \ - SDL_memcpy(test,pivot,size); \ + memcpy(pivot,first,size); \ + memmove(test+size,test,first-test); \ + memcpy(test,pivot,size); \ } \ } @@ -298,7 +305,7 @@ stack_entry stack[STACK_SIZE]; int stacktop=0; char *first,*last; - char *pivot=SDL_malloc(size); + char *pivot=malloc(size); size_t trunc=TRUNC_nonaligned*size; assert(pivot!=0); @@ -310,7 +317,7 @@ /* Select pivot */ { char * mid=first+size*((last-first)/size >> 1); Pivot(SWAP_nonaligned,size); - SDL_memcpy(pivot,mid,size); + memcpy(pivot,mid,size); } /* Partition. */ Partition(SWAP_nonaligned,size); @@ -320,7 +327,7 @@ } PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size); Insertion(SWAP_nonaligned); - SDL_free(pivot); + free(pivot); } static void qsort_aligned(void *base, size_t nmemb, size_t size, @@ -329,7 +336,7 @@ stack_entry stack[STACK_SIZE]; int stacktop=0; char *first,*last; - char *pivot=SDL_malloc(size); + char *pivot=malloc(size); size_t trunc=TRUNC_aligned*size; assert(pivot!=0); @@ -341,7 +348,7 @@ /* Select pivot */ { char * mid=first+size*((last-first)/size >> 1); Pivot(SWAP_aligned,size); - SDL_memcpy(pivot,mid,size); + memcpy(pivot,mid,size); } /* Partition. */ Partition(SWAP_aligned,size); @@ -351,7 +358,7 @@ } PreInsertion(SWAP_aligned,TRUNC_aligned,size); Insertion(SWAP_aligned); - SDL_free(pivot); + free(pivot); } static void qsort_words(void *base, size_t nmemb, @@ -360,7 +367,7 @@ stack_entry stack[STACK_SIZE]; int stacktop=0; char *first,*last; - char *pivot=SDL_malloc(WORD_BYTES); + char *pivot=malloc(WORD_BYTES); assert(pivot!=0); first=(char*)base; last=first+(nmemb-1)*WORD_BYTES; @@ -398,12 +405,12 @@ *pr=*pl; } if (pr!=(int*)first) *pr=*(int*)pivot; } - SDL_free(pivot); + free(pivot); } /* ---------------------------------------------------------------------- */ -void SDL_qsort(void *base, size_t nmemb, size_t size, +void qsort(void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *)) { if (nmemb<=1) return;