mirror of
https://github.com/yawut/SDL.git
synced 2026-09-08 17:16:19 -05:00
Use SDL_ prefixed versions of C library functions.
FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
This commit is contained in:
@@ -42,20 +42,20 @@ int SDL_putenv(const char *variable)
|
||||
char *value;
|
||||
const char *sep;
|
||||
|
||||
sep = strchr(variable, '=');
|
||||
sep = SDL_strchr(variable, '=');
|
||||
if ( sep == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
bufferlen = strlen(variable)+1;
|
||||
bufferlen = SDL_strlen(variable)+1;
|
||||
if ( bufferlen > SDL_envmemlen ) {
|
||||
char *newmem = (char *)realloc(SDL_envmem, bufferlen);
|
||||
char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
|
||||
if ( newmem == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
SDL_envmem = newmem;
|
||||
SDL_envmemlen = bufferlen;
|
||||
}
|
||||
strcpy(SDL_envmem, variable);
|
||||
SDL_strcpy(SDL_envmem, variable);
|
||||
value = SDL_envmem + (sep - variable);
|
||||
*value++ = '\0';
|
||||
if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) {
|
||||
@@ -74,7 +74,7 @@ char *SDL_getenv(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
if ( bufferlen > SDL_envmemlen ) {
|
||||
char *newmem = (char *)realloc(SDL_envmem, bufferlen);
|
||||
char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
|
||||
if ( newmem == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ int SDL_putenv(const char *variable)
|
||||
|
||||
/* Didn't find it in the environment, expand and add */
|
||||
if ( ! added ) {
|
||||
new_env = realloc(SDL_env, (i+2)*sizeof(char *));
|
||||
new_env = SDL_realloc(SDL_env, (i+2)*sizeof(char *));
|
||||
if ( new_env ) {
|
||||
SDL_env = new_env;
|
||||
SDL_env[i++] = new_variable;
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
#define LACKS_ERRNO_H
|
||||
#define LACKS_STDLIB_H
|
||||
#define ABORT
|
||||
#define memset SDL_memset
|
||||
#define memcpy SDL_memcpy
|
||||
#define malloc SDL_malloc
|
||||
#define realloc SDL_realloc
|
||||
#define free SDL_free
|
||||
|
||||
/*
|
||||
This is a version (aka dlmalloc) of malloc/free/realloc written by
|
||||
|
||||
@@ -233,9 +233,9 @@ typedef struct { char * first; char * last; } stack_entry;
|
||||
/* Shift everything in [test,first) \
|
||||
* up by one, and place |first| \
|
||||
* where |test| is. */ \
|
||||
memcpy(pivot,first,size); \
|
||||
memmove(test+size,test,first-test); \
|
||||
memcpy(test,pivot,size); \
|
||||
SDL_memcpy(pivot,first,size); \
|
||||
SDL_memmove(test+size,test,first-test); \
|
||||
SDL_memcpy(test,pivot,size); \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
|
||||
stack_entry stack[STACK_SIZE];
|
||||
int stacktop=0;
|
||||
char *first,*last;
|
||||
char *pivot=malloc(size);
|
||||
char *pivot=SDL_malloc(size);
|
||||
size_t trunc=TRUNC_nonaligned*size;
|
||||
assert(pivot!=0);
|
||||
|
||||
@@ -310,7 +310,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
|
||||
/* Select pivot */
|
||||
{ char * mid=first+size*((last-first)/size >> 1);
|
||||
Pivot(SWAP_nonaligned,size);
|
||||
memcpy(pivot,mid,size);
|
||||
SDL_memcpy(pivot,mid,size);
|
||||
}
|
||||
/* Partition. */
|
||||
Partition(SWAP_nonaligned,size);
|
||||
@@ -320,7 +320,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
|
||||
}
|
||||
PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size);
|
||||
Insertion(SWAP_nonaligned);
|
||||
free(pivot);
|
||||
SDL_free(pivot);
|
||||
}
|
||||
|
||||
static void qsort_aligned(void *base, size_t nmemb, size_t size,
|
||||
@@ -329,7 +329,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size,
|
||||
stack_entry stack[STACK_SIZE];
|
||||
int stacktop=0;
|
||||
char *first,*last;
|
||||
char *pivot=malloc(size);
|
||||
char *pivot=SDL_malloc(size);
|
||||
size_t trunc=TRUNC_aligned*size;
|
||||
assert(pivot!=0);
|
||||
|
||||
@@ -341,7 +341,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size,
|
||||
/* Select pivot */
|
||||
{ char * mid=first+size*((last-first)/size >> 1);
|
||||
Pivot(SWAP_aligned,size);
|
||||
memcpy(pivot,mid,size);
|
||||
SDL_memcpy(pivot,mid,size);
|
||||
}
|
||||
/* Partition. */
|
||||
Partition(SWAP_aligned,size);
|
||||
@@ -351,7 +351,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size,
|
||||
}
|
||||
PreInsertion(SWAP_aligned,TRUNC_aligned,size);
|
||||
Insertion(SWAP_aligned);
|
||||
free(pivot);
|
||||
SDL_free(pivot);
|
||||
}
|
||||
|
||||
static void qsort_words(void *base, size_t nmemb,
|
||||
@@ -360,7 +360,7 @@ static void qsort_words(void *base, size_t nmemb,
|
||||
stack_entry stack[STACK_SIZE];
|
||||
int stacktop=0;
|
||||
char *first,*last;
|
||||
char *pivot=malloc(WORD_BYTES);
|
||||
char *pivot=SDL_malloc(WORD_BYTES);
|
||||
assert(pivot!=0);
|
||||
|
||||
first=(char*)base; last=first+(nmemb-1)*WORD_BYTES;
|
||||
@@ -398,7 +398,7 @@ fprintf(stderr,"pivot=%d\n",*(int*)pivot);
|
||||
*pr=*pl; }
|
||||
if (pr!=(int*)first) *pr=*(int*)pivot;
|
||||
}
|
||||
free(pivot);
|
||||
SDL_free(pivot);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@@ -375,7 +375,7 @@ char *SDL_strchr(const char *string, int c)
|
||||
#ifndef HAVE_STRRCHR
|
||||
char *SDL_strrchr(const char *string, int c)
|
||||
{
|
||||
const char *bufp = string + strlen(string) - 1;
|
||||
const char *bufp = string + SDL_strlen(string) - 1;
|
||||
while ( bufp >= string ) {
|
||||
if ( *bufp == c ) {
|
||||
return (char *)bufp;
|
||||
@@ -388,9 +388,9 @@ char *SDL_strrchr(const char *string, int c)
|
||||
#ifndef HAVE_STRSTR
|
||||
char *SDL_strstr(const char *haystack, const char *needle)
|
||||
{
|
||||
size_t length = strlen(needle);
|
||||
size_t length = SDL_strlen(needle);
|
||||
while ( *haystack ) {
|
||||
if ( strncmp(haystack, needle, length) == 0 ) {
|
||||
if ( SDL_strncmp(haystack, needle, length) == 0 ) {
|
||||
return (char *)haystack;
|
||||
}
|
||||
}
|
||||
@@ -429,9 +429,9 @@ char *SDL_ltoa(long value, char *string, int radix)
|
||||
|
||||
/* The numbers went into the string backwards. :) */
|
||||
if ( *string == '-' ) {
|
||||
_strrev(string+1);
|
||||
SDL_strrev(string+1);
|
||||
} else {
|
||||
_strrev(string);
|
||||
SDL_strrev(string);
|
||||
}
|
||||
|
||||
return string;
|
||||
@@ -454,7 +454,7 @@ char *SDL_ultoa(unsigned long value, char *string, int radix)
|
||||
*bufp = '\0';
|
||||
|
||||
/* The numbers went into the string backwards. :) */
|
||||
_strrev(string);
|
||||
SDL_strrev(string);
|
||||
|
||||
return string;
|
||||
}
|
||||
@@ -497,9 +497,9 @@ char *SDL_lltoa(Sint64 value, char *string, int radix)
|
||||
|
||||
/* The numbers went into the string backwards. :) */
|
||||
if ( *string == '-' ) {
|
||||
_strrev(string+1);
|
||||
SDL_strrev(string+1);
|
||||
} else {
|
||||
_strrev(string);
|
||||
SDL_strrev(string);
|
||||
}
|
||||
|
||||
return string;
|
||||
@@ -522,7 +522,7 @@ char *SDL_ulltoa(Uint64 value, char *string, int radix)
|
||||
*bufp = '\0';
|
||||
|
||||
/* The numbers went into the string backwards. :) */
|
||||
_strrev(string);
|
||||
SDL_strrev(string);
|
||||
|
||||
return string;
|
||||
}
|
||||
@@ -878,12 +878,12 @@ static size_t SDL_PrintLong(char *text, long value, int radix, size_t maxlen)
|
||||
char num[130];
|
||||
size_t size;
|
||||
|
||||
_ltoa(value, num, radix);
|
||||
SDL_ltoa(value, num, radix);
|
||||
size = SDL_strlen(num);
|
||||
if ( size > maxlen ) {
|
||||
size = maxlen;
|
||||
}
|
||||
strncpy(text, num, size);
|
||||
SDL_strncpy(text, num, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -892,12 +892,12 @@ static size_t SDL_PrintUnsignedLong(char *text, unsigned long value, int radix,
|
||||
char num[130];
|
||||
size_t size;
|
||||
|
||||
_ultoa(value, num, radix);
|
||||
SDL_ultoa(value, num, radix);
|
||||
size = SDL_strlen(num);
|
||||
if ( size > maxlen ) {
|
||||
size = maxlen;
|
||||
}
|
||||
strncpy(text, num, size);
|
||||
SDL_strncpy(text, num, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -907,12 +907,12 @@ static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxl
|
||||
char num[130];
|
||||
size_t size;
|
||||
|
||||
_i64toa(value, num, radix);
|
||||
SDL_lltoa(value, num, radix);
|
||||
size = SDL_strlen(num);
|
||||
if ( size > maxlen ) {
|
||||
size = maxlen;
|
||||
}
|
||||
strncpy(text, num, size);
|
||||
SDL_strncpy(text, num, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -921,12 +921,12 @@ static size_t SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, siz
|
||||
char num[130];
|
||||
size_t size;
|
||||
|
||||
_ui64toa(value, num, radix);
|
||||
SDL_ulltoa(value, num, radix);
|
||||
size = SDL_strlen(num);
|
||||
if ( size > maxlen ) {
|
||||
size = maxlen;
|
||||
}
|
||||
strncpy(text, num, size);
|
||||
SDL_strncpy(text, num, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -1076,7 +1076,7 @@ int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||
break;
|
||||
}
|
||||
if ( do_lowercase ) {
|
||||
_strlwr(text);
|
||||
SDL_strlwr(text);
|
||||
}
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user