Don't touch code that we brought in from other sources
authorSam Lantinga <slouken@libsdl.org>
Tue, 07 Feb 2006 07:03:29 +0000
changeset 1337c687f06c7473
parent 1336 3692456e7b0f
child 1338 604d73db6802
Don't touch code that we brought in from other sources
src/stdlib/SDL_qsort.c
     1.1 --- a/src/stdlib/SDL_qsort.c	Tue Feb 07 06:59:48 2006 +0000
     1.2 +++ b/src/stdlib/SDL_qsort.c	Tue Feb 07 07:03:29 2006 +0000
     1.3 @@ -47,10 +47,17 @@
     1.4  #include <stdlib.h>
     1.5  #include <string.h>
     1.6  */
     1.7 -#define assert(X)
     1.8  #include "SDL_stdlib.h"
     1.9  #include "SDL_string.h"
    1.10  
    1.11 +#define assert(X)
    1.12 +#define malloc	SDL_malloc
    1.13 +#define free	SDL_free
    1.14 +#define memcpy	SDL_memcpy
    1.15 +#define memmove	SDL_memmove
    1.16 +#define qsort	SDL_qsort
    1.17 +
    1.18 +
    1.19  #ifndef HAVE_QSORT
    1.20  
    1.21  static char _ID[]="<qsort.c gjm 1.12 1998-03-19>";
    1.22 @@ -233,9 +240,9 @@
    1.23        /* Shift everything in [test,first)	\
    1.24         * up by one, and place |first|		\
    1.25         * where |test| is. */			\
    1.26 -      SDL_memcpy(pivot,first,size);			\
    1.27 -      SDL_memmove(test+size,test,first-test);	\
    1.28 -      SDL_memcpy(test,pivot,size);			\
    1.29 +      memcpy(pivot,first,size);			\
    1.30 +      memmove(test+size,test,first-test);	\
    1.31 +      memcpy(test,pivot,size);			\
    1.32      }						\
    1.33    }
    1.34  
    1.35 @@ -298,7 +305,7 @@
    1.36    stack_entry stack[STACK_SIZE];
    1.37    int stacktop=0;
    1.38    char *first,*last;
    1.39 -  char *pivot=SDL_malloc(size);
    1.40 +  char *pivot=malloc(size);
    1.41    size_t trunc=TRUNC_nonaligned*size;
    1.42    assert(pivot!=0);
    1.43  
    1.44 @@ -310,7 +317,7 @@
    1.45        /* Select pivot */
    1.46        { char * mid=first+size*((last-first)/size >> 1);
    1.47          Pivot(SWAP_nonaligned,size);
    1.48 -        SDL_memcpy(pivot,mid,size);
    1.49 +        memcpy(pivot,mid,size);
    1.50        }
    1.51        /* Partition. */
    1.52        Partition(SWAP_nonaligned,size);
    1.53 @@ -320,7 +327,7 @@
    1.54    }
    1.55    PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size);
    1.56    Insertion(SWAP_nonaligned);
    1.57 -  SDL_free(pivot);
    1.58 +  free(pivot);
    1.59  }
    1.60  
    1.61  static void qsort_aligned(void *base, size_t nmemb, size_t size,
    1.62 @@ -329,7 +336,7 @@
    1.63    stack_entry stack[STACK_SIZE];
    1.64    int stacktop=0;
    1.65    char *first,*last;
    1.66 -  char *pivot=SDL_malloc(size);
    1.67 +  char *pivot=malloc(size);
    1.68    size_t trunc=TRUNC_aligned*size;
    1.69    assert(pivot!=0);
    1.70  
    1.71 @@ -341,7 +348,7 @@
    1.72        /* Select pivot */
    1.73        { char * mid=first+size*((last-first)/size >> 1);
    1.74          Pivot(SWAP_aligned,size);
    1.75 -        SDL_memcpy(pivot,mid,size);
    1.76 +        memcpy(pivot,mid,size);
    1.77        }
    1.78        /* Partition. */
    1.79        Partition(SWAP_aligned,size);
    1.80 @@ -351,7 +358,7 @@
    1.81    }
    1.82    PreInsertion(SWAP_aligned,TRUNC_aligned,size);
    1.83    Insertion(SWAP_aligned);
    1.84 -  SDL_free(pivot);
    1.85 +  free(pivot);
    1.86  }
    1.87  
    1.88  static void qsort_words(void *base, size_t nmemb,
    1.89 @@ -360,7 +367,7 @@
    1.90    stack_entry stack[STACK_SIZE];
    1.91    int stacktop=0;
    1.92    char *first,*last;
    1.93 -  char *pivot=SDL_malloc(WORD_BYTES);
    1.94 +  char *pivot=malloc(WORD_BYTES);
    1.95    assert(pivot!=0);
    1.96  
    1.97    first=(char*)base; last=first+(nmemb-1)*WORD_BYTES;
    1.98 @@ -398,12 +405,12 @@
    1.99        *pr=*pl; }
   1.100      if (pr!=(int*)first) *pr=*(int*)pivot;
   1.101    }
   1.102 -  SDL_free(pivot);
   1.103 +  free(pivot);
   1.104  }
   1.105  
   1.106  /* ---------------------------------------------------------------------- */
   1.107  
   1.108 -void SDL_qsort(void *base, size_t nmemb, size_t size,
   1.109 +void qsort(void *base, size_t nmemb, size_t size,
   1.110             int (*compare)(const void *, const void *)) {
   1.111  
   1.112    if (nmemb<=1) return;