Commit 1da8cb01 authored by Sam Lantinga's avatar Sam Lantinga

Use only safe string functions

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401383
parent a81db3ea
...@@ -119,7 +119,7 @@ if test x$enable_libc = xyes; then ...@@ -119,7 +119,7 @@ if test x$enable_libc = xyes; then
if test x$ac_cv_func_strtod = xyes; then if test x$ac_cv_func_strtod = xyes; then
AC_DEFINE(HAVE_STRTOD) AC_DEFINE(HAVE_STRTOD)
fi fi
AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strcpy strncpy strcat strncat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol _i64toa _ui64toa strtoll atoi atof strcmp strncmp stricmp strcasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep) AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol _i64toa _ui64toa strtoll atoi atof strcmp strncmp stricmp strcasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep)
AC_CHECK_LIB(m, pow, [BUILD_LIBS="$BUILD_LIBS -lm"]) AC_CHECK_LIB(m, pow, [BUILD_LIBS="$BUILD_LIBS -lm"])
fi fi
......
...@@ -87,10 +87,8 @@ ...@@ -87,10 +87,8 @@
#undef HAVE_MEMMOVE #undef HAVE_MEMMOVE
#undef HAVE_MEMCMP #undef HAVE_MEMCMP
#undef HAVE_STRLEN #undef HAVE_STRLEN
#undef HAVE_STRCPY #undef HAVE_STRLCPY
#undef HAVE_STRNCPY #undef HAVE_STRLCAT
#undef HAVE_STRCAT
#undef HAVE_STRNCAT
#undef HAVE_STRDUP #undef HAVE_STRDUP
#undef HAVE__STRREV #undef HAVE__STRREV
#undef HAVE__STRUPR #undef HAVE__STRUPR
......
...@@ -206,6 +206,9 @@ extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, ...@@ -206,6 +206,9 @@ extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) #define SDL_abs(X) ((X) < 0 ? -(X) : (X))
#endif #endif
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
#if HAVE_CTYPE_H #if HAVE_CTYPE_H
#define SDL_isdigit(X) isdigit(X) #define SDL_isdigit(X) isdigit(X)
#define SDL_isspace(X) isspace(X) #define SDL_isspace(X) isspace(X)
...@@ -355,28 +358,16 @@ extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t le ...@@ -355,28 +358,16 @@ extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t le
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
#endif #endif
#if HAVE_STRCPY #if HAVE_STRLCPY
#define SDL_strcpy strcpy #define SDL_strlcpy strlcpy
#else
extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src);
#endif
#if HAVE_STRNCPY
#define SDL_strncpy strncpy
#else
extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen);
#endif
#if HAVE_STRCAT
#define SDL_strcat strcat
#else #else
#define SDL_strcat(dst, src) (SDL_strcpy(dst+SDL_strlen(dst), src), dst) extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
#endif #endif
#if HAVE_STRNCAT #if HAVE_STRLCAT
#define SDL_strncat strncat #define SDL_strlcat strlcat
#else #else
#define SDL_strncat(dst, src, n) (SDL_strncpy(dst+SDL_strlen(dst), src, n), dst) extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
#endif #endif
#if HAVE_STRDUP #if HAVE_STRDUP
......
...@@ -59,8 +59,7 @@ void SDL_SetError (const char *fmt, ...) ...@@ -59,8 +59,7 @@ void SDL_SetError (const char *fmt, ...)
/* Copy in the key, mark error as valid */ /* Copy in the key, mark error as valid */
error = SDL_GetErrBuf(); error = SDL_GetErrBuf();
error->error = 1; error->error = 1;
SDL_strncpy((char *)error->key, fmt, sizeof(error->key)); SDL_strlcpy((char *)error->key, fmt, sizeof(error->key));
error->key[sizeof(error->key)-1] = '\0';
va_start(ap, fmt); va_start(ap, fmt);
error->argc = 0; error->argc = 0;
...@@ -94,8 +93,7 @@ void SDL_SetError (const char *fmt, ...) ...@@ -94,8 +93,7 @@ void SDL_SetError (const char *fmt, ...)
char *str = va_arg(ap, char *); char *str = va_arg(ap, char *);
if (str == NULL) if (str == NULL)
str = "(null)"; str = "(null)";
SDL_strncpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN); SDL_strlcpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
error->args[index].buf[ERR_MAX_STRLEN-1] = 0;
error->argc++; error->argc++;
} }
break; break;
...@@ -251,8 +249,7 @@ Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen) ...@@ -251,8 +249,7 @@ Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen)
/* Allocate the UNICODE buffer */ /* Allocate the UNICODE buffer */
errstr16 = (Uint16 *)SDL_malloc(maxlen * (sizeof *errstr16)); errstr16 = (Uint16 *)SDL_malloc(maxlen * (sizeof *errstr16));
if ( ! errstr16 ) { if ( ! errstr16 ) {
SDL_strncpy((char *)errstr, "Out of memory", maxlen); SDL_strlcpy((char *)errstr, "Out of memory", maxlen);
errstr[maxlen-1] = '\0';
return(errstr); return(errstr);
} }
......
...@@ -373,8 +373,7 @@ int SDL_AudioInit(const char *driver_name) ...@@ -373,8 +373,7 @@ int SDL_AudioInit(const char *driver_name)
char *SDL_AudioDriverName(char *namebuf, int maxlen) char *SDL_AudioDriverName(char *namebuf, int maxlen)
{ {
if ( current_audio != NULL ) { if ( current_audio != NULL ) {
SDL_strncpy(namebuf, current_audio->name, maxlen-1); SDL_strlcpy(namebuf, current_audio->name, maxlen);
namebuf[maxlen-1] = '\0';
return(namebuf); return(namebuf);
} }
return(NULL); return(NULL);
......
...@@ -89,7 +89,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) ...@@ -89,7 +89,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
audiodev = audiopath; audiodev = audiopath;
} }
if ( path != NULL ) { if ( path != NULL ) {
SDL_strncpy(path, audiodev, maxlen); SDL_strlcpy(path, audiodev, maxlen);
path[maxlen-1] = '\0'; path[maxlen-1] = '\0';
} }
return(audio_fd); return(audio_fd);
...@@ -136,7 +136,7 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags) ...@@ -136,7 +136,7 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
} }
audio_fd = open(audiodev, flags, 0); audio_fd = open(audiodev, flags, 0);
if ( path != NULL ) { if ( path != NULL ) {
SDL_strncpy(path, audiodev, maxlen); SDL_strlcpy(path, audiodev, maxlen);
path[maxlen-1] = '\0'; path[maxlen-1] = '\0';
} }
return audio_fd; return audio_fd;
...@@ -166,8 +166,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) ...@@ -166,8 +166,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
audio_fd = open(audiopath, flags, 0); audio_fd = open(audiopath, flags, 0);
if ( audio_fd > 0 ) { if ( audio_fd > 0 ) {
if ( path != NULL ) { if ( path != NULL ) {
SDL_strncpy( path, audiopath, maxlen ); SDL_strlcpy( path, audiopath, maxlen );
path[maxlen-1] = '\0';
} }
return audio_fd; return audio_fd;
} }
......
...@@ -124,7 +124,7 @@ static int LoadALSALibrary(void) { ...@@ -124,7 +124,7 @@ static int LoadALSALibrary(void) {
if (alsa_handle) { if (alsa_handle) {
alsa_loaded = 1; alsa_loaded = 1;
retval = 0; retval = 0;
for (i = 0; i < SDL_TABLESIZE(alsa_functions); i++) { for (i = 0; i < SDL_arraysize(alsa_functions); i++) {
/* *alsa_functions[i].func = SDL_LoadFunction(alsa_handle,alsa_functions[i].name);*/ /* *alsa_functions[i].func = SDL_LoadFunction(alsa_handle,alsa_functions[i].name);*/
#if HAVE_DLVSYM #if HAVE_DLVSYM
*alsa_functions[i].func = dlvsym(alsa_handle,alsa_functions[i].name,"ALSA_0.9"); *alsa_functions[i].func = dlvsym(alsa_handle,alsa_functions[i].name,"ALSA_0.9");
......
...@@ -90,7 +90,7 @@ static int LoadARTSLibrary(void) ...@@ -90,7 +90,7 @@ static int LoadARTSLibrary(void)
if ( arts_handle ) { if ( arts_handle ) {
arts_loaded = 1; arts_loaded = 1;
retval = 0; retval = 0;
for ( i=0; i<SDL_TABLESIZE(arts_functions); ++i ) { for ( i=0; i<SDL_arraysize(arts_functions); ++i ) {
*arts_functions[i].func = SDL_LoadFunction(arts_handle, arts_functions[i].name); *arts_functions[i].func = SDL_LoadFunction(arts_handle, arts_functions[i].name);
if ( !*arts_functions[i].func ) { if ( !*arts_functions[i].func ) {
retval = -1; retval = -1;
......
...@@ -85,7 +85,7 @@ static int LoadESDLibrary(void) ...@@ -85,7 +85,7 @@ static int LoadESDLibrary(void)
if ( esd_handle ) { if ( esd_handle ) {
esd_loaded = 1; esd_loaded = 1;
retval = 0; retval = 0;
for ( i=0; i<SDL_TABLESIZE(esd_functions); ++i ) { for ( i=0; i<SDL_arraysize(esd_functions); ++i ) {
*esd_functions[i].func = SDL_LoadFunction(esd_handle, esd_functions[i].name); *esd_functions[i].func = SDL_LoadFunction(esd_handle, esd_functions[i].name);
if ( !*esd_functions[i].func ) { if ( !*esd_functions[i].func ) {
retval = -1; retval = -1;
......
...@@ -124,12 +124,11 @@ static void AddDrive(char *drive, struct stat *stbuf) ...@@ -124,12 +124,11 @@ static void AddDrive(char *drive, struct stat *stbuf)
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
...@@ -302,9 +301,10 @@ int SDL_SYS_CDInit(void) ...@@ -302,9 +301,10 @@ int SDL_SYS_CDInit(void)
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if ( SDLcdrom != NULL ) { if ( SDLcdrom != NULL ) {
char *cdpath, *delim; char *cdpath, *delim;
cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_stack_alloc(char, len);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -323,7 +323,7 @@ int SDL_SYS_CDInit(void) ...@@ -323,7 +323,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
...@@ -360,21 +360,23 @@ static int SDL_SYS_CDOpen(int drive) ...@@ -360,21 +360,23 @@ static int SDL_SYS_CDOpen(int drive)
int fd; int fd;
char* lastsl; char* lastsl;
char* cdromname; char* cdromname;
size_t len;
/* /*
* We found /dev/cd? drives and that is in our list. But we can * We found /dev/cd? drives and that is in our list. But we can
* open only the /dev/rcd? versions of those devices for Audio CD. * open only the /dev/rcd? versions of those devices for Audio CD.
*/ */
cdromname = (char*)SDL_malloc( SDL_strlen(SDL_cdlist[drive]+2) ); len = SDL_strlen(SDL_cdlist[drive])+2;
SDL_strcpy(cdromname,SDL_cdlist[drive]); cdromname = (char*)SDL_malloc(len);
SDL_strlcpy(cdromname,SDL_cdlist[drive],len);
lastsl = SDL_strrchr(cdromname,'/'); lastsl = SDL_strrchr(cdromname,'/');
if (lastsl) { if (lastsl) {
*lastsl = 0; *lastsl = 0;
strcat(cdromname,"/r"); SDL_strlcat(cdromname,"/r",len);
lastsl = SDL_strrchr(SDL_cdlist[drive],'/'); lastsl = SDL_strrchr(SDL_cdlist[drive],'/');
if (lastsl) { if (lastsl) {
lastsl++; lastsl++;
strcat(cdromname,lastsl); SDL_strlcat(cdromname,lastsl,len);
} }
} }
......
...@@ -224,12 +224,11 @@ static void AddDrive(char *drive, struct stat *stbuf) ...@@ -224,12 +224,11 @@ static void AddDrive(char *drive, struct stat *stbuf)
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
...@@ -265,9 +264,10 @@ int SDL_SYS_CDInit(void) ...@@ -265,9 +264,10 @@ int SDL_SYS_CDInit(void)
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if ( SDLcdrom != NULL ) { if ( SDLcdrom != NULL ) {
char *cdpath, *delim; char *cdpath, *delim;
cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_stack_alloc(char, len);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -283,7 +283,7 @@ int SDL_SYS_CDInit(void) ...@@ -283,7 +283,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
......
...@@ -110,12 +110,11 @@ static void AddDrive(char *drive, struct stat *stbuf) ...@@ -110,12 +110,11 @@ static void AddDrive(char *drive, struct stat *stbuf)
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
...@@ -152,9 +151,10 @@ int SDL_SYS_CDInit(void) ...@@ -152,9 +151,10 @@ int SDL_SYS_CDInit(void)
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if ( SDLcdrom != NULL ) { if ( SDLcdrom != NULL ) {
char *cdpath, *delim; char *cdpath, *delim;
cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_stack_alloc(char, len);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -170,7 +170,7 @@ int SDL_SYS_CDInit(void) ...@@ -170,7 +170,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
......
...@@ -167,12 +167,11 @@ static void AddDrive(char *drive, struct stat *stbuf) ...@@ -167,12 +167,11 @@ static void AddDrive(char *drive, struct stat *stbuf)
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
...@@ -192,21 +191,25 @@ static void CheckMounts(const char *mtab) ...@@ -192,21 +191,25 @@ static void CheckMounts(const char *mtab)
if ( mntfp != NULL ) { if ( mntfp != NULL ) {
char *tmp; char *tmp;
char *mnt_type; char *mnt_type;
size_t mnt_type_len;
char *mnt_dev; char *mnt_dev;
size_t mnt_dev_len;
while ( (mntent=getmntent(mntfp)) != NULL ) { while ( (mntent=getmntent(mntfp)) != NULL ) {
mnt_type = SDL_malloc(SDL_strlen(mntent->mnt_type) + 1); mnt_type_len = SDL_strlen(mntent->mnt_type) + 1;
mnt_type = SDL_stack_alloc(char, mnt_type_len);
if (mnt_type == NULL) if (mnt_type == NULL)
continue; /* maybe you'll get lucky next time. */ continue; /* maybe you'll get lucky next time. */
mnt_dev = SDL_malloc(SDL_strlen(mntent->mnt_fsname) + 1); mnt_dev_len = SDL_strlen(mntent->mnt_fsname) + 1;
mnt_dev = SDL_stack_alloc(char, mnt_dev_len);
if (mnt_dev == NULL) { if (mnt_dev == NULL) {
SDL_free(mnt_type); SDL_stack_free(mnt_type);
continue; continue;
} }
SDL_strcpy(mnt_type, mntent->mnt_type); SDL_strlcpy(mnt_type, mntent->mnt_type, mnt_type_len);
SDL_strcpy(mnt_dev, mntent->mnt_fsname); SDL_strlcpy(mnt_dev, mntent->mnt_fsname, mnt_dev_len);
/* Handle "supermount" filesystem mounts */ /* Handle "supermount" filesystem mounts */
if ( SDL_strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) { if ( SDL_strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
...@@ -242,8 +245,8 @@ static void CheckMounts(const char *mtab) ...@@ -242,8 +245,8 @@ static void CheckMounts(const char *mtab)
AddDrive(mnt_dev, &stbuf); AddDrive(mnt_dev, &stbuf);
} }
} }
SDL_free(mnt_dev); SDL_stack_free(mnt_dev);
SDL_free(mnt_type); SDL_stack_free(mnt_type);
} }
endmntent(mntfp); endmntent(mntfp);
} }
...@@ -277,9 +280,10 @@ int SDL_SYS_CDInit(void) ...@@ -277,9 +280,10 @@ int SDL_SYS_CDInit(void)
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if ( SDLcdrom != NULL ) { if ( SDLcdrom != NULL ) {
char *cdpath, *delim; char *cdpath, *delim;
cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_stack_alloc(char, len);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -298,7 +302,7 @@ int SDL_SYS_CDInit(void) ...@@ -298,7 +302,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
......
...@@ -115,12 +115,11 @@ static void AddDrive(char *drive, struct stat *stbuf) ...@@ -115,12 +115,11 @@ static void AddDrive(char *drive, struct stat *stbuf)
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
...@@ -161,9 +160,10 @@ int SDL_SYS_CDInit(void) ...@@ -161,9 +160,10 @@ int SDL_SYS_CDInit(void)
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if ( SDLcdrom != NULL ) { if ( SDLcdrom != NULL ) {
char *cdpath, *delim; char *cdpath, *delim;
cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_stack_alloc(char, len);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -179,7 +179,7 @@ int SDL_SYS_CDInit(void) ...@@ -179,7 +179,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
......
...@@ -94,13 +94,12 @@ for (i=0; i<SDL_numcds; i++) ...@@ -94,13 +94,12 @@ for (i=0; i<SDL_numcds; i++)
{ {
msp.ulNumber = i+1; msp.ulNumber = i+1;
mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0); mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0);
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(SysInfoRet)+1); SDL_cdlist[i] = SDL_strdup(SysInfoRet);
if ( SDL_cdlist[i] == NULL ) if ( SDL_cdlist[i] == NULL )
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
SDL_strcpy(SDL_cdlist[i], SysInfoRet);
} }
return(0); return(0);
} }
......
...@@ -119,13 +119,11 @@ static void AddDrive(char *drive, struct stat *stbuf) ...@@ -119,13 +119,11 @@ static void AddDrive(char *drive, struct stat *stbuf)
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
...@@ -174,9 +172,10 @@ int SDL_SYS_CDInit(void) ...@@ -174,9 +172,10 @@ int SDL_SYS_CDInit(void)
SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */
if ( SDLcdrom != NULL ) { if ( SDLcdrom != NULL ) {
char *cdpath, *delim; char *cdpath, *delim;
cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_stack_alloc(len);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -192,7 +191,7 @@ int SDL_SYS_CDInit(void) ...@@ -192,7 +191,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
...@@ -226,15 +225,6 @@ int SDL_SYS_CDInit(void) ...@@ -226,15 +225,6 @@ int SDL_SYS_CDInit(void)
#endif #endif
} }
} }
/*
SDLcdrom=SDL_malloc(sizeof(char) * 32);
SDL_strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
SDL_cdlist[0] = SDLcdrom;
stat(SDLcdrom, &stbuf);
SDL_cdmode[0] = stbuf.st_rdev;
SDL_numcds = 1;
*/
return (0); return (0);
} }
......
...@@ -124,13 +124,12 @@ static void AddDrive(char *drive, struct stat *stbuf) ...@@ -124,13 +124,12 @@ static void AddDrive(char *drive, struct stat *stbuf)
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if (SDL_cdlist[i] == NULL) if (SDL_cdlist[i] == NULL)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
} }
...@@ -169,11 +168,11 @@ int SDL_SYS_CDInit(void) ...@@ -169,11 +168,11 @@ int SDL_SYS_CDInit(void)
if ( SDLcdrom != NULL ) if ( SDLcdrom != NULL )
{ {
char *cdpath, *delim; char *cdpath, *delim;
size_t len = SDL_strlen(SDLcdrom)+1;
cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); cdpath = SDL_stack_alloc(len);
if (cdpath != NULL) if (cdpath != NULL)
{ {
SDL_strcpy(cdpath, SDLcdrom); SDL_strlcpy(cdpath, SDLcdrom, len);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = SDL_strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
...@@ -194,7 +193,7 @@ int SDL_SYS_CDInit(void) ...@@ -194,7 +193,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while (SDLcdrom); } while (SDLcdrom);
SDL_free(cdpath); SDL_stack_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
......
...@@ -63,12 +63,11 @@ static void AddDrive(char *drive) ...@@ -63,12 +63,11 @@ static void AddDrive(char *drive)
if ( SDL_numcds < MAX_DRIVES ) { if ( SDL_numcds < MAX_DRIVES ) {
/* Add this drive to our list */ /* Add this drive to our list */
i = SDL_numcds; i = SDL_numcds;
SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1); SDL_cdlist[i] = SDL_strdup(drive);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
SDL_strcpy(SDL_cdlist[i], drive);
++SDL_numcds; ++SDL_numcds;
#ifdef CDROM_DEBUG #ifdef CDROM_DEBUG
fprintf(stderr, "Added CD-ROM drive: %s\n", drive); fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
......
...@@ -554,7 +554,7 @@ int SDL_JoystickEventState(int state) ...@@ -554,7 +554,7 @@ int SDL_JoystickEventState(int state)
switch (state) { switch (state) {
case SDL_QUERY: case SDL_QUERY:
state = SDL_IGNORE; state = SDL_IGNORE;
for ( i=0; i<SDL_TABLESIZE(event_list); ++i ) { for ( i=0; i<SDL_arraysize(event_list); ++i ) {
state = SDL_EventState(event_list[i],SDL_QUERY); state = SDL_EventState(event_list[i],SDL_QUERY);
if ( state == SDL_ENABLE ) { if ( state == SDL_ENABLE ) {
break; break;
...@@ -562,7 +562,7 @@ int SDL_JoystickEventState(int state) ...@@ -562,7 +562,7 @@ int SDL_JoystickEventState(int state)
} }
break; break;
default: default:
for ( i=0; i<SDL_TABLESIZE(event_list); ++i ) { for ( i=0; i<SDL_arraysize(event_list); ++i ) {
SDL_EventState(event_list[i], state); SDL_EventState(event_list[i], state);
} }
break; break;
......
...@@ -179,17 +179,6 @@ struct joystick_hwdata { ...@@ -179,17 +179,6 @@ struct joystick_hwdata {
#endif #endif
}; };
static char *mystrdup(const char *string)
{
char *newstring;
newstring = (char *)SDL_malloc(SDL_strlen(string)+1);
if ( newstring ) {
SDL_strcpy(newstring, string);
}
return(newstring);
}
#ifndef NO_LOGICAL_JOYSTICKS #ifndef NO_LOGICAL_JOYSTICKS
...@@ -204,7 +193,7 @@ static int CountLogicalJoysticks(int max) ...@@ -204,7 +193,7 @@ static int CountLogicalJoysticks(int max)
name = SDL_SYS_JoystickName(i); name = SDL_SYS_JoystickName(i);
if (name) { if (name) {
for(j = 0; j < SDL_TABLESIZE(joystick_logicalmap); j++) { for(j = 0; j < SDL_arraysize(joystick_logicalmap); j++) {
if (!SDL_strcmp(name, joystick_logicalmap[j].name)) { if (!SDL_strcmp(name, joystick_logicalmap[j].name)) {
prev = i; prev = i;
...@@ -303,13 +292,12 @@ int SDL_SYS_JoystickInit(void) ...@@ -303,13 +292,12 @@ int SDL_SYS_JoystickInit(void)
/* First see if the user specified a joystick to use */ /* First see if the user specified a joystick to use */
if ( SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL ) { if ( SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL ) {
SDL_strncpy(path, SDL_getenv("SDL_JOYSTICK_DEVICE"), sizeof(path)); SDL_strlcpy(path, SDL_getenv("SDL_JOYSTICK_DEVICE"), sizeof(path));
path[sizeof(path)-1] = '\0';
if ( stat(path, &sb) == 0 ) { if ( stat(path, &sb) == 0 ) {
fd = open(path, O_RDONLY, 0); fd = open(path, O_RDONLY, 0);
if ( fd >= 0 ) { if ( fd >= 0 ) {
/* Assume the user knows what they're doing. */ /* Assume the user knows what they're doing. */
SDL_joylist[numjoysticks].fname =mystrdup(path); SDL_joylist[numjoysticks].fname = SDL_strdup(path);
if ( SDL_joylist[numjoysticks].fname ) { if ( SDL_joylist[numjoysticks].fname ) {
dev_nums[numjoysticks] = sb.st_rdev; dev_nums[numjoysticks] = sb.st_rdev;
++numjoysticks; ++numjoysticks;
...@@ -319,7 +307,7 @@ int SDL_SYS_JoystickInit(void) ...@@ -319,7 +307,7 @@ int SDL_SYS_JoystickInit(void)
} }
} }
for ( i=0; i<SDL_TABLESIZE(joydev_pattern); ++i ) { for ( i=0; i<SDL_arraysize(joydev_pattern); ++i ) {
for ( j=0; j < MAX_JOYSTICKS; ++j ) { for ( j=0; j < MAX_JOYSTICKS; ++j ) {
SDL_snprintf(path, SDL_arraysize(path), joydev_pattern[i], j); SDL_snprintf(path, SDL_arraysize(path), joydev_pattern[i], j);
...@@ -357,7 +345,7 @@ int SDL_SYS_JoystickInit(void) ...@@ -357,7 +345,7 @@ int SDL_SYS_JoystickInit(void)
close(fd); close(fd);
/* We're fine, add this joystick */ /* We're fine, add this joystick */
SDL_joylist[numjoysticks].fname =mystrdup(path); SDL_joylist[numjoysticks].fname = SDL_strdup(path);
if ( SDL_joylist[numjoysticks].fname ) { if ( SDL_joylist[numjoysticks].fname ) {
dev_nums[numjoysticks] = sb.st_rdev; dev_nums[numjoysticks] = sb.st_rdev;
++numjoysticks; ++numjoysticks;
...@@ -489,7 +477,7 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd) ...@@ -489,7 +477,7 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd)
} }
/* Special joystick support */ /* Special joystick support */
for ( i=0; i < SDL_TABLESIZE(special_joysticks); ++i ) { for ( i=0; i < SDL_arraysize(special_joysticks); ++i ) {
if ( SDL_strcmp(name, special_joysticks[i].name) == 0 ) { if ( SDL_strcmp(name, special_joysticks[i].name) == 0 ) {
joystick->naxes = special_joysticks[i].naxes; joystick->naxes = special_joysticks[i].naxes;
...@@ -503,7 +491,7 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd) ...@@ -503,7 +491,7 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd)
/* User environment joystick support */ /* User environment joystick support */
if ( (env = SDL_getenv("SDL_LINUX_JOYSTICK")) ) { if ( (env = SDL_getenv("SDL_LINUX_JOYSTICK")) ) {
SDL_strcpy(env_name, ""); *env_name = '\0';
if ( *env == '\'' && SDL_sscanf(env, "'%[^']s'", env_name) == 1 ) if ( *env == '\'' && SDL_sscanf(env, "'%[^']s'", env_name) == 1 )
env += SDL_strlen(env_name)+2; env += SDL_strlen(env_name)+2;
else if ( SDL_sscanf(env, "%s", env_name) == 1 ) else if ( SDL_sscanf(env, "%s", env_name) == 1 )
......
...@@ -165,7 +165,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) ...@@ -165,7 +165,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
return(-1); return(-1);
} }
SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
SDL_strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index)); SDL_strlcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index), SDL_arraysize(joystick->hwdata->name));
joystick->name = joystick->hwdata->name; joystick->name = joystick->hwdata->name;
ISpElementList_ExtractByKind( ISpElementList_ExtractByKind(
......
...@@ -214,7 +214,7 @@ if (numdevs > 0) ...@@ -214,7 +214,7 @@ if (numdevs > 0)
if (joycfg.buttons>=7) SYS_JoyData[0].buttoncalc[2]=((axis[2]->upper+axis[3]->centre)>>1); if (joycfg.buttons>=7) SYS_JoyData[0].buttoncalc[2]=((axis[2]->upper+axis[3]->centre)>>1);
if (joycfg.buttons>=8) SYS_JoyData[0].buttoncalc[3]=((axis[3]->upper+axis[3]->centre)>>1); if (joycfg.buttons>=8) SYS_JoyData[0].buttoncalc[3]=((axis[3]->upper+axis[3]->centre)>>1);
/* Intialize Joystick Name */ /* Intialize Joystick Name */
SDL_strcpy (SYS_JoyData[0].szDeviceName,joycfg.name); SDL_strlcpy (SYS_JoyData[0].szDeviceName,joycfg.name, SDL_arraysize(SYS_JoyData[0].szDeviceName));
} }
/* Default Init ... autoconfig */ /* Default Init ... autoconfig */
else else
......
...@@ -42,9 +42,10 @@ void *SDL_LoadFunction(void *handle, const char *name) ...@@ -42,9 +42,10 @@ void *SDL_LoadFunction(void *handle, const char *name)
{ {
void *symbol = dlsym(handle, name); void *symbol = dlsym(handle, name);
if ( symbol == NULL ) { if ( symbol == NULL ) {
char *_name = SDL_stack_alloc(char, 1+SDL_strlen(name)+1); size_t len = 1+SDL_strlen(name)+1;
char *_name = SDL_stack_alloc(char, len);
_name[0] = '_'; _name[0] = '_';
SDL_strcpy(&_name[1], name); SDL_strlcpy(&_name[1], name, len);
symbol = dlsym(handle, name); symbol = dlsym(handle, name);
SDL_stack_free(_name); SDL_stack_free(_name);
if ( symbol == NULL ) { if ( symbol == NULL ) {
......
...@@ -42,8 +42,7 @@ void *SDL_LoadObject(const char *sofile) ...@@ -42,8 +42,7 @@ void *SDL_LoadObject(const char *sofile)
OSErr error; OSErr error;
char psofile[512]; char psofile[512];
SDL_strncpy(psofile, sofile, SDL_TABLESIZE(psofile)); SDL_strlcpy(psofile, sofile, SDL_arraysize(psofile));
psofile[SDL_TABLESIZE(psofile)-1] = '\0';
error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch, error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch,
kLoadCFrag, &library_id, &mainAddr, errName); kLoadCFrag, &library_id, &mainAddr, errName);
switch (error) { switch (error) {
...@@ -80,8 +79,7 @@ void *SDL_LoadFunction(void *handle, const char *name) ...@@ -80,8 +79,7 @@ void *SDL_LoadFunction(void *handle, const char *name)
CFragConnectionID library_id = (CFragConnectionID)handle; CFragConnectionID library_id = (CFragConnectionID)handle;
char pname[512]; char pname[512];
SDL_strncpy(pname, name, SDL_TABLESIZE(pname)); SDL_strlcpy(pname, name, SDL_arraysize(pname));
pname[SDL_TABLESIZE(pname)-1] = '\0';
if ( FindSymbol(library_id, C2PStr(pname), if ( FindSymbol(library_id, C2PStr(pname),
(char **)&symbol, &class) != noErr ) { (char **)&symbol, &class) != noErr ) {
loaderror = "Symbol not found"; loaderror = "Symbol not found";
......
...@@ -281,7 +281,7 @@ static void error(const char *str, ...) ...@@ -281,7 +281,7 @@ static void error(const char *str, ...)
va_start(arg, str); va_start(arg, str);
tss = pthread_getspecific(dlerror_key); tss = pthread_getspecific(dlerror_key);
err_str = tss->errstr; err_str = tss->errstr;
SDL_strncpy(err_str, "dlcompat: ", ERR_STR_LEN); SDL_strlcpy(err_str, "dlcompat: ", ERR_STR_LEN);
vsnprintf(err_str + 10, ERR_STR_LEN - 10, str, arg); vsnprintf(err_str + 10, ERR_STR_LEN - 10, str, arg);
va_end(arg); va_end(arg);
debug("ERROR: %s\n", err_str); debug("ERROR: %s\n", err_str);
...@@ -620,18 +620,17 @@ static NSSymbol *search_linked_libs(const struct mach_header * mh, const char *s ...@@ -620,18 +620,17 @@ static NSSymbol *search_linked_libs(const struct mach_header * mh, const char *s
} }
/* Up to the caller to SDL_free() returned string */ /* Up to the caller to SDL_free() returned string */
static inline const char *dyld_error_str() static inline char *dyld_error_str()
{ {
NSLinkEditErrors dylder; NSLinkEditErrors dylder;
int dylderno; int dylderno;
const char *dylderrstr; const char *dylderrstr;
const char *dyldfile; const char *dyldfile;
const char* retStr = NULL; char* retStr = NULL;
NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
if (dylderrstr && SDL_strlen(dylderrstr)) if (dylderrstr && *dylderrstr)
{ {
retStr = SDL_malloc(SDL_strlen(dylderrstr) +1); retStr = SDL_strdup(dylderrstr);
SDL_strcpy((char*)retStr,dylderrstr);
} }
return retStr; return retStr;
} }
...@@ -645,7 +644,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr ...@@ -645,7 +644,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
void *caller = NULL; void *caller = NULL;
#endif #endif
const struct mach_header *caller_mh = 0; const struct mach_header *caller_mh = 0;
const char* savedErrorStr = NULL; char* savedErrorStr = NULL;
resetdlerror(); resetdlerror();
#ifndef RTLD_SELF #ifndef RTLD_SELF
#define RTLD_SELF ((void *) -3) #define RTLD_SELF ((void *) -3)
...@@ -734,9 +733,9 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr ...@@ -734,9 +733,9 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
else else
{ {
if (savedErrorStr) if (savedErrorStr)
SDL_free((char*)savedErrorStr); SDL_free(savedErrorStr);
savedErrorStr = SDL_malloc(256); savedErrorStr = SDL_malloc(256);
SDL_snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol); SDL_snprintf(savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol);
} }
} }
} }
...@@ -746,9 +745,9 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr ...@@ -746,9 +745,9 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
if (!savedErrorStr || !SDL_strlen(savedErrorStr)) if (!savedErrorStr || !SDL_strlen(savedErrorStr))
{ {
if (savedErrorStr) if (savedErrorStr)
SDL_free((char*)savedErrorStr); SDL_free(savedErrorStr);
savedErrorStr = SDL_malloc(256); savedErrorStr = SDL_malloc(256);
SDL_snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol); SDL_snprintf(savedErrorStr, 256,"Symbol \"%s\" not found",symbol);
} }
if (canSetError) if (canSetError)
{ {
...@@ -759,7 +758,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr ...@@ -759,7 +758,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
debug(savedErrorStr); debug(savedErrorStr);
} }
if (savedErrorStr) if (savedErrorStr)
SDL_free((char*)savedErrorStr); SDL_free(savedErrorStr);
return NULL; return NULL;
} }
return NSAddressOfSymbol(nssym); return NSAddressOfSymbol(nssym);
......
...@@ -47,7 +47,7 @@ void *SDL_LoadObject(const char *sofile) ...@@ -47,7 +47,7 @@ void *SDL_LoadObject(const char *sofile)
FORMAT_MESSAGE_FROM_SYSTEM), FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(), NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_TABLESIZE(errbuf), NULL); errbuf_t, SDL_arraysize(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf; loaderror = errbuf;
} }
...@@ -66,7 +66,7 @@ void *SDL_LoadObject(const char *sofile) ...@@ -66,7 +66,7 @@ void *SDL_LoadObject(const char *sofile)
FORMAT_MESSAGE_FROM_SYSTEM), FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(), NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf, SDL_TABLESIZE(errbuf), NULL); errbuf, SDL_arraysize(errbuf), NULL);
loaderror = errbuf; loaderror = errbuf;
} }
#endif #endif
...@@ -97,7 +97,7 @@ void *SDL_LoadFunction(void *handle, const char *name) ...@@ -97,7 +97,7 @@ void *SDL_LoadFunction(void *handle, const char *name)
FORMAT_MESSAGE_FROM_SYSTEM), FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(), NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_TABLESIZE(errbuf), NULL); errbuf_t, SDL_arraysize(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf; loaderror = errbuf;
} }
...@@ -114,7 +114,7 @@ void *SDL_LoadFunction(void *handle, const char *name) ...@@ -114,7 +114,7 @@ void *SDL_LoadFunction(void *handle, const char *name)
FORMAT_MESSAGE_FROM_SYSTEM), FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(), NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf, SDL_TABLESIZE(errbuf), NULL); errbuf, SDL_arraysize(errbuf), NULL);
loaderror = errbuf; loaderror = errbuf;
} }
#endif #endif
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
# define fopen _wfopen # define fopen _wfopen
# define freopen _wfreopen # define freopen _wfreopen
# define remove(x) DeleteFile(x) # define remove(x) DeleteFile(x)
# define strcat wcscat
#else #else
# define DIR_SEPERATOR TEXT("/") # define DIR_SEPERATOR TEXT("/")
# include <direct.h> # include <direct.h>
...@@ -208,8 +207,7 @@ int console_main(int argc, char *argv[]) ...@@ -208,8 +207,7 @@ int console_main(int argc, char *argv[])
if ( bufp == NULL ) { if ( bufp == NULL ) {
return OutOfMemory(); return OutOfMemory();
} }
SDL_strncpy(bufp, appname, n); SDL_strlcpy(bufp, appname, n);
bufp[n] = '\0';
appname = bufp; appname = bufp;
/* Load SDL dynamic link library */ /* Load SDL dynamic link library */
...@@ -259,10 +257,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) ...@@ -259,10 +257,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
int nLen; int nLen;
#else #else
char *bufp; char *bufp;
size_t nLen;
#endif #endif
#ifndef NO_STDIO_REDIRECT #ifndef NO_STDIO_REDIRECT
FILE *newfp; FILE *newfp;
#endif #endif
int retval;
/* Start up DDHELP.EXE before opening any files, so DDHELP doesn't /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't
keep them open. This is a hack.. hopefully it will be fixed keep them open. This is a hack.. hopefully it will be fixed
...@@ -274,14 +274,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) ...@@ -274,14 +274,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
} }
#ifndef NO_STDIO_REDIRECT #ifndef NO_STDIO_REDIRECT
pathlen = GetModuleFileName(NULL, path, SDL_TABLESIZE(path)); pathlen = GetModuleFileName(NULL, path, SDL_arraysize(path));
while ( pathlen > 0 && path[pathlen] != '\\' ) { while ( pathlen > 0 && path[pathlen] != '\\' ) {
--pathlen; --pathlen;
} }
path[pathlen] = '\0'; path[pathlen] = '\0';
SDL_strcpy( stdoutPath, path ); SDL_strlcpy( stdoutPath, path, SDL_arraysize(stdoutPath) );
SDL_strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE ); SDL_strlcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
/* Redirect standard input and standard output */ /* Redirect standard input and standard output */
newfp = freopen(stdoutPath, TEXT("w"), stdout); newfp = freopen(stdoutPath, TEXT("w"), stdout);
...@@ -299,8 +299,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) ...@@ -299,8 +299,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
} }
#endif /* _WIN32_WCE */ #endif /* _WIN32_WCE */
SDL_strcpy( stderrPath, path ); SDL_strlcpy( stderrPath, path, SDL_arraysize(stderrPath) );
SDL_strcat( stderrPath, DIR_SEPERATOR STDERR_FILE ); SDL_strlcat( stderrPath, DIR_SEPERATOR STDERR_FILE, SDL_arraysize(stderrPath) );
newfp = freopen(stderrPath, TEXT("w"), stderr); newfp = freopen(stderrPath, TEXT("w"), stderr);
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
...@@ -328,7 +328,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) ...@@ -328,7 +328,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
wcscpy (bufp+wcslen(bufp), TEXT("\" ")); wcscpy (bufp+wcslen(bufp), TEXT("\" "));
wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp)); wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp));
nLen = wcslen(bufp)+1; nLen = wcslen(bufp)+1;
cmdline = (char *)alloca(nLen); cmdline = SDL_stack_alloc(wchar_t, nLen);
if ( cmdline == NULL ) { if ( cmdline == NULL ) {
return OutOfMemory(); return OutOfMemory();
} }
...@@ -336,21 +336,26 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) ...@@ -336,21 +336,26 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#else #else
/* Grab the command line (use alloca() on Windows) */ /* Grab the command line (use alloca() on Windows) */
bufp = GetCommandLine(); bufp = GetCommandLine();
cmdline = (char *)alloca(SDL_strlen(bufp)+1); nLen = SDL_strlen(bufp)+1;
cmdline = SDL_stack_alloc(char, nLen);
if ( cmdline == NULL ) { if ( cmdline == NULL ) {
return OutOfMemory(); return OutOfMemory();
} }
SDL_strcpy(cmdline, bufp); SDL_strlcpy(cmdline, bufp, nLen);
#endif #endif
/* Parse it into argv and argc */ /* Parse it into argv and argc */
argc = ParseCommandLine(cmdline, NULL); argc = ParseCommandLine(cmdline, NULL);
argv = (char **)alloca((argc+1)*(sizeof *argv)); argv = SDL_stack_alloc(char*, argc+1);
if ( argv == NULL ) { if ( argv == NULL ) {
return OutOfMemory(); return OutOfMemory();
} }
ParseCommandLine(cmdline, argv); ParseCommandLine(cmdline, argv);
/* Run the main program (after a little SDL initialization) */ /* Run the main program (after a little SDL initialization) */
return(console_main(argc, argv)); retval = console_main(argc, argv);
SDL_stack_free(cmdline);
SDL_stack_free(argv);
return retval;
} }
...@@ -53,7 +53,7 @@ int SDL_putenv(const char *variable) ...@@ -53,7 +53,7 @@ int SDL_putenv(const char *variable)
SDL_envmem = newmem; SDL_envmem = newmem;
SDL_envmemlen = bufferlen; SDL_envmemlen = bufferlen;
} }
SDL_strcpy(SDL_envmem, variable); SDL_strlcpy(SDL_envmem, variable, bufferlen);
value = SDL_envmem + (sep - variable); value = SDL_envmem + (sep - variable);
*value++ = '\0'; *value++ = '\0';
if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) { if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) {
...@@ -111,11 +111,10 @@ int SDL_putenv(const char *variable) ...@@ -111,11 +111,10 @@ int SDL_putenv(const char *variable)
} }
/* Allocate memory for the variable */ /* Allocate memory for the variable */
new_variable = (char *)SDL_malloc(SDL_strlen(variable)+1); new_variable = SDL_strdup(variable);
if ( ! new_variable ) { if ( ! new_variable ) {
return(-1); return(-1);
} }
SDL_strcpy(new_variable, variable);
/* Actually put it into the environment */ /* Actually put it into the environment */
added = 0; added = 0;
......
...@@ -294,39 +294,38 @@ size_t SDL_strlen(const char *string) ...@@ -294,39 +294,38 @@ size_t SDL_strlen(const char *string)
} }
#endif #endif
#ifndef HAVE_STRCPY #ifndef HAVE_STRLCPY
char *SDL_strcpy(char *dst, const char *src) size_t SDL_strlcpy(char *dst, const char *src, size_t maxlen)
{ {
char *dstp = dst; size_t srclen = SDL_strlen(src);
while ( *src ) { if ( maxlen > 0 ) {
*dstp++ = *src++; size_t len = SDL_min(srclen, maxlen-1);
SDL_memcpy(dst, src, len);
dst[len] = '\0';
} }
*dstp = '\0'; return srclen;
return dst;
} }
#endif #endif
#ifndef HAVE_STRNCPY #ifndef HAVE_STRLCAT
char *SDL_strncpy(char *dst, const char *src, size_t maxlen) size_t SDL_strlcat(char *dst, const char *src, size_t maxlen)
{ {
char *dstp = dst; size_t dstlen = SDL_strlen(dst);
while ( maxlen-- && *src ) { size_t srclen = SDL_strlen(src);
*dstp++ = *src++; if ( dstlen < maxlen ) {
SDL_strlcpy(dst+dstlen, src, maxlen-dstlen);
} }
*dstp = '\0'; return dstlen+srclen;
return dst;
} }
#endif #endif
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
char *SDL_strdup(const char *string) char *SDL_strdup(const char *string)
{ {
size_t len = SDL_strlen(string); size_t len = SDL_strlen(string)+1;
char *newstr = SDL_malloc(len+1); char *newstr = SDL_malloc(len);
if ( newstr ) { if ( newstr ) {
SDL_strcpy(newstr, string); SDL_strlcpy(newstr, string, len);
} }
return newstr; return newstr;
} }
...@@ -912,7 +911,7 @@ static size_t SDL_PrintLong(char *text, long value, int radix, size_t maxlen) ...@@ -912,7 +911,7 @@ static size_t SDL_PrintLong(char *text, long value, int radix, size_t maxlen)
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
SDL_strncpy(text, num, size); SDL_strlcpy(text, num, size);
return size; return size;
} }
...@@ -926,7 +925,7 @@ static size_t SDL_PrintUnsignedLong(char *text, unsigned long value, int radix, ...@@ -926,7 +925,7 @@ static size_t SDL_PrintUnsignedLong(char *text, unsigned long value, int radix,
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
SDL_strncpy(text, num, size); SDL_strlcpy(text, num, size);
return size; return size;
} }
...@@ -941,7 +940,7 @@ static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxl ...@@ -941,7 +940,7 @@ static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxl
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
SDL_strncpy(text, num, size); SDL_strlcpy(text, num, size);
return size; return size;
} }
...@@ -955,7 +954,7 @@ static size_t SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, siz ...@@ -955,7 +954,7 @@ static size_t SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, siz
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
SDL_strncpy(text, num, size); SDL_strlcpy(text, num, size);
return size; return size;
} }
......
...@@ -283,8 +283,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) ...@@ -283,8 +283,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
char *SDL_VideoDriverName(char *namebuf, int maxlen) char *SDL_VideoDriverName(char *namebuf, int maxlen)
{ {
if ( current_video != NULL ) { if ( current_video != NULL ) {
SDL_strncpy(namebuf, current_video->name, maxlen-1); SDL_strlcpy(namebuf, current_video->name, maxlen);
namebuf[maxlen-1] = '\0';
return(namebuf); return(namebuf);
} }
return(NULL); return(NULL);
...@@ -1664,19 +1663,13 @@ void SDL_WM_SetCaption (const char *title, const char *icon) ...@@ -1664,19 +1663,13 @@ void SDL_WM_SetCaption (const char *title, const char *icon)
if ( video->wm_title ) { if ( video->wm_title ) {
SDL_free(video->wm_title); SDL_free(video->wm_title);
} }
video->wm_title = (char *)SDL_malloc(SDL_strlen(title)+1); video->wm_title = SDL_strdup(title);
if ( video->wm_title != NULL ) {
SDL_strcpy(video->wm_title, title);
}
} }
if ( icon ) { if ( icon ) {
if ( video->wm_icon ) { if ( video->wm_icon ) {
SDL_free(video->wm_icon); SDL_free(video->wm_icon);
} }
video->wm_icon = (char *)SDL_malloc(SDL_strlen(icon)+1); video->wm_icon = SDL_strdup(icon);
if ( video->wm_icon != NULL ) {
SDL_strcpy(video->wm_icon, icon);
}
} }
if ( (title || icon) && (video->SetCaption != NULL) ) { if ( (title || icon) && (video->SetCaption != NULL) ) {
video->SetCaption(this, video->wm_title,video->wm_icon); video->SetCaption(this, video->wm_title,video->wm_icon);
......
...@@ -234,8 +234,7 @@ SDL_NAME(XvQueryAdaptors)( ...@@ -234,8 +234,7 @@ SDL_NAME(XvQueryAdaptors)(
SyncHandle(); SyncHandle();
return(XvBadAlloc); return(XvBadAlloc);
} }
(void)strncpy(name, u.string, size); SDL_strlcpy(name, u.string, size);
name[size] = '\0';
pa->name = name; pa->name = name;
u.buffer += (size + 3) & ~3; u.buffer += (size + 3) & ~3;
...@@ -386,8 +385,7 @@ SDL_NAME(XvQueryEncodings)( ...@@ -386,8 +385,7 @@ SDL_NAME(XvQueryEncodings)(
SyncHandle(); SyncHandle();
return(XvBadAlloc); return(XvBadAlloc);
} }
strncpy(name, u.string, size); SDL_strlcpy(name, u.string, size);
name[size] = '\0';
pe->name = name; pe->name = name;
pe++; pe++;
......
...@@ -36,6 +36,8 @@ in this Software without prior written authorization from The Open Group. ...@@ -36,6 +36,8 @@ in this Software without prior written authorization from The Open Group.
#ifndef _EXTUTIL_H_ #ifndef _EXTUTIL_H_
#define _EXTUTIL_H_ #define _EXTUTIL_H_
#include "SDL_stdinc.h" /* For portable string functions */
#include <X11/extensions/Xext.h> #include <X11/extensions/Xext.h>
/* /*
...@@ -212,7 +214,7 @@ char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \ ...@@ -212,7 +214,7 @@ char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
code -= codes->first_error; \ code -= codes->first_error; \
if (code >= 0 && code < nerr) { \ if (code >= 0 && code < nerr) { \
char tmp[256]; \ char tmp[256]; \
sprintf (tmp, "%s.%d", extname, code); \ SDL_snprintf (tmp, SDL_arraysize(tmp), "%s.%d", extname, code); \
pXGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \ pXGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
return buf; \ return buf; \
} \ } \
......
...@@ -122,7 +122,7 @@ void AA_InitOSKeymap(_THIS) ...@@ -122,7 +122,7 @@ void AA_InitOSKeymap(_THIS)
const char *std; const char *std;
/* Initialize the AAlib key translation table */ /* Initialize the AAlib key translation table */
for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) for ( i=0; i<SDL_arraysize(keymap); ++i )
keymap[i] = SDLK_UNKNOWN; keymap[i] = SDLK_UNKNOWN;
keymap[AA_ESC] = SDLK_ESCAPE; keymap[AA_ESC] = SDLK_ESCAPE;
......
...@@ -219,10 +219,10 @@ int SDL_AtariGL_LoadLibrary(_THIS, const char *path) ...@@ -219,10 +219,10 @@ int SDL_AtariGL_LoadLibrary(_THIS, const char *path)
this->gl_config.dll_handle = handle; this->gl_config.dll_handle = handle;
if ( path ) { if ( path ) {
SDL_strncpy(this->gl_config.driver_path, path, SDL_strlcpy(this->gl_config.driver_path, path,
sizeof(this->gl_config.driver_path)-1); SDL_arraysize(this->gl_config.driver_path));
} else { } else {
SDL_strcpy(this->gl_config.driver_path, ""); *this->gl_config.driver_path = '\0';
} }
#endif #endif
......
...@@ -301,7 +301,7 @@ void amiga_InitKeymap(void) ...@@ -301,7 +301,7 @@ void amiga_InitKeymap(void)
int i; int i;
/* Map the miscellaneous keys */ /* Map the miscellaneous keys */
for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i ) for ( i=0; i<SDL_arraysize(MISC_keymap); ++i )
MISC_keymap[i] = SDLK_UNKNOWN; MISC_keymap[i] = SDLK_UNKNOWN;
/* These X keysyms have 0xFF as the high byte */ /* These X keysyms have 0xFF as the high byte */
......
...@@ -90,7 +90,7 @@ void DirectFB_InitOSKeymap (_THIS) ...@@ -90,7 +90,7 @@ void DirectFB_InitOSKeymap (_THIS)
int i; int i;
/* Initialize the DirectFB key translation table */ /* Initialize the DirectFB key translation table */
for (i=0; i<SDL_TABLESIZE(keymap); ++i) for (i=0; i<SDL_arraysize(keymap); ++i)
keymap[i] = SDLK_UNKNOWN; keymap[i] = SDLK_UNKNOWN;
keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a; keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a;
......
...@@ -994,7 +994,7 @@ void FB_InitOSKeymap(_THIS) ...@@ -994,7 +994,7 @@ void FB_InitOSKeymap(_THIS)
/* Initialize the Linux key translation table */ /* Initialize the Linux key translation table */
/* First get the ascii keys and others not well handled */ /* First get the ascii keys and others not well handled */
for (i=0; i<SDL_TABLESIZE(keymap); ++i) { for (i=0; i<SDL_arraysize(keymap); ++i) {
switch(i) { switch(i) {
/* These aren't handled by the x86 kernel keymapping (?) */ /* These aren't handled by the x86 kernel keymapping (?) */
case SCANCODE_PRINTSCREEN: case SCANCODE_PRINTSCREEN:
...@@ -1033,7 +1033,7 @@ void FB_InitOSKeymap(_THIS) ...@@ -1033,7 +1033,7 @@ void FB_InitOSKeymap(_THIS)
break; break;
} }
} }
for (i=0; i<SDL_TABLESIZE(keymap); ++i) { for (i=0; i<SDL_arraysize(keymap); ++i) {
switch(keymap_temp[i]) { switch(keymap_temp[i]) {
case K_F1: keymap[i] = SDLK_F1; break; case K_F1: keymap[i] = SDLK_F1; break;
case K_F2: keymap[i] = SDLK_F2; break; case K_F2: keymap[i] = SDLK_F2; break;
......
...@@ -123,7 +123,7 @@ void GGI_InitOSKeymap(_THIS) ...@@ -123,7 +123,7 @@ void GGI_InitOSKeymap(_THIS)
int i; int i;
/* Initialize the GGI key translation table */ /* Initialize the GGI key translation table */
for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) for ( i=0; i<SDL_arraysize(keymap); ++i )
keymap[i] = SDLK_UNKNOWN; keymap[i] = SDLK_UNKNOWN;
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
......
...@@ -457,7 +457,7 @@ void Mac_InitOSKeymap(_THIS) ...@@ -457,7 +457,7 @@ void Mac_InitOSKeymap(_THIS)
int world = SDLK_WORLD_0; int world = SDLK_WORLD_0;
/* Map the MAC keysyms */ /* Map the MAC keysyms */
for ( i=0; i<SDL_TABLESIZE(MAC_keymap); ++i ) for ( i=0; i<SDL_arraysize(MAC_keymap); ++i )
MAC_keymap[i] = SDLK_UNKNOWN; MAC_keymap[i] = SDLK_UNKNOWN;
/* Defined MAC_* constants */ /* Defined MAC_* constants */
......
...@@ -355,7 +355,7 @@ static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice) ...@@ -355,7 +355,7 @@ static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice)
if ( DSpContext_GetAttributes (context, &attributes) != noErr ) if ( DSpContext_GetAttributes (context, &attributes) != noErr )
return NULL; return NULL;
for ( i = 0; i < SDL_TABLESIZE(temp_list); i++ ) { for ( i = 0; i < SDL_arraysize(temp_list); i++ ) {
width = attributes.displayWidth; width = attributes.displayWidth;
height = attributes.displayHeight; height = attributes.displayHeight;
......
...@@ -41,7 +41,7 @@ void NX_InitOSKeymap (_THIS) ...@@ -41,7 +41,7 @@ void NX_InitOSKeymap (_THIS)
Dprintf ("enter NX_InitOSKeymap\n") ; Dprintf ("enter NX_InitOSKeymap\n") ;
// Map the nanox scancodes to SDL keysyms // Map the nanox scancodes to SDL keysyms
for (i = 0; i < SDL_TABLESIZE (NX_NONASCII_keymap); ++ i) for (i = 0; i < SDL_arraysize (NX_NONASCII_keymap); ++ i)
NX_NONASCII_keymap [i] = SDLK_UNKNOWN ; NX_NONASCII_keymap [i] = SDLK_UNKNOWN ;
NX_NONASCII_keymap [MWKEY_LEFT & 0xFF] = SDLK_LEFT ; NX_NONASCII_keymap [MWKEY_LEFT & 0xFF] = SDLK_LEFT ;
......
...@@ -442,13 +442,13 @@ void ph_InitKeymap(void) ...@@ -442,13 +442,13 @@ void ph_InitKeymap(void)
int i; int i;
/* Odd keys used in international keyboards */ /* Odd keys used in international keyboards */
for (i=0; i<SDL_TABLESIZE(ODD_keymap); ++i) for (i=0; i<SDL_arraysize(ODD_keymap); ++i)
{ {
ODD_keymap[i] = SDLK_UNKNOWN; ODD_keymap[i] = SDLK_UNKNOWN;
} }
/* Map the miscellaneous keys */ /* Map the miscellaneous keys */
for (i=0; i<SDL_TABLESIZE(MISC_keymap); ++i) for (i=0; i<SDL_arraysize(MISC_keymap); ++i)
{ {
MISC_keymap[i] = SDLK_UNKNOWN; MISC_keymap[i] = SDLK_UNKNOWN;
} }
......
...@@ -123,7 +123,7 @@ int ph_GL_LoadLibrary(_THIS, const char* path) ...@@ -123,7 +123,7 @@ int ph_GL_LoadLibrary(_THIS, const char* path)
this->gl_config.dll_handle = handle; this->gl_config.dll_handle = handle;
this->gl_config.driver_loaded = 1; this->gl_config.driver_loaded = 1;
SDL_strncpy(this->gl_config.driver_path, path, sizeof(this->gl_config.driver_path)-1); SDL_strlcpy(this->gl_config.driver_path, path, SDL_arraysize(this->gl_config.driver_path));
return 0; return 0;
} }
......
...@@ -822,7 +822,7 @@ void GS_InitOSKeymap(_THIS) ...@@ -822,7 +822,7 @@ void GS_InitOSKeymap(_THIS)
/* Initialize the Linux key translation table */ /* Initialize the Linux key translation table */
/* First get the ascii keys and others not well handled */ /* First get the ascii keys and others not well handled */
for (i=0; i<SDL_TABLESIZE(keymap); ++i) { for (i=0; i<SDL_arraysize(keymap); ++i) {
switch(i) { switch(i) {
/* These aren't handled by the x86 kernel keymapping (?) */ /* These aren't handled by the x86 kernel keymapping (?) */
case SCANCODE_PRINTSCREEN: case SCANCODE_PRINTSCREEN:
...@@ -861,7 +861,7 @@ void GS_InitOSKeymap(_THIS) ...@@ -861,7 +861,7 @@ void GS_InitOSKeymap(_THIS)
break; break;
} }
} }
for (i=0; i<SDL_TABLESIZE(keymap); ++i) { for (i=0; i<SDL_arraysize(keymap); ++i) {
switch(keymap_temp[i]) { switch(keymap_temp[i]) {
case K_F1: keymap[i] = SDLK_F1; break; case K_F1: keymap[i] = SDLK_F1; break;
case K_F2: keymap[i] = SDLK_F2; break; case K_F2: keymap[i] = SDLK_F2; break;
......
...@@ -657,8 +657,7 @@ static void FULLSCREEN_EnableEscape() ...@@ -657,8 +657,7 @@ static void FULLSCREEN_EnableEscape()
/** Store caption in case this is called before we create a window */ /** Store caption in case this is called before we create a window */
void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon) void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon)
{ {
SDL_strncpy(this->hidden->title, title, 255); SDL_strlcpy(this->hidden->title, title, SDL_arraysize(this->hidden->title));
this->hidden->title[255] = 0;
} }
/* Set screen mode /* Set screen mode
......
...@@ -101,7 +101,7 @@ void RISCOS_InitOSKeymap(_THIS) ...@@ -101,7 +101,7 @@ void RISCOS_InitOSKeymap(_THIS)
int i; int i;
/* Map the VK keysyms */ /* Map the VK keysyms */
for ( i=0; i<SDL_TABLESIZE(RO_keymap); ++i ) for ( i=0; i<SDL_arraysize(RO_keymap); ++i )
RO_keymap[i] = SDLK_UNKNOWN; RO_keymap[i] = SDLK_UNKNOWN;
RO_keymap[3] = SDLK_LSHIFT; RO_keymap[3] = SDLK_LSHIFT;
......
...@@ -57,7 +57,7 @@ extern int mouseInWindow; /* Mouse is in WIMP window */ ...@@ -57,7 +57,7 @@ extern int mouseInWindow; /* Mouse is in WIMP window */
/* Local function */ /* Local function */
static int RISCOS_GetTaskName(char *task_name); static int RISCOS_GetTaskName(char *task_name, size_t maxlen);
/* Uncomment next line to copy mode changes/restores to stderr */ /* Uncomment next line to copy mode changes/restores to stderr */
/* #define DUMP_MODE */ /* #define DUMP_MODE */
...@@ -91,7 +91,7 @@ int RISCOS_InitTask() ...@@ -91,7 +91,7 @@ int RISCOS_InitTask()
_kernel_swi_regs regs; _kernel_swi_regs regs;
int messages[4]; int messages[4];
if (RISCOS_GetTaskName(task_name) == 0) return 0; if (RISCOS_GetTaskName(task_name, SDL_arraysize(task_name)) == 0) return 0;
messages[0] = 9; /* Palette changed */ messages[0] = 9; /* Palette changed */
messages[1] = 0x400c1; /* Mode changed */ messages[1] = 0x400c1; /* Mode changed */
...@@ -177,7 +177,7 @@ void RISCOS_ExitTask() ...@@ -177,7 +177,7 @@ void RISCOS_ExitTask()
***************************************************************************/ ***************************************************************************/
int RISCOS_GetTaskName(char *task_name) int RISCOS_GetTaskName(char *task_name, size_t maxlen)
{ {
_kernel_swi_regs regs; _kernel_swi_regs regs;
...@@ -187,11 +187,12 @@ int RISCOS_GetTaskName(char *task_name) ...@@ -187,11 +187,12 @@ int RISCOS_GetTaskName(char *task_name)
if (_kernel_swi(OS_GetEnv, &regs, &regs) == 0) if (_kernel_swi(OS_GetEnv, &regs, &regs) == 0)
{ {
char *command_line = (char *)regs.r[0]; char *command_line = (char *)regs.r[0];
char *buffer = SDL_malloc(SDL_strlen(command_line)+1); size_t len = SDL_strlen(command_line)+1;
char *buffer = SDL_stack_alloc(char, len);
char *env_var; char *env_var;
char *p; char *p;
SDL_strcpy(buffer, command_line); SDL_strlcpy(buffer, command_line, len);
p = SDL_strchr(buffer, ' '); p = SDL_strchr(buffer, ' ');
if (p) *p = 0; if (p) *p = 0;
p = SDL_strrchr(buffer, '.'); p = SDL_strrchr(buffer, '.');
...@@ -217,45 +218,45 @@ int RISCOS_GetTaskName(char *task_name) ...@@ -217,45 +218,45 @@ int RISCOS_GetTaskName(char *task_name)
if (*p) if (*p)
{ {
/* Read variables that effect the RISC OS SDL engine for this task */ /* Read variables that effect the RISC OS SDL engine for this task */
env_var = SDL_malloc(SDL_strlen(p) + 18); /* 18 is larger than the biggest variable name */ len = SDL_strlen(p) + 18; /* 18 is larger than the biggest variable name */
env_var = SDL_stack_alloc(char, len);
if (env_var) if (env_var)
{ {
char *env_val; char *env_val;
/* See if a variable of form SDL$<dirname>$TaskName exists */ /* See if a variable of form SDL$<dirname>$TaskName exists */
SDL_strcpy(env_var, "SDL$"); SDL_strlcpy(env_var, "SDL$", len);
strcat(env_var, p); SDL_strlcat(env_var, p, len);
strcat(env_var, "$TaskName"); SDL_strlcat(env_var, "$TaskName", len);
env_val = SDL_getenv(env_var); env_val = SDL_getenv(env_var);
if (env_val) SDL_strncpy(task_name, env_val, 31); if (env_val) SDL_strlcpy(task_name, env_val, maxlen);
SDL_strcpy(env_var, "SDL$"); SDL_strlcpy(env_var, "SDL$", len);
strcat(env_var, p); SDL_strlcat(env_var, p, len);
strcat(env_var, "$BackBuffer"); SDL_strlcat(env_var, "$BackBuffer", len);
env_val = SDL_getenv(env_var); env_val = SDL_getenv(env_var);
if (env_val) riscos_backbuffer = atoi(env_val); if (env_val) riscos_backbuffer = atoi(env_val);
SDL_strcpy(env_var, "SDL$"); SDL_strlcpy(env_var, "SDL$", len);
strcat(env_var, p); SDL_strlcat(env_var, p, len);
strcat(env_var, "$CloseAction"); SDL_strlcat(env_var, "$CloseAction", len);
env_val = SDL_getenv(env_var); env_val = SDL_getenv(env_var);
if (env_val && SDL_strcmp(env_val,"0") == 0) riscos_closeaction = 0; if (env_val && SDL_strcmp(env_val,"0") == 0) riscos_closeaction = 0;
SDL_free(env_var); SDL_stack_free(env_var);
} }
if (task_name[0] == 0) SDL_strncpy(task_name, p, 31); if (!*task_name) SDL_strlcpy(task_name, p, maxlen);
task_name[31] = 0;
} }
SDL_free(buffer); SDL_stack_free(buffer);
} }
if (task_name[0] == 0) SDL_strcpy(task_name, "SDL Task"); if (task_name[0] == 0) SDL_strlcpy(task_name, "SDL Task", maxlen);
return 1; return 1;
} }
......
...@@ -384,8 +384,7 @@ void WIMP_SetWMCaption(_THIS, const char *title, const char *icon) ...@@ -384,8 +384,7 @@ void WIMP_SetWMCaption(_THIS, const char *title, const char *icon)
{ {
_kernel_swi_regs regs; _kernel_swi_regs regs;
SDL_strncpy(this->hidden->title, title, 255); SDL_strlcpy(this->hidden->title, title, SDL_arraysize(this->hidden->title));
this->hidden->title[255] = 0;
if (RISCOS_GetWimpVersion() < 380) if (RISCOS_GetWimpVersion() < 380)
{ {
......
...@@ -210,7 +210,7 @@ void SVGA_InitOSKeymap(_THIS) ...@@ -210,7 +210,7 @@ void SVGA_InitOSKeymap(_THIS)
int i; int i;
/* Initialize the BeOS key translation table */ /* Initialize the BeOS key translation table */
for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) for ( i=0; i<SDL_arraysize(keymap); ++i )
keymap[i] = SDLK_UNKNOWN; keymap[i] = SDLK_UNKNOWN;
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
......
...@@ -143,7 +143,7 @@ void VGL_InitOSKeymap(_THIS) ...@@ -143,7 +143,7 @@ void VGL_InitOSKeymap(_THIS)
int i; int i;
/* Initialize the BeOS key translation table */ /* Initialize the BeOS key translation table */
for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) for ( i=0; i<SDL_arraysize(keymap); ++i )
keymap[i] = SDLK_UNKNOWN; keymap[i] = SDLK_UNKNOWN;
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
......
...@@ -702,13 +702,13 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst) ...@@ -702,13 +702,13 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
if ( name ) { if ( name ) {
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
/* WinCE uses the UNICODE version */ /* WinCE uses the UNICODE version */
int nLen = SDL_strlen(name)+1; size_t nLen = SDL_strlen(name)+1;
SDL_Appname = SDL_malloc(nLen*2); SDL_Appname = SDL_malloc(nLen*2);
MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen); MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
#else #else
int nLen = SDL_strlen(name)+1; size_t nLen = SDL_strlen(name)+1;
SDL_Appname = SDL_malloc(nLen); SDL_Appname = SDL_malloc(nLen);
SDL_strcpy(SDL_Appname, name); SDL_strlcpy(SDL_Appname, name, nLen);
#endif /* _WIN32_WCE */ #endif /* _WIN32_WCE */
SDL_Appstyle = style; SDL_Appstyle = style;
SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); SDL_Instance = hInst ? hInst : SDL_GetModuleHandle();
......
...@@ -551,7 +551,7 @@ int WIN_GL_LoadLibrary(_THIS, const char* path) ...@@ -551,7 +551,7 @@ int WIN_GL_LoadLibrary(_THIS, const char* path)
} }
this->gl_config.dll_handle = handle; this->gl_config.dll_handle = handle;
SDL_strcpy(this->gl_config.driver_path, path); SDL_strlcpy(this->gl_config.driver_path, path, SDL_arraysize(this->gl_config.driver_path));
this->gl_config.driver_loaded = 1; this->gl_config.driver_loaded = 1;
return 0; return 0;
} }
......
...@@ -251,7 +251,7 @@ void DIB_InitOSKeymap(_THIS) ...@@ -251,7 +251,7 @@ void DIB_InitOSKeymap(_THIS)
int i; int i;
/* Map the VK keysyms */ /* Map the VK keysyms */
for ( i=0; i<SDL_TABLESIZE(VK_keymap); ++i ) for ( i=0; i<SDL_arraysize(VK_keymap); ++i )
VK_keymap[i] = SDLK_UNKNOWN; VK_keymap[i] = SDLK_UNKNOWN;
VK_keymap[VK_BACK] = SDLK_BACKSPACE; VK_keymap[VK_BACK] = SDLK_BACKSPACE;
......
...@@ -703,7 +703,7 @@ void DX5_InitOSKeymap(_THIS) ...@@ -703,7 +703,7 @@ void DX5_InitOSKeymap(_THIS)
int i; int i;
/* Map the DIK scancodes to SDL keysyms */ /* Map the DIK scancodes to SDL keysyms */
for ( i=0; i<SDL_TABLESIZE(DIK_keymap); ++i ) for ( i=0; i<SDL_arraysize(DIK_keymap); ++i )
DIK_keymap[i] = 0; DIK_keymap[i] = 0;
/* Defined DIK_* constants */ /* Defined DIK_* constants */
......
...@@ -100,7 +100,7 @@ static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) ...@@ -100,7 +100,7 @@ static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
keysym->sym = SDLK_UNKNOWN; keysym->sym = SDLK_UNKNOWN;
keysym->mod = KMOD_NONE; keysym->mod = KMOD_NONE;
if (scancode < SDL_TABLESIZE(keymap)) if (scancode < SDL_arraysize(keymap))
keysym->sym = keymap[scancode]; keysym->sym = keymap[scancode];
if (keysym->sym == SDLK_UNKNOWN) if (keysym->sym == SDLK_UNKNOWN)
...@@ -141,7 +141,7 @@ void WSCONS_InitOSKeymap(_THIS) ...@@ -141,7 +141,7 @@ void WSCONS_InitOSKeymap(_THIS)
int i; int i;
/* Make sure unknown keys are mapped correctly */ /* Make sure unknown keys are mapped correctly */
for (i=0; i < SDL_TABLESIZE(keymap); i++) { for (i=0; i < SDL_arraysize(keymap); i++) {
keymap[i] = SDLK_UNKNOWN; keymap[i] = SDLK_UNKNOWN;
} }
......
...@@ -693,7 +693,7 @@ void X11_InitKeymap(void) ...@@ -693,7 +693,7 @@ void X11_InitKeymap(void)
int i; int i;
/* Odd keys used in international keyboards */ /* Odd keys used in international keyboards */
for ( i=0; i<SDL_TABLESIZE(ODD_keymap); ++i ) for ( i=0; i<SDL_arraysize(ODD_keymap); ++i )
ODD_keymap[i] = SDLK_UNKNOWN; ODD_keymap[i] = SDLK_UNKNOWN;
/* Some of these might be mappable to an existing SDLK_ code */ /* Some of these might be mappable to an existing SDLK_ code */
...@@ -729,7 +729,7 @@ void X11_InitKeymap(void) ...@@ -729,7 +729,7 @@ void X11_InitKeymap(void)
#endif #endif
/* Map the miscellaneous keys */ /* Map the miscellaneous keys */
for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i ) for ( i=0; i<SDL_arraysize(MISC_keymap); ++i )
MISC_keymap[i] = SDLK_UNKNOWN; MISC_keymap[i] = SDLK_UNKNOWN;
/* These X keysyms have 0xFF as the high byte */ /* These X keysyms have 0xFF as the high byte */
......
...@@ -414,10 +414,10 @@ int X11_GL_LoadLibrary(_THIS, const char* path) ...@@ -414,10 +414,10 @@ int X11_GL_LoadLibrary(_THIS, const char* path)
this->gl_config.dll_handle = handle; this->gl_config.dll_handle = handle;
this->gl_config.driver_loaded = 1; this->gl_config.driver_loaded = 1;
if ( path ) { if ( path ) {
SDL_strncpy(this->gl_config.driver_path, path, SDL_strlcpy(this->gl_config.driver_path, path,
sizeof(this->gl_config.driver_path)-1); SDL_arraysize(this->gl_config.driver_path));
} else { } else {
SDL_strcpy(this->gl_config.driver_path, ""); *this->gl_config.driver_path = '\0';
} }
return 0; return 0;
} }
......
...@@ -493,7 +493,7 @@ int X11_GetVideoModes(_THIS) ...@@ -493,7 +493,7 @@ int X11_GetVideoModes(_THIS)
} }
this->hidden->nvisuals = 0; this->hidden->nvisuals = 0;
if ( ! add_visual_byid(this, SDL_getenv("SDL_VIDEO_X11_VISUALID")) ) { if ( ! add_visual_byid(this, SDL_getenv("SDL_VIDEO_X11_VISUALID")) ) {
for ( i=0; i<SDL_TABLESIZE(depth_list); ++i ) { for ( i=0; i<SDL_arraysize(depth_list); ++i ) {
if ( depth_list[i] > 8 ) { if ( depth_list[i] > 8 ) {
if ( use_directcolor ) { if ( use_directcolor ) {
add_visual(this, depth_list[i], DirectColor); add_visual(this, depth_list[i], DirectColor);
......
...@@ -191,14 +191,16 @@ void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y) ...@@ -191,14 +191,16 @@ void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
static void SetMouseAccel(_THIS, const char *accel_param) static void SetMouseAccel(_THIS, const char *accel_param)
{ {
int i; int i;
size_t len;
int accel_value[3]; int accel_value[3];
char *mouse_param, *mouse_param_buf, *pin; char *mouse_param, *mouse_param_buf, *pin;
mouse_param_buf = (char *)SDL_malloc(SDL_strlen(accel_param)+1); len = SDL_strlen(accel_param)+1;
mouse_param_buf = SDL_stack_alloc(char, len);
if ( ! mouse_param_buf ) { if ( ! mouse_param_buf ) {
return; return;
} }
SDL_strcpy(mouse_param_buf, accel_param); SDL_strlcpy(mouse_param_buf, accel_param, len);
mouse_param = mouse_param_buf; mouse_param = mouse_param_buf;
for ( i=0; (i < 3) && mouse_param; ++i ) { for ( i=0; (i < 3) && mouse_param; ++i ) {
......
...@@ -275,7 +275,7 @@ static char *get_classname(char *classname, int maxlen) ...@@ -275,7 +275,7 @@ static char *get_classname(char *classname, int maxlen)
/* First allow environment variable override */ /* First allow environment variable override */
spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS");
if ( spot ) { if ( spot ) {
SDL_strncpy(classname, spot, maxlen); SDL_strlcpy(classname, spot, maxlen);
return classname; return classname;
} }
...@@ -293,16 +293,16 @@ static char *get_classname(char *classname, int maxlen) ...@@ -293,16 +293,16 @@ static char *get_classname(char *classname, int maxlen)
linkfile[linksize] = '\0'; linkfile[linksize] = '\0';
spot = SDL_strrchr(linkfile, '/'); spot = SDL_strrchr(linkfile, '/');
if ( spot ) { if ( spot ) {
SDL_strncpy(classname, spot+1, maxlen); SDL_strlcpy(classname, spot+1, maxlen);
} else { } else {
SDL_strncpy(classname, linkfile, maxlen); SDL_strlcpy(classname, linkfile, maxlen);
} }
return classname; return classname;
} }
#endif /* linux */ #endif /* linux */
/* Finally use the default we've used forever */ /* Finally use the default we've used forever */
SDL_strncpy(classname, "SDL_App", maxlen); SDL_strlcpy(classname, "SDL_App", maxlen);
return classname; return classname;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment