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...

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401340
This commit is contained in:
Sam Lantinga 2006-02-07 06:59:48 +00:00
parent 00f6d8e5e3
commit 5d53175e4d
212 changed files with 1840 additions and 1884 deletions

View file

@ -54,16 +54,16 @@
#endif /* !_WIN32_WCE */ #endif /* !_WIN32_WCE */
/* Features provided by SDL_stdlib.h */ /* Features provided by SDL_stdlib.h */
#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
#define HAVE_GETENV
#define HAVE_PUTENV
#endif
#define HAVE_MALLOC #define HAVE_MALLOC
#define HAVE_REALLOC #define HAVE_REALLOC
#define HAVE_FREE #define HAVE_FREE
#ifndef HAVE_ALLOCA #ifndef HAVE_ALLOCA
#define HAVE_ALLOCA #define HAVE_ALLOCA
#endif #endif
#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
#define HAVE_GETENV
#define HAVE_PUTENV
#endif
/*#define HAVE_QSORT*/ /*#define HAVE_QSORT*/
/* Features provided by SDL_string.h */ /* Features provided by SDL_string.h */
@ -74,6 +74,8 @@
#define HAVE_STRLEN #define HAVE_STRLEN
#define HAVE_STRCPY #define HAVE_STRCPY
#define HAVE_STRNCPY #define HAVE_STRNCPY
#define HAVE_STRCAT
#define HAVE_STRNCAT
/*#define HAVE__STRREV*/ /*#define HAVE__STRREV*/
/*#define HAVE__STRUPR*/ /*#define HAVE__STRUPR*/
/*#define HAVE__STRLWR*/ /*#define HAVE__STRLWR*/
@ -94,7 +96,7 @@
/*#define HAVE_STRCASECMP*/ /*#define HAVE_STRCASECMP*/
#define HAVE_SSCANF #define HAVE_SSCANF
/*#define HAVE_SNPRINTF*/ /*#define HAVE_SNPRINTF*/
#define HAVE_VSNPRINTF /*#define HAVE_VSNPRINTF*/
#endif /* HAVE_LIBC */ #endif /* HAVE_LIBC */

View file

@ -20,39 +20,4 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
#ifndef _SDL_getenv_h #include "SDL_stdlib.h"
#define _SDL_getenv_h
#include "SDL_config.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_GETENV
#define SDL_getenv getenv
#else
#define getenv SDL_getenv
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
#endif
#ifdef HAVE_PUTENV
#define SDL_putenv putenv
#else
#define putenv SDL_putenv
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#endif
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_getenv_h */

View file

@ -49,9 +49,6 @@ char *alloca ();
#endif #endif
#include "SDL_types.h" #include "SDL_types.h"
#include "SDL_stdarg.h"
#include "SDL_getenv.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@ -62,21 +59,18 @@ extern "C" {
#ifdef HAVE_MALLOC #ifdef HAVE_MALLOC
#define SDL_malloc malloc #define SDL_malloc malloc
#else #else
#define malloc SDL_malloc
extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
#endif #endif
#ifdef HAVE_REALLOC #ifdef HAVE_REALLOC
#define SDL_realloc realloc #define SDL_realloc realloc
#else #else
#define realloc SDL_realloc
extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
#endif #endif
#ifdef HAVE_FREE #ifdef HAVE_FREE
#define SDL_free free #define SDL_free free
#else #else
#define free SDL_free
extern DECLSPEC void SDLCALL SDL_free(void *mem); extern DECLSPEC void SDLCALL SDL_free(void *mem);
#endif #endif
@ -84,14 +78,25 @@ extern DECLSPEC void SDLCALL SDL_free(void *mem);
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count) #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*count)
#define SDL_stack_free(data) #define SDL_stack_free(data)
#else #else
#define SDL_stack_alloc(type, count) SDL_malloc(sizeof(type)*count) #define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*count)
#define SDL_stack_free(data) SDL_free(data) #define SDL_stack_free(data) SDL_free(data)
#endif #endif
#ifdef HAVE_GETENV
#define SDL_getenv getenv
#else
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
#endif
#ifdef HAVE_PUTENV
#define SDL_putenv putenv
#else
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#endif
#ifdef HAVE_QSORT #ifdef HAVE_QSORT
#define SDL_qsort qsort #define SDL_qsort qsort
#else #else
#define qsort SDL_qsort
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *)); int (*compare)(const void *, const void *));
#endif #endif

View file

@ -44,10 +44,9 @@
extern "C" { extern "C" {
#endif #endif
#ifndef HAVE_MEMSET #ifdef HAVE_MEMSET
#define memset SDL_memset #define SDL_memset memset
#endif #else
#ifndef SDL_memset
extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
#endif #endif
@ -98,23 +97,14 @@ do { \
: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
: "memory" ); \ : "memory" ); \
} while(0) } while(0)
#define SDL_memcpy4(dst, src, len) \
do { \
int ecx, edi, esi; \
__asm__ __volatile__ ( \
"cld\n\t" \
"rep ; movsl" \
: "=&c" (ecx), "=&D" (edi), "=&S" (esi) \
: "0" ((unsigned)(len)), "1" (dst), "2" (src) \
: "memory" ); \
} while(0)
#endif
#ifndef HAVE_MEMCPY
#define memcpy SDL_memcpy
#endif #endif
#ifndef SDL_memcpy #ifndef SDL_memcpy
#ifdef HAVE_MEMCPY
#define SDL_memcpy memcpy
#else
extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
#endif #endif
#endif
#if defined(__GNUC__) && defined(i386) #if defined(__GNUC__) && defined(i386)
#define SDL_memcpy4(dst, src, len) \ #define SDL_memcpy4(dst, src, len) \
@ -162,9 +152,9 @@ do { \
extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
#endif #endif
#ifndef HAVE_MEMMOVE #ifdef HAVE_MEMMOVE
#define memmove SDL_memmove #define SDL_memmove memmove
#endif #else
#define SDL_memmove(dst, src, len) \ #define SDL_memmove(dst, src, len) \
do { \ do { \
if ( dst < src ) { \ if ( dst < src ) { \
@ -173,109 +163,107 @@ do { \
SDL_revcpy(dst, src, len); \ SDL_revcpy(dst, src, len); \
} \ } \
} while(0) } while(0)
#ifndef HAVE_MEMCMP
#define memcmp SDL_memcmp
#endif #endif
#ifndef SDL_memcmp
#ifdef HAVE_MEMCMP
#define SDL_memcmp memcmp
#else
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
#endif #endif
#ifdef HAVE_STRLEN #ifdef HAVE_STRLEN
#define SDL_strlen strlen #define SDL_strlen strlen
#else #else
#define strlen SDL_strlen
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
#endif #endif
#ifdef HAVE_STRCPY #ifdef HAVE_STRCPY
#define SDL_strcpy strcpy #define SDL_strcpy strcpy
#else #else
#define strcpy SDL_strcpy
extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src); extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src);
#endif #endif
#ifdef HAVE_STRNCPY #ifdef HAVE_STRNCPY
#define SDL_strncpy strncpy #define SDL_strncpy strncpy
#else #else
#define strncpy SDL_strncpy
extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen); extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen);
#endif #endif
#ifdef HAVE_STRCAT
#define SDL_strcat strcat
#else
#define SDL_strcat(dst, src) (SDL_strcpy(dst+SDL_strlen(dst), src), dst)
#endif
#ifdef HAVE_STRNCAT
#define SDL_strncat strncat
#else
#define SDL_strncat(dst, src, n) (SDL_strncpy(dst+SDL_strlen(dst), src, n), dst)
#endif
#ifdef HAVE__STRREV #ifdef HAVE__STRREV
#define SDL_strrev _strrev #define SDL_strrev _strrev
#else #else
#define _strrev SDL_strrev
extern DECLSPEC char * SDLCALL SDL_strrev(char *string); extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
#endif #endif
#ifdef HAVE__STRUPR #ifdef HAVE__STRUPR
#define SDL_strupr _strupr #define SDL_strupr _strupr
#else #else
#define _strupr SDL_strupr
extern DECLSPEC char * SDLCALL SDL_strupr(char *string); extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
#endif #endif
#ifdef HAVE__STRLWR #ifdef HAVE__STRLWR
#define SDL_strlwr _strlwr #define SDL_strlwr _strlwr
#else #else
#define _strlwr SDL_strlwr
extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
#endif #endif
#ifdef HAVE_STRCHR #ifdef HAVE_STRCHR
#define SDL_strchr strchr #define SDL_strchr strchr
#else #else
#define strchr SDL_strchr
extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
#endif #endif
#ifdef HAVE_STRRCHR #ifdef HAVE_STRRCHR
#define SDL_strrchr strrchr #define SDL_strrchr strrchr
#else #else
#define strrchr SDL_strrchr
extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
#endif #endif
#ifdef HAVE_STRSTR #ifdef HAVE_STRSTR
#define SDL_strstr strstr #define SDL_strstr strstr
#else #else
#define strstr SDL_strstr
extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
#endif #endif
#ifdef HAVE_ITOA #ifdef HAVE_ITOA
#define SDL_itoa itoa #define SDL_itoa itoa
#else #else
#define itoa SDL_itoa
#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) #define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
#endif #endif
#ifdef HAVE__LTOA #ifdef HAVE__LTOA
#define SDL_ltoa _ltoa #define SDL_ltoa _ltoa
#else #else
#define _ltoa SDL_ltoa
extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
#endif #endif
#ifdef HAVE__UITOA #ifdef HAVE__UITOA
#define SDL_uitoa _uitoa #define SDL_uitoa _uitoa
#else #else
#define _uitoa SDL_uitoa
#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) #define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
#endif #endif
#ifdef HAVE__ULTOA #ifdef HAVE__ULTOA
#define SDL_ultoa _ultoa #define SDL_ultoa _ultoa
#else #else
#define _ultoa SDL_ultoa
extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
#endif #endif
#ifdef HAVE_STRTOL #ifdef HAVE_STRTOL
#define SDL_strtol strtol #define SDL_strtol strtol
#else #else
#define strtol SDL_strtol
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
#endif #endif
@ -284,21 +272,18 @@ extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int bas
#ifdef HAVE__I64TOA #ifdef HAVE__I64TOA
#define SDL_lltoa _i64toa #define SDL_lltoa _i64toa
#else #else
#define _i64toa SDL_lltoa
extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
#endif #endif
#ifdef HAVE__UI64TOA #ifdef HAVE__UI64TOA
#define SDL_ulltoa _ui64toa #define SDL_ulltoa _ui64toa
#else #else
#define _ui64toa SDL_ulltoa
extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
#endif #endif
#ifdef HAVE_STRTOLL #ifdef HAVE_STRTOLL
#define SDL_strtoll strtoll #define SDL_strtoll strtoll
#else #else
#define strtoll SDL_strtoll
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
#endif #endif
@ -307,14 +292,12 @@ extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int
#ifdef HAVE_STRCMP #ifdef HAVE_STRCMP
#define SDL_strcmp strcmp #define SDL_strcmp strcmp
#else #else
#define strcmp SDL_strcmp
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
#endif #endif
#ifdef HAVE_STRNCMP #ifdef HAVE_STRNCMP
#define SDL_strncmp strncmp #define SDL_strncmp strncmp
#else #else
#define strncmp SDL_strncmp
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
#endif #endif
@ -325,28 +308,24 @@ extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size
#ifdef HAVE_STRCASECMP #ifdef HAVE_STRCASECMP
#define SDL_strcasecmp strcasecmp #define SDL_strcasecmp strcasecmp
#else #else
#define strcasecmp SDL_strcasecmp
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
#endif #endif
#ifdef HAVE_SSCANF #ifdef HAVE_SSCANF
#define SDL_sscanf sscanf #define SDL_sscanf sscanf
#else #else
#define sscanf SDL_sscanf
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
#endif #endif
#ifdef HAVE_SNPRINTF #ifdef HAVE_SNPRINTF
#define SDL_snprintf snprintf #define SDL_snprintf snprintf
#else #else
#define snprintf SDL_snprintf
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
#endif #endif
#ifdef HAVE_VSNPRINTF #ifdef HAVE_VSNPRINTF
#define SDL_vsnprintf vsnprintf #define SDL_vsnprintf vsnprintf
#else #else
#define vsnprintf SDL_vsnprintf
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
#endif #endif

View file

@ -66,7 +66,7 @@ int SDL_InitSubSystem(Uint32 flags)
#ifndef DISABLE_VIDEO #ifndef DISABLE_VIDEO
/* Initialize the video/event subsystem */ /* Initialize the video/event subsystem */
if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) { if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) {
if ( SDL_VideoInit(getenv("SDL_VIDEODRIVER"), if ( SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"),
(flags&SDL_INIT_EVENTTHREAD)) < 0 ) { (flags&SDL_INIT_EVENTTHREAD)) < 0 ) {
return(-1); return(-1);
} }
@ -82,7 +82,7 @@ int SDL_InitSubSystem(Uint32 flags)
#ifndef DISABLE_AUDIO #ifndef DISABLE_AUDIO
/* Initialize the audio subsystem */ /* Initialize the audio subsystem */
if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) { if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) {
if ( SDL_AudioInit(getenv("SDL_AUDIODRIVER")) < 0 ) { if ( SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0 ) {
return(-1); return(-1);
} }
SDL_initialized |= SDL_INIT_AUDIO; SDL_initialized |= SDL_INIT_AUDIO;

View file

@ -63,7 +63,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;
strncpy((char *)error->key, fmt, sizeof(error->key)); SDL_strncpy((char *)error->key, fmt, sizeof(error->key));
error->key[sizeof(error->key)-1] = '\0'; error->key[sizeof(error->key)-1] = '\0';
va_start(ap, fmt); va_start(ap, fmt);
@ -98,7 +98,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)";
strncpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN); SDL_strncpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
error->args[index].buf[ERR_MAX_STRLEN-1] = 0; error->args[index].buf[ERR_MAX_STRLEN-1] = 0;
error->argc++; error->argc++;
} }
@ -125,9 +125,9 @@ static int PrintInt(Uint16 *str, unsigned int maxlen, int value)
char tmp[128]; char tmp[128];
int len, i; int len, i;
snprintf(tmp, SDL_arraysize(tmp), "%d", value); SDL_snprintf(tmp, SDL_arraysize(tmp), "%d", value);
len = 0; len = 0;
if ( strlen(tmp) < maxlen ) { if ( SDL_strlen(tmp) < maxlen ) {
for ( i=0; tmp[i]; ++i ) { for ( i=0; tmp[i]; ++i ) {
*str++ = tmp[i]; *str++ = tmp[i];
++len; ++len;
@ -141,9 +141,9 @@ static int PrintDouble(Uint16 *str, unsigned int maxlen, double value)
char tmp[128]; char tmp[128];
int len, i; int len, i;
snprintf(tmp, SDL_arraysize(tmp), "%f", value); SDL_snprintf(tmp, SDL_arraysize(tmp), "%f", value);
len = 0; len = 0;
if ( strlen(tmp) < maxlen ) { if ( SDL_strlen(tmp) < maxlen ) {
for ( i=0; tmp[i]; ++i ) { for ( i=0; tmp[i]; ++i ) {
*str++ = tmp[i]; *str++ = tmp[i];
++len; ++len;
@ -157,9 +157,9 @@ static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value)
char tmp[128]; char tmp[128];
int len, i; int len, i;
snprintf(tmp, SDL_arraysize(tmp), "%p", value); SDL_snprintf(tmp, SDL_arraysize(tmp), "%p", value);
len = 0; len = 0;
if ( strlen(tmp) < maxlen ) { if ( SDL_strlen(tmp) < maxlen ) {
for ( i=0; tmp[i]; ++i ) { for ( i=0; tmp[i]; ++i ) {
*str++ = tmp[i]; *str++ = tmp[i];
++len; ++len;
@ -253,9 +253,9 @@ Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen)
unsigned int i; unsigned int i;
/* Allocate the UNICODE buffer */ /* Allocate the UNICODE buffer */
errstr16 = (Uint16 *)malloc(maxlen * (sizeof *errstr16)); errstr16 = (Uint16 *)SDL_malloc(maxlen * (sizeof *errstr16));
if ( ! errstr16 ) { if ( ! errstr16 ) {
strncpy((char *)errstr, "Out of memory", maxlen); SDL_strncpy((char *)errstr, "Out of memory", maxlen);
errstr[maxlen-1] = '\0'; errstr[maxlen-1] = '\0';
return(errstr); return(errstr);
} }
@ -269,7 +269,7 @@ Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen)
} }
/* Free UNICODE buffer (if necessary) */ /* Free UNICODE buffer (if necessary) */
free(errstr16); SDL_free(errstr16);
return(errstr); return(errstr);
} }
@ -320,7 +320,7 @@ int main(int argc, char *argv[])
SDL_SetError("Hi there!"); SDL_SetError("Hi there!");
printf("Error 1: %s\n", SDL_GetError()); printf("Error 1: %s\n", SDL_GetError());
SDL_ClearError(); SDL_ClearError();
memset(buffer, '1', BUFSIZ); SDL_memset(buffer, '1', BUFSIZ);
buffer[BUFSIZ] = 0; buffer[BUFSIZ] = 0;
SDL_SetError("This is the error: %s (%f)", buffer, 1.0); SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
printf("Error 2: %s\n", SDL_GetError()); printf("Error 2: %s\n", SDL_GetError());

View file

@ -220,7 +220,7 @@ int SDL_RunAudio(void *audiop)
stream = audio->fake_stream; stream = audio->fake_stream;
} }
} }
memset(stream, silence, stream_len); SDL_memset(stream, silence, stream_len);
if ( ! audio->paused ) { if ( ! audio->paused ) {
SDL_mutexP(audio->mixer_lock); SDL_mutexP(audio->mixer_lock);
@ -235,7 +235,7 @@ int SDL_RunAudio(void *audiop)
if ( stream == NULL ) { if ( stream == NULL ) {
stream = audio->fake_stream; stream = audio->fake_stream;
} }
memcpy(stream, audio->convert.buf, SDL_memcpy(stream, audio->convert.buf,
audio->convert.len_cvt); audio->convert.len_cvt);
} }
@ -299,17 +299,17 @@ int SDL_AudioInit(const char *driver_name)
audio = NULL; audio = NULL;
idx = 0; idx = 0;
#ifdef unix #ifdef unix
if ( (driver_name == NULL) && (getenv("ESPEAKER") != NULL) ) { if ( (driver_name == NULL) && (SDL_getenv("ESPEAKER") != NULL) ) {
/* Ahem, we know that if ESPEAKER is set, user probably wants /* Ahem, we know that if ESPEAKER is set, user probably wants
to use ESD, but don't start it if it's not already running. to use ESD, but don't start it if it's not already running.
This probably isn't the place to do this, but... Shh! :) This probably isn't the place to do this, but... Shh! :)
*/ */
for ( i=0; bootstrap[i]; ++i ) { for ( i=0; bootstrap[i]; ++i ) {
if ( strcmp(bootstrap[i]->name, "esd") == 0 ) { if ( SDL_strcmp(bootstrap[i]->name, "esd") == 0 ) {
const char *esd_no_spawn; const char *esd_no_spawn;
/* Don't start ESD if it's not running */ /* Don't start ESD if it's not running */
esd_no_spawn = getenv("ESD_NO_SPAWN"); esd_no_spawn = SDL_getenv("ESD_NO_SPAWN");
if ( esd_no_spawn == NULL ) { if ( esd_no_spawn == NULL ) {
putenv("ESD_NO_SPAWN=1"); putenv("ESD_NO_SPAWN=1");
} }
@ -329,13 +329,13 @@ int SDL_AudioInit(const char *driver_name)
if ( audio == NULL ) { if ( audio == NULL ) {
if ( driver_name != NULL ) { if ( driver_name != NULL ) {
#if 0 /* This will be replaced with a better driver selection API */ #if 0 /* This will be replaced with a better driver selection API */
if ( strrchr(driver_name, ':') != NULL ) { if ( SDL_strrchr(driver_name, ':') != NULL ) {
idx = atoi(strrchr(driver_name, ':')+1); idx = atoi(SDL_strrchr(driver_name, ':')+1);
} }
#endif #endif
for ( i=0; bootstrap[i]; ++i ) { for ( i=0; bootstrap[i]; ++i ) {
if (strncmp(bootstrap[i]->name, driver_name, if (SDL_strncmp(bootstrap[i]->name, driver_name,
strlen(bootstrap[i]->name)) == 0) { SDL_strlen(bootstrap[i]->name)) == 0) {
if ( bootstrap[i]->available() ) { if ( bootstrap[i]->available() ) {
audio=bootstrap[i]->create(idx); audio=bootstrap[i]->create(idx);
break; break;
@ -375,7 +375,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 ) {
strncpy(namebuf, current_audio->name, maxlen-1); SDL_strncpy(namebuf, current_audio->name, maxlen-1);
namebuf[maxlen-1] = '\0'; namebuf[maxlen-1] = '\0';
return(namebuf); return(namebuf);
} }
@ -436,7 +436,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
SDL_CalculateAudioSpec(desired); SDL_CalculateAudioSpec(desired);
/* Open the audio subsystem */ /* Open the audio subsystem */
memcpy(&audio->spec, desired, sizeof(audio->spec)); SDL_memcpy(&audio->spec, desired, sizeof(audio->spec));
audio->convert.needed = 0; audio->convert.needed = 0;
audio->enabled = 1; audio->enabled = 1;
audio->paused = 1; audio->paused = 1;
@ -489,7 +489,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
/* See if we need to do any conversion */ /* See if we need to do any conversion */
if ( obtained != NULL ) { if ( obtained != NULL ) {
memcpy(obtained, &audio->spec, sizeof(audio->spec)); SDL_memcpy(obtained, &audio->spec, sizeof(audio->spec));
} else if ( desired->freq != audio->spec.freq || } else if ( desired->freq != audio->spec.freq ||
desired->format != audio->spec.format || desired->format != audio->spec.format ||
desired->channels != audio->spec.channels ) { desired->channels != audio->spec.channels ) {

View file

@ -55,8 +55,8 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
char audiopath[1024]; char audiopath[1024];
/* Figure out what our audio device is */ /* Figure out what our audio device is */
if ( ((audiodev=getenv("SDL_PATH_DSP")) == NULL) && if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) &&
((audiodev=getenv("AUDIODEV")) == NULL) ) { ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) {
if ( classic ) { if ( classic ) {
audiodev = _PATH_DEV_AUDIO; audiodev = _PATH_DEV_AUDIO;
} else { } else {
@ -74,7 +74,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
audio_fd = open(audiodev, flags, 0); audio_fd = open(audiodev, flags, 0);
/* If the first open fails, look for other devices */ /* If the first open fails, look for other devices */
if ( (audio_fd < 0) && (strlen(audiodev) < (sizeof(audiopath)-3)) ) { if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) {
int exists, instance; int exists, instance;
struct stat sb; struct stat sb;
@ -90,7 +90,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
audiodev = audiopath; audiodev = audiopath;
} }
if ( path != NULL ) { if ( path != NULL ) {
strncpy(path, audiodev, maxlen); SDL_strncpy(path, audiodev, maxlen);
path[maxlen-1] = '\0'; path[maxlen-1] = '\0';
} }
return(audio_fd); return(audio_fd);
@ -130,15 +130,15 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
int audio_fd; int audio_fd;
/* Figure out what our audio device is */ /* Figure out what our audio device is */
if ((audiodev=getenv("SDL_PATH_DSP")) == NULL) { if ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) {
audiodev=getenv("AUDIODEV"); audiodev=SDL_getenv("AUDIODEV");
} }
if ( audiodev == NULL ) { if ( audiodev == NULL ) {
return -1; return -1;
} }
audio_fd = open(audiodev, flags, 0); audio_fd = open(audiodev, flags, 0);
if ( path != NULL ) { if ( path != NULL ) {
strncpy(path, audiodev, maxlen); SDL_strncpy(path, audiodev, maxlen);
path[maxlen-1] = '\0'; path[maxlen-1] = '\0';
} }
return audio_fd; return audio_fd;
@ -168,7 +168,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 ) {
strncpy( path, audiopath, maxlen ); SDL_strncpy( path, audiopath, maxlen );
path[maxlen-1] = '\0'; path[maxlen-1] = '\0';
} }
return audio_fd; return audio_fd;

View file

@ -52,7 +52,7 @@ void *SDL_AllocAudioMem(int size)
/* Set the segment for deletion when it is detatched */ /* Set the segment for deletion when it is detatched */
shmctl(semid, IPC_RMID, NULL); /* Delets semid if shmat() fails */ shmctl(semid, IPC_RMID, NULL); /* Delets semid if shmat() fails */
#else #else
chunk = malloc(size); chunk = SDL_malloc(size);
#endif #endif
return((void *)chunk); return((void *)chunk);
} }
@ -62,6 +62,6 @@ void SDL_FreeAudioMem(void *chunk)
#ifdef FORK_HACK #ifdef FORK_HACK
shmdt(chunk); shmdt(chunk);
#else #else
free(chunk); SDL_free(chunk);
#endif #endif
} }

View file

@ -2,7 +2,7 @@
SDL - Simple DirectMedia Layer SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or This library is SDL_free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.

View file

@ -135,7 +135,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
*audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) * *audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) *
MS_ADPCM_state.wSamplesPerBlock* MS_ADPCM_state.wSamplesPerBlock*
MS_ADPCM_state.wavefmt.channels*sizeof(Sint16); MS_ADPCM_state.wavefmt.channels*sizeof(Sint16);
*audio_buf = (Uint8 *)malloc(*audio_len); *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
if ( *audio_buf == NULL ) { if ( *audio_buf == NULL ) {
SDL_Error(SDL_ENOMEM); SDL_Error(SDL_ENOMEM);
return(-1); return(-1);
@ -214,7 +214,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
} }
encoded_len -= MS_ADPCM_state.wavefmt.blockalign; encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
} }
free(freeable); SDL_free(freeable);
return(0); return(0);
} }
@ -352,7 +352,7 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) * *audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) *
IMA_ADPCM_state.wSamplesPerBlock* IMA_ADPCM_state.wSamplesPerBlock*
IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16); IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16);
*audio_buf = (Uint8 *)malloc(*audio_len); *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
if ( *audio_buf == NULL ) { if ( *audio_buf == NULL ) {
SDL_Error(SDL_ENOMEM); SDL_Error(SDL_ENOMEM);
return(-1); return(-1);
@ -394,7 +394,7 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
} }
encoded_len -= IMA_ADPCM_state.wavefmt.blockalign; encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
} }
free(freeable); SDL_free(freeable);
return(0); return(0);
} }
@ -444,7 +444,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
chunk.data = NULL; chunk.data = NULL;
do { do {
if ( chunk.data != NULL ) { if ( chunk.data != NULL ) {
free(chunk.data); SDL_free(chunk.data);
} }
lenread = ReadChunk(src, &chunk); lenread = ReadChunk(src, &chunk);
if ( lenread < 0 ) { if ( lenread < 0 ) {
@ -489,7 +489,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
was_error = 1; was_error = 1;
goto done; goto done;
} }
memset(spec, 0, (sizeof *spec)); SDL_memset(spec, 0, (sizeof *spec));
spec->freq = SDL_SwapLE32(format->frequency); spec->freq = SDL_SwapLE32(format->frequency);
switch (SDL_SwapLE16(format->bitspersample)) { switch (SDL_SwapLE16(format->bitspersample)) {
case 4: case 4:
@ -521,7 +521,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
*audio_buf = NULL; *audio_buf = NULL;
do { do {
if ( *audio_buf != NULL ) { if ( *audio_buf != NULL ) {
free(*audio_buf); SDL_free(*audio_buf);
} }
lenread = ReadChunk(src, &chunk); lenread = ReadChunk(src, &chunk);
if ( lenread < 0 ) { if ( lenread < 0 ) {
@ -553,7 +553,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
done: done:
if ( format != NULL ) { if ( format != NULL ) {
free(format); SDL_free(format);
} }
if ( freesrc && src ) { if ( freesrc && src ) {
SDL_RWclose(src); SDL_RWclose(src);
@ -574,7 +574,7 @@ done:
void SDL_FreeWAV(Uint8 *audio_buf) void SDL_FreeWAV(Uint8 *audio_buf)
{ {
if ( audio_buf != NULL ) { if ( audio_buf != NULL ) {
free(audio_buf); SDL_free(audio_buf);
} }
} }
@ -582,14 +582,14 @@ static int ReadChunk(SDL_RWops *src, Chunk *chunk)
{ {
chunk->magic = SDL_ReadLE32(src); chunk->magic = SDL_ReadLE32(src);
chunk->length = SDL_ReadLE32(src); chunk->length = SDL_ReadLE32(src);
chunk->data = (Uint8 *)malloc(chunk->length); chunk->data = (Uint8 *)SDL_malloc(chunk->length);
if ( chunk->data == NULL ) { if ( chunk->data == NULL ) {
SDL_Error(SDL_ENOMEM); SDL_Error(SDL_ENOMEM);
return(-1); return(-1);
} }
if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) { if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) {
SDL_Error(SDL_EFREAD); SDL_Error(SDL_EFREAD);
free(chunk->data); SDL_free(chunk->data);
return(-1); return(-1);
} }
return(chunk->length); return(chunk->length);

View file

@ -2,7 +2,7 @@
SDL - Simple DirectMedia Layer SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or This library is SDL_free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.

View file

@ -170,7 +170,7 @@ static const char *get_audio_device(int channels)
{ {
const char *device; const char *device;
device = getenv("AUDIODEV"); /* Is there a standard variable name? */ device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */
if ( device == NULL ) { if ( device == NULL ) {
if (channels == 6) device = "surround51"; if (channels == 6) device = "surround51";
else if (channels == 4) device = "surround40"; else if (channels == 4) device = "surround40";
@ -202,8 +202,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
UnloadALSALibrary(); UnloadALSALibrary();
} }
@ -213,20 +213,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
LoadALSALibrary(); LoadALSALibrary();
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = ALSA_OpenAudio; this->OpenAudio = ALSA_OpenAudio;
@ -435,7 +435,7 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec)
ALSA_CloseAudio(this); ALSA_CloseAudio(this);
return(-1); return(-1);
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* Get the parent process id (we're the parent of the audio thread) */ /* Get the parent process id (we're the parent of the audio thread) */
parent = getpid(); parent = getpid();

View file

@ -74,8 +74,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -87,20 +87,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
#endif #endif
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = AHI_OpenAudio; this->OpenAudio = AHI_OpenAudio;
@ -316,7 +316,7 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
D(bug("Before audio_req memcpy\n")); D(bug("Before audio_req memcpy\n"));
memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest)); SDL_memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest));
if ( mixbuf[0] == NULL || mixbuf[1] == NULL ) { if ( mixbuf[0] == NULL || mixbuf[1] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
@ -325,8 +325,8 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
D(bug("Before mixbuf memset\n")); D(bug("Before mixbuf memset\n"));
memset(mixbuf[0], spec->silence, spec->size); SDL_memset(mixbuf[0], spec->silence, spec->size);
memset(mixbuf[1], spec->silence, spec->size); SDL_memset(mixbuf[1], spec->silence, spec->size);
current_buffer=0; current_buffer=0;
playing=0; playing=0;

View file

@ -152,8 +152,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
UnloadARTSLibrary(); UnloadARTSLibrary();
} }
@ -163,20 +163,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
LoadARTSLibrary(); LoadARTSLibrary();
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
stream = 0; stream = 0;
/* Set the function pointers */ /* Set the function pointers */
@ -331,7 +331,7 @@ static int ARTSC_OpenAudio(_THIS, SDL_AudioSpec *spec)
if ( mixbuf == NULL ) { if ( mixbuf == NULL ) {
return(-1); return(-1);
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* Get the parent process id (we're the parent of the audio thread) */ /* Get the parent process id (we're the parent of the audio thread) */
parent = getpid(); parent = getpid();

View file

@ -54,8 +54,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -63,20 +63,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *device; SDL_AudioDevice *device;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
device = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); device = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( device ) { if ( device ) {
memset(device, 0, (sizeof *device)); SDL_memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateAudioData *) device->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *device->hidden)); SDL_malloc((sizeof *device->hidden));
} }
if ( (device == NULL) || (device->hidden == NULL) ) { if ( (device == NULL) || (device->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( device ) { if ( device ) {
free(device); SDL_free(device);
} }
return(0); return(0);
} }
memset(device->hidden, 0, (sizeof *device->hidden)); SDL_memset(device->hidden, 0, (sizeof *device->hidden));
/* Set the function pointers */ /* Set the function pointers */
device->OpenAudio = BE_OpenAudio; device->OpenAudio = BE_OpenAudio;
@ -102,7 +102,7 @@ static void FillSound(void *device, void *stream, size_t len,
SDL_AudioDevice *audio = (SDL_AudioDevice *)device; SDL_AudioDevice *audio = (SDL_AudioDevice *)device;
/* Silence the buffer, since it's ours */ /* Silence the buffer, since it's ours */
memset(stream, audio->spec.silence, len); SDL_memset(stream, audio->spec.silence, len);
/* Only do soemthing if audio is enabled */ /* Only do soemthing if audio is enabled */
if ( ! audio->enabled ) if ( ! audio->enabled )
@ -115,7 +115,7 @@ static void FillSound(void *device, void *stream, size_t len,
(Uint8 *)audio->convert.buf,audio->convert.len); (Uint8 *)audio->convert.buf,audio->convert.len);
SDL_mutexV(audio->mixer_lock); SDL_mutexV(audio->mixer_lock);
SDL_ConvertAudio(&audio->convert); SDL_ConvertAudio(&audio->convert);
memcpy(stream,audio->convert.buf,audio->convert.len_cvt); SDL_memcpy(stream,audio->convert.buf,audio->convert.len_cvt);
} else { } else {
SDL_mutexP(audio->mixer_lock); SDL_mutexP(audio->mixer_lock);
(*audio->spec.callback)(audio->spec.userdata, (*audio->spec.callback)(audio->spec.userdata,

View file

@ -94,7 +94,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
int rc; int rc;
// First thing is to try to open a given DART device! // First thing is to try to open a given DART device!
memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS)); SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS));
// pszDeviceType should contain the device type in low word, and device ordinal in high word! // pszDeviceType should contain the device type in low word, and device ordinal in high word!
AmpOpenParms.pszDeviceType = (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16)); AmpOpenParms.pszDeviceType = (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16));
@ -138,7 +138,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
iBufSize = spec->size; iBufSize = spec->size;
// Now query this device if it supports the given freq/bits/channels! // Now query this device if it supports the given freq/bits/channels!
memset(&(_this->hidden->MixSetupParms), 0, sizeof(MCI_MIXSETUP_PARMS)); SDL_memset(&(_this->hidden->MixSetupParms), 0, sizeof(MCI_MIXSETUP_PARMS));
_this->hidden->MixSetupParms.ulBitsPerSample = iBits; _this->hidden->MixSetupParms.ulBitsPerSample = iBits;
_this->hidden->MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM; _this->hidden->MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM;
_this->hidden->MixSetupParms.ulSamplesPerSec = iFreq; _this->hidden->MixSetupParms.ulSamplesPerSec = iFreq;
@ -170,7 +170,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
// Ok, the device is initialized. // Ok, the device is initialized.
// Now we should allocate buffers. For this, we need a place where // Now we should allocate buffers. For this, we need a place where
// the buffer descriptors will be: // the buffer descriptors will be:
_this->hidden->pMixBuffers = (MCI_MIX_BUFFER *) malloc(sizeof(MCI_MIX_BUFFER)*iNumBufs); _this->hidden->pMixBuffers = (MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER)*iNumBufs);
if (!(_this->hidden->pMixBuffers)) if (!(_this->hidden->pMixBuffers))
{ // Not enough memory! { // Not enough memory!
// Close DART, and exit with error code! // Close DART, and exit with error code!
@ -190,7 +190,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
if ((rc!=MCIERR_SUCCESS) || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers) || (_this->hidden->BufferParms.ulBufferSize==0)) if ((rc!=MCIERR_SUCCESS) || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers) || (_this->hidden->BufferParms.ulBufferSize==0))
{ // Could not allocate memory! { // Could not allocate memory!
// Close DART, and exit with error code! // Close DART, and exit with error code!
free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
SDL_SetError("DART could not allocate buffers"); SDL_SetError("DART could not allocate buffers");
return(-1); return(-1);
@ -200,18 +200,18 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
int i; int i;
for (i=0; i<iNumBufs; i++) for (i=0; i<iNumBufs; i++)
{ {
pMixBufferDesc pBufferDesc = (pMixBufferDesc) malloc(sizeof(tMixBufferDesc));; pMixBufferDesc pBufferDesc = (pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));;
// Check if this buffer was really allocated by DART // Check if this buffer was really allocated by DART
if ((!(_this->hidden->pMixBuffers[i].pBuffer)) || (!pBufferDesc)) if ((!(_this->hidden->pMixBuffers[i].pBuffer)) || (!pBufferDesc))
{ // Wrong buffer! { // Wrong buffer!
// Close DART, and exit with error code! // Close DART, and exit with error code!
// Free buffer descriptions // Free buffer descriptions
{ int j; { int j;
for (j=0; j<i; j++) free((void *)(_this->hidden->pMixBuffers[j].ulUserParm)); for (j=0; j<i; j++) SDL_free((void *)(_this->hidden->pMixBuffers[j].ulUserParm));
} }
// and cleanup // and cleanup
mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0); mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
SDL_SetError("Error at internal buffer check"); SDL_SetError("Error at internal buffer check");
return(-1); return(-1);
@ -224,7 +224,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
_this->hidden->pMixBuffers[i].ulFlags = 0; // Some stuff should be flagged here for DART, like end of _this->hidden->pMixBuffers[i].ulFlags = 0; // Some stuff should be flagged here for DART, like end of
// audio data, but as we will continously send // audio data, but as we will continously send
// audio data, there will be no end.:) // audio data, there will be no end.:)
memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence, iBufSize); SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence, iBufSize);
} }
} }
_this->hidden->iNextFreeBuffer = 0; _this->hidden->iNextFreeBuffer = 0;
@ -235,10 +235,10 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
// Could not create event semaphore! // Could not create event semaphore!
{ {
int i; int i;
for (i=0; i<iNumBufs; i++) free((void *)(_this->hidden->pMixBuffers[i].ulUserParm)); for (i=0; i<iNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
} }
mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0); mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
SDL_SetError("Could not create event semaphore"); SDL_SetError("Could not create event semaphore");
return(-1); return(-1);
@ -363,14 +363,14 @@ void DART_CloseAudio(_THIS)
// Free memory of buffer descriptions // Free memory of buffer descriptions
{ {
int i; int i;
for (i=0; i<_this->hidden->iCurrNumBufs; i++) free((void *)(_this->hidden->pMixBuffers[i].ulUserParm)); for (i=0; i<_this->hidden->iCurrNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
} }
// Deallocate buffers // Deallocate buffers
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0); rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
// Free bufferlist // Free bufferlist
free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
// Close dart // Close dart
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, &(GenericParms), 0); rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, &(GenericParms), 0);
@ -385,8 +385,8 @@ int Audio_Available(void)
void Audio_DeleteDevice(SDL_AudioDevice *device) void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -394,21 +394,21 @@ SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) if ( this )
{ {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) if ( (this == NULL) || (this->hidden == NULL) )
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) if ( this )
free(this); SDL_free(this);
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = DART_OpenAudio; this->OpenAudio = DART_OpenAudio;

View file

@ -60,8 +60,8 @@ static int DCAUD_Available(void)
static void DCAUD_DeleteDevice(SDL_AudioDevice *device) static void DCAUD_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *DCAUD_CreateDevice(int devindex) static SDL_AudioDevice *DCAUD_CreateDevice(int devindex)
@ -69,20 +69,20 @@ static SDL_AudioDevice *DCAUD_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = DCAUD_OpenAudio; this->OpenAudio = DCAUD_OpenAudio;
@ -229,7 +229,7 @@ static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
if ( this->hidden->mixbuf == NULL ) { if ( this->hidden->mixbuf == NULL ) {
return(-1); return(-1);
} }
memset(this->hidden->mixbuf, spec->silence, spec->size); SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
this->hidden->leftpos = 0x11000; this->hidden->leftpos = 0x11000;
this->hidden->rightpos = 0x11000+spec->size; this->hidden->rightpos = 0x11000+spec->size;
this->hidden->playing = 0; this->hidden->playing = 0;

View file

@ -62,7 +62,7 @@ static void DISKAUD_CloseAudio(_THIS);
static const char *DISKAUD_GetOutputFilename(void) static const char *DISKAUD_GetOutputFilename(void)
{ {
const char *envr = getenv(DISKENVR_OUTFILE); const char *envr = SDL_getenv(DISKENVR_OUTFILE);
return((envr != NULL) ? envr : DISKDEFAULT_OUTFILE); return((envr != NULL) ? envr : DISKDEFAULT_OUTFILE);
} }
@ -75,10 +75,10 @@ static int DISKAUD_Available(void)
int exists = 0; int exists = 0;
struct stat statbuf; struct stat statbuf;
const char *fname = DISKAUD_GetOutputFilename(); const char *fname = DISKAUD_GetOutputFilename();
const char *envr = getenv("SDL_AUDIODRIVER"); const char *envr = SDL_getenv("SDL_AUDIODRIVER");
available = 0; available = 0;
if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
if (stat(fname, &statbuf) == 0) if (stat(fname, &statbuf) == 0)
exists = 1; exists = 1;
@ -93,8 +93,8 @@ static int DISKAUD_Available(void)
} }
return(available); return(available);
#else #else
const char *envr = getenv("SDL_AUDIODRIVER"); const char *envr = SDL_getenv("SDL_AUDIODRIVER");
if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
return(1); return(1);
} }
@ -104,8 +104,8 @@ static int DISKAUD_Available(void)
static void DISKAUD_DeleteDevice(SDL_AudioDevice *device) static void DISKAUD_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex) static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
@ -114,22 +114,22 @@ static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
const char *envr; const char *envr;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
envr = getenv(DISKENVR_WRITEDELAY); envr = SDL_getenv(DISKENVR_WRITEDELAY);
this->hidden->write_delay = (envr) ? atoi(envr) : DISKDEFAULT_WRITEDELAY; this->hidden->write_delay = (envr) ? atoi(envr) : DISKDEFAULT_WRITEDELAY;
/* Set the function pointers */ /* Set the function pointers */
@ -216,7 +216,7 @@ static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
if ( this->hidden->mixbuf == NULL ) { if ( this->hidden->mixbuf == NULL ) {
return(-1); return(-1);
} }
memset(this->hidden->mixbuf, spec->silence, spec->size); SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
/* We're ready to rock and roll. :-) */ /* We're ready to rock and roll. :-) */
return(0); return(0);

View file

@ -93,8 +93,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -102,20 +102,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
audio_fd = -1; audio_fd = -1;
/* Set the function pointers */ /* Set the function pointers */
@ -428,11 +428,11 @@ static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec)
dma_buf = NULL; dma_buf = NULL;
return(-1); return(-1);
} }
memset(dma_buf, spec->silence, dma_len); SDL_memset(dma_buf, spec->silence, dma_len);
/* Check to see if we need to use select() workaround */ /* Check to see if we need to use select() workaround */
{ char *workaround; { char *workaround;
workaround = getenv("SDL_DSP_NOSELECT"); workaround = SDL_getenv("SDL_DSP_NOSELECT");
if ( workaround ) { if ( workaround ) {
frame_ticks = (float)(spec->samples*1000)/spec->freq; frame_ticks = (float)(spec->samples*1000)/spec->freq;
next_frame = SDL_GetTicks()+frame_ticks; next_frame = SDL_GetTicks()+frame_ticks;

View file

@ -62,8 +62,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -71,20 +71,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = AL_OpenAudio; this->OpenAudio = AL_OpenAudio;
@ -211,7 +211,7 @@ static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* We're ready to rock and roll. :-) */ /* We're ready to rock and roll. :-) */
return(0); return(0);

View file

@ -82,8 +82,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -91,20 +91,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
audio_fd = -1; audio_fd = -1;
/* Set the function pointers */ /* Set the function pointers */
@ -322,7 +322,7 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
DSP_CloseAudio(this); DSP_CloseAudio(this);
return(-1); return(-1);
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* Get the parent process id (we're the parent of the audio thread) */ /* Get the parent process id (we're the parent of the audio thread) */
parent = getpid(); parent = getpid();

View file

@ -142,8 +142,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
UnloadESDLibrary(); UnloadESDLibrary();
} }
@ -153,20 +153,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
LoadESDLibrary(); LoadESDLibrary();
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
audio_fd = -1; audio_fd = -1;
/* Set the function pointers */ /* Set the function pointers */
@ -261,7 +261,7 @@ static char *get_progname(void)
fp = fopen(temp, "r"); fp = fopen(temp, "r");
if ( fp != NULL ) { if ( fp != NULL ) {
if ( fgets(temp, sizeof(temp)-1, fp) ) { if ( fgets(temp, sizeof(temp)-1, fp) ) {
progname = strrchr(temp, '/'); progname = SDL_strrchr(temp, '/');
if ( progname == NULL ) { if ( progname == NULL ) {
progname = temp; progname = temp;
} else { } else {
@ -318,7 +318,7 @@ static int ESD_OpenAudio(_THIS, SDL_AudioSpec *spec)
if ( mixbuf == NULL ) { if ( mixbuf == NULL ) {
return(-1); return(-1);
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* Get the parent process id (we're the parent of the audio thread) */ /* Get the parent process id (we're the parent of the audio thread) */
parent = getpid(); parent = getpid();

View file

@ -52,8 +52,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -61,20 +61,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = Core_OpenAudio; this->OpenAudio = Core_OpenAudio;
@ -106,7 +106,7 @@ static OSStatus audioCallback (void *inRefCon,
/* Only do anything if audio is enabled and not paused */ /* Only do anything if audio is enabled and not paused */
if ( ! this->enabled || this->paused ) { if ( ! this->enabled || this->paused ) {
memset(ioData->mData, this->spec.silence, ioData->mDataByteSize); SDL_memset(ioData->mData, this->spec.silence, ioData->mDataByteSize);
return 0; return 0;
} }
@ -121,7 +121,7 @@ static OSStatus audioCallback (void *inRefCon,
while (remaining > 0) { while (remaining > 0) {
if (bufferOffset >= bufferSize) { if (bufferOffset >= bufferSize) {
/* Generate the data */ /* Generate the data */
memset(buffer, this->spec.silence, bufferSize); SDL_memset(buffer, this->spec.silence, bufferSize);
SDL_mutexP(this->mixer_lock); SDL_mutexP(this->mixer_lock);
(*this->spec.callback)(this->spec.userdata, (*this->spec.callback)(this->spec.userdata,
buffer, bufferSize); buffer, bufferSize);
@ -132,7 +132,7 @@ static OSStatus audioCallback (void *inRefCon,
len = bufferSize - bufferOffset; len = bufferSize - bufferOffset;
if (len > remaining) if (len > remaining)
len = remaining; len = remaining;
memcpy(ptr, buffer + bufferOffset, len); SDL_memcpy(ptr, buffer + bufferOffset, len);
ptr += len; ptr += len;
remaining -= len; remaining -= len;
bufferOffset += len; bufferOffset += len;
@ -189,7 +189,7 @@ void Core_CloseAudio(_THIS)
return; return;
} }
free(buffer); SDL_free(buffer);
} }
#define CHECK_RESULT(msg) \ #define CHECK_RESULT(msg) \
@ -269,7 +269,7 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
/* Allocate a sample buffer */ /* Allocate a sample buffer */
bufferOffset = bufferSize = this->spec.size; bufferOffset = bufferSize = this->spec.size;
buffer = malloc(bufferSize); buffer = SDL_malloc(bufferSize);
assert(buffer); assert(buffer);
/* Finally, start processing of the audio unit */ /* Finally, start processing of the audio unit */

View file

@ -66,8 +66,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -75,20 +75,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = Mac_OpenAudio; this->OpenAudio = Mac_OpenAudio;
@ -135,7 +135,7 @@ static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
if ( audio->convert.len_cvt != audio->spec.size ) { if ( audio->convert.len_cvt != audio->spec.size ) {
/* Uh oh... probably crashes here */; /* Uh oh... probably crashes here */;
} }
memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
} else { } else {
audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
} }
@ -267,7 +267,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) {
} }
/* Create the sound manager channel */ /* Create the sound manager channel */
channel = (SndChannelPtr)malloc(sizeof(*channel)); channel = (SndChannelPtr)SDL_malloc(sizeof(*channel));
if ( channel == NULL ) { if ( channel == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
@ -281,7 +281,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) {
channel->qLength = 128; channel->qLength = 128;
if ( SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr ) { if ( SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr ) {
SDL_SetError("Unable to create audio channel"); SDL_SetError("Unable to create audio channel");
free(channel); SDL_free(channel);
channel = NULL; channel = NULL;
return(-1); return(-1);
} }
@ -311,7 +311,7 @@ static void Mac_CloseAudio(_THIS) {
for ( i=0; i<2; ++i ) { for ( i=0; i<2; ++i ) {
if ( buffer[i] ) { if ( buffer[i] ) {
free(buffer[i]); SDL_free(buffer[i]);
buffer[i] = NULL; buffer[i] = NULL;
} }
} }
@ -355,7 +355,7 @@ void sndDoubleBackProc (SndChannelPtr chan, SndDoubleBufferPtr newbuf)
/* Uh oh... probably crashes here */; /* Uh oh... probably crashes here */;
} }
#endif #endif
memcpy(newbuf->dbSoundData, audio->convert.buf, SDL_memcpy(newbuf->dbSoundData, audio->convert.buf,
audio->convert.len_cvt); audio->convert.len_cvt);
} else { } else {
audio->spec.callback(audio->spec.userdata, audio->spec.callback(audio->spec.userdata,
@ -400,7 +400,7 @@ static void Mac_CloseAudio(_THIS)
} }
for ( i=0; i<2; ++i ) { for ( i=0; i<2; ++i ) {
if ( audio_buf[i] ) { if ( audio_buf[i] ) {
free(audio_buf[i]); SDL_free(audio_buf[i]);
audio_buf[i] = NULL; audio_buf[i] = NULL;
} }
} }
@ -435,7 +435,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec)
SDL_CalculateAudioSpec(spec); SDL_CalculateAudioSpec(spec);
/* initialize the double-back header */ /* initialize the double-back header */
memset(&audio_dbh, 0, sizeof(audio_dbh)); SDL_memset(&audio_dbh, 0, sizeof(audio_dbh));
doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc); doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc);
sample_bits = spec->size / spec->samples / spec->channels * 8; sample_bits = spec->size / spec->samples / spec->channels * 8;
@ -467,7 +467,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec)
} }
/* Create the sound manager channel */ /* Create the sound manager channel */
channel = (SndChannelPtr)malloc(sizeof(*channel)); channel = (SndChannelPtr)SDL_malloc(sizeof(*channel));
if ( channel == NULL ) { if ( channel == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
@ -481,7 +481,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec)
channel->qLength = 128; channel->qLength = 128;
if ( SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr ) { if ( SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr ) {
SDL_SetError("Unable to create audio channel"); SDL_SetError("Unable to create audio channel");
free(channel); SDL_free(channel);
channel = NULL; channel = NULL;
return(-1); return(-1);
} }

View file

@ -63,7 +63,7 @@ void SDL_MintAudio_Callback(void)
SDL_AudioDevice *audio = SDL_MintAudio_device; SDL_AudioDevice *audio = SDL_MintAudio_device;
buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
memset(buffer, audio->spec.silence, audio->spec.size); SDL_memset(buffer, audio->spec.silence, audio->spec.size);
if (audio->paused) if (audio->paused)
return; return;
@ -76,11 +76,11 @@ void SDL_MintAudio_Callback(void)
} else { } else {
silence = 0; silence = 0;
} }
memset(audio->convert.buf, silence, audio->convert.len); SDL_memset(audio->convert.buf, silence, audio->convert.len);
audio->spec.callback(audio->spec.userdata, audio->spec.callback(audio->spec.userdata,
(Uint8 *)audio->convert.buf,audio->convert.len); (Uint8 *)audio->convert.buf,audio->convert.len);
SDL_ConvertAudio(&audio->convert); SDL_ConvertAudio(&audio->convert);
memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
} else { } else {
audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
} }
@ -106,7 +106,7 @@ void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
/* Put all following ones farer */ /* Put all following ones farer */
if (MINTAUDIO_freqcount>0) { if (MINTAUDIO_freqcount>0) {
for (i=MINTAUDIO_freqcount; i>p; i--) { for (i=MINTAUDIO_freqcount; i>p; i--) {
memcpy(&MINTAUDIO_frequencies[i], &MINTAUDIO_frequencies[i-1], sizeof(mint_frequency_t)); SDL_memcpy(&MINTAUDIO_frequencies[i], &MINTAUDIO_frequencies[i-1], sizeof(mint_frequency_t));
} }
} }

View file

@ -81,10 +81,10 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec);
static int Audio_Available(void) static int Audio_Available(void)
{ {
const char *envr = getenv("SDL_AUDIODRIVER"); const char *envr = SDL_getenv("SDL_AUDIODRIVER");
/* Check if user asked a different audio driver */ /* Check if user asked a different audio driver */
if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
return 0; return 0;
} }
@ -121,8 +121,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -130,20 +130,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = Mint_OpenAudio; this->OpenAudio = Mint_OpenAudio;
@ -347,7 +347,7 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
SDL_MintAudio_numbuf=0; SDL_MintAudio_numbuf=0;
memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_audiosize = spec->size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;

View file

@ -85,10 +85,10 @@ static void Mint_GsxbNullInterrupt(void);
static int Audio_Available(void) static int Audio_Available(void)
{ {
const char *envr = getenv("SDL_AUDIODRIVER"); const char *envr = SDL_getenv("SDL_AUDIODRIVER");
/* Check if user asked a different audio driver */ /* Check if user asked a different audio driver */
if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
return(0); return(0);
} }
@ -127,8 +127,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -136,20 +136,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = Mint_OpenAudio; this->OpenAudio = Mint_OpenAudio;
@ -384,7 +384,7 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
SDL_MintAudio_numbuf=0; SDL_MintAudio_numbuf=0;
memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_audiosize = spec->size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;

View file

@ -84,7 +84,7 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec);
static int Audio_Available(void) static int Audio_Available(void)
{ {
unsigned long dummy; unsigned long dummy;
const char *envr = getenv("SDL_AUDIODRIVER"); const char *envr = SDL_getenv("SDL_AUDIODRIVER");
SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
@ -94,7 +94,7 @@ static int Audio_Available(void)
} }
/* Check if user asked a different audio driver */ /* Check if user asked a different audio driver */
if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
return(0); return(0);
} }
@ -141,8 +141,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -150,20 +150,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = Mint_OpenAudio; this->OpenAudio = Mint_OpenAudio;
@ -388,7 +388,7 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
SDL_MintAudio_numbuf=0; SDL_MintAudio_numbuf=0;
memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_audiosize = spec->size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;

View file

@ -89,10 +89,10 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec);
static int Audio_Available(void) static int Audio_Available(void)
{ {
const char *envr = getenv("SDL_AUDIODRIVER"); const char *envr = SDL_getenv("SDL_AUDIODRIVER");
/* Check if user asked a different audio driver */ /* Check if user asked a different audio driver */
if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
return(0); return(0);
} }
@ -121,8 +121,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -130,20 +130,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = Mint_OpenAudio; this->OpenAudio = Mint_OpenAudio;
@ -308,7 +308,7 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
SDL_MintAudio_numbuf=0; SDL_MintAudio_numbuf=0;
memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_audiosize = spec->size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;

View file

@ -84,7 +84,7 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec);
static int Audio_Available(void) static int Audio_Available(void)
{ {
unsigned long dummy; unsigned long dummy;
const char *envr = getenv("SDL_AUDIODRIVER"); const char *envr = SDL_getenv("SDL_AUDIODRIVER");
SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
@ -94,7 +94,7 @@ static int Audio_Available(void)
} }
/* Check if user asked a different audio driver */ /* Check if user asked a different audio driver */
if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) { if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
return(0); return(0);
} }
@ -124,8 +124,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -133,20 +133,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = Mint_OpenAudio; this->OpenAudio = Mint_OpenAudio;
@ -285,7 +285,7 @@ static void Mint_CheckExternalClock(_THIS)
DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n")); DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n"));
return; return;
} }
memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE); SDL_memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE);
Buffoper(0); Buffoper(0);
Settracks(0,0); Settracks(0,0);
@ -477,7 +477,7 @@ static int Mint_OpenAudio(_THIS, SDL_AudioSpec *spec)
} }
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ; SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
SDL_MintAudio_numbuf=0; SDL_MintAudio_numbuf=0;
memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2); SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_audiosize = spec->size;
SDL_MintAudio_mutex = 0; SDL_MintAudio_mutex = 0;

View file

@ -43,10 +43,10 @@ static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
if ( device ) { if ( device ) {
if ( device->hidden ) { if ( device->hidden ) {
free(device->hidden); SDL_free(device->hidden);
device->hidden = NULL; device->hidden = NULL;
} }
free(device); SDL_free(device);
device = NULL; device = NULL;
} }
} }
@ -56,19 +56,19 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = malloc(sizeof(SDL_AudioDevice)); this = SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = malloc((sizeof *this->hidden)); this->hidden = SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = MME_OpenAudio; this->OpenAudio = MME_OpenAudio;
this->WaitAudio = MME_WaitAudio; this->WaitAudio = MME_WaitAudio;
@ -92,7 +92,7 @@ static void SetMMerror(char *function, MMRESULT code)
char errbuf[MAXERRORLENGTH]; char errbuf[MAXERRORLENGTH];
sprintf(errbuf, "%s: ", function); sprintf(errbuf, "%s: ", function);
len = strlen(errbuf); len = SDL_strlen(errbuf);
waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len); waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len);
SDL_SetError("%s",errbuf); SDL_SetError("%s",errbuf);
} }

View file

@ -66,8 +66,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -75,20 +75,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = NAS_OpenAudio; this->OpenAudio = NAS_OpenAudio;
@ -293,7 +293,7 @@ static int NAS_OpenAudio(_THIS, SDL_AudioSpec *spec)
if ( this->hidden->mixbuf == NULL ) { if ( this->hidden->mixbuf == NULL ) {
return(-1); return(-1);
} }
memset(this->hidden->mixbuf, spec->silence, spec->size); SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
/* Get the parent process id (we're the parent of the audio thread) */ /* Get the parent process id (we're the parent of the audio thread) */
this->hidden->parent = getpid(); this->hidden->parent = getpid();

View file

@ -94,7 +94,7 @@ static int NTO_CheckBuggyCards(_THIS, unsigned long checkfor)
for (it=0; it<QSA_WA_CARDS; it++) for (it=0; it<QSA_WA_CARDS; it++)
{ {
if (strcmp(buggycards[it].cardname, scardname)==0) if (SDL_strcmp(buggycards[it].cardname, scardname)==0)
{ {
if (buggycards[it].bugtype==checkfor) if (buggycards[it].bugtype==checkfor)
{ {
@ -120,7 +120,7 @@ static void NTO_ThreadInit(_THIS)
/* PCM transfer channel parameters initialize function */ /* PCM transfer channel parameters initialize function */
static void NTO_InitAudioParams(snd_pcm_channel_params_t* cpars) static void NTO_InitAudioParams(snd_pcm_channel_params_t* cpars)
{ {
memset(cpars, 0, sizeof(snd_pcm_channel_params_t)); SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
cpars->channel = SND_PCM_CHANNEL_PLAYBACK; cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
cpars->mode = SND_PCM_MODE_BLOCK; cpars->mode = SND_PCM_MODE_BLOCK;
@ -172,11 +172,11 @@ static void NTO_DeleteAudioDevice(SDL_AudioDevice *device)
{ {
if ((device)&&(device->hidden)) if ((device)&&(device->hidden))
{ {
free(device->hidden); SDL_free(device->hidden);
} }
if (device) if (device)
{ {
free(device); SDL_free(device);
} }
} }
@ -185,22 +185,22 @@ static SDL_AudioDevice* NTO_CreateAudioDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if (this) if (this)
{ {
memset(this, 0, sizeof(SDL_AudioDevice)); SDL_memset(this, 0, sizeof(SDL_AudioDevice));
this->hidden = (struct SDL_PrivateAudioData *)malloc(sizeof(struct SDL_PrivateAudioData)); this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(struct SDL_PrivateAudioData));
} }
if ((this == NULL) || (this->hidden == NULL)) if ((this == NULL) || (this->hidden == NULL))
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
if (this) if (this)
{ {
free(this); SDL_free(this);
} }
return (0); return (0);
} }
memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData)); SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
audio_handle = NULL; audio_handle = NULL;
/* Set the function pointers */ /* Set the function pointers */
@ -280,7 +280,7 @@ static void NTO_PlayAudio(_THIS)
{ {
if ((errno == EINVAL) || (errno == EIO)) if ((errno == EINVAL) || (errno == EIO))
{ {
memset(&cstatus, 0, sizeof(cstatus)); SDL_memset(&cstatus, 0, sizeof(cstatus));
cstatus.channel = SND_PCM_CHANNEL_PLAYBACK; cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
if ((rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0) if ((rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0)
{ {
@ -455,7 +455,7 @@ static int NTO_OpenAudio(_THIS, SDL_AudioSpec* spec)
} }
/* Make sure channel is setup right one last time */ /* Make sure channel is setup right one last time */
memset(&csetup, 0x00, sizeof(csetup)); SDL_memset(&csetup, 0x00, sizeof(csetup));
csetup.channel = SND_PCM_CHANNEL_PLAYBACK; csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
if (snd_pcm_plugin_setup(audio_handle, &csetup) < 0) if (snd_pcm_plugin_setup(audio_handle, &csetup) < 0)
{ {
@ -483,7 +483,7 @@ static int NTO_OpenAudio(_THIS, SDL_AudioSpec* spec)
SDL_SetError("NTO_OpenAudio(): pcm buffer allocation failed\n"); SDL_SetError("NTO_OpenAudio(): pcm buffer allocation failed\n");
return (-1); return (-1);
} }
memset(pcm_buf, spec->silence, pcm_len); SDL_memset(pcm_buf, spec->silence, pcm_len);
/* get the file descriptor */ /* get the file descriptor */
if ((audio_fd = snd_pcm_file_descriptor(audio_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0) if ((audio_fd = snd_pcm_file_descriptor(audio_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0)

View file

@ -95,8 +95,8 @@ Audio_Available(void)
static void static void
Audio_DeleteDevice(SDL_AudioDevice *device) Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice static SDL_AudioDevice
@ -105,18 +105,18 @@ static SDL_AudioDevice
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice*)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice*)SDL_malloc(sizeof(SDL_AudioDevice));
if(this) { if(this) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = this->hidden =
(struct SDL_PrivateAudioData*)malloc((sizeof *this->hidden)); (struct SDL_PrivateAudioData*)SDL_malloc((sizeof *this->hidden));
} }
if((this == NULL) || (this->hidden == NULL)) { if((this == NULL) || (this->hidden == NULL)) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if(this) free(this); if(this) SDL_free(this);
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
audio_fd = -1; audio_fd = -1;
/* Set the function pointers */ /* Set the function pointers */
@ -397,7 +397,7 @@ OBSD_OpenAudio(_THIS, SDL_AudioSpec *spec)
if(mixbuf == NULL) { if(mixbuf == NULL) {
return(-1); return(-1);
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* Get the parent process id (we're the parent of the audio thread) */ /* Get the parent process id (we're the parent of the audio thread) */
parent = getpid(); parent = getpid();

View file

@ -82,8 +82,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -91,20 +91,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
audio_fd = -1; audio_fd = -1;
/* Set the function pointers */ /* Set the function pointers */
@ -457,7 +457,7 @@ static int Paud_OpenAudio(_THIS, SDL_AudioSpec *spec)
if ( mixbuf == NULL ) { if ( mixbuf == NULL ) {
return -1; return -1;
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* /*
* Set some paramters: full volume, first speaker that we can find. * Set some paramters: full volume, first speaker that we can find.
@ -498,7 +498,7 @@ static int Paud_OpenAudio(_THIS, SDL_AudioSpec *spec)
/* Check to see if we need to use select() workaround */ /* Check to see if we need to use select() workaround */
{ char *workaround; { char *workaround;
workaround = getenv("SDL_DSP_NOSELECT"); workaround = SDL_getenv("SDL_DSP_NOSELECT");
if ( workaround ) { if ( workaround ) {
frame_ticks = (float)(spec->samples*1000)/spec->freq; frame_ticks = (float)(spec->samples*1000)/spec->freq;
next_frame = SDL_GetTicks()+frame_ticks; next_frame = SDL_GetTicks()+frame_ticks;

View file

@ -75,8 +75,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -84,20 +84,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
audio_fd = -1; audio_fd = -1;
/* Set the function pointers */ /* Set the function pointers */
@ -236,7 +236,7 @@ void DSP_CloseAudio(_THIS)
mixbuf = NULL; mixbuf = NULL;
} }
if ( ulaw_buf != NULL ) { if ( ulaw_buf != NULL ) {
free(ulaw_buf); SDL_free(ulaw_buf);
ulaw_buf = NULL; ulaw_buf = NULL;
} }
close(audio_fd); close(audio_fd);
@ -349,7 +349,7 @@ int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
spec->freq = desired_freq; spec->freq = desired_freq;
fragsize = (spec->samples*1000)/(spec->freq/8); fragsize = (spec->samples*1000)/(spec->freq/8);
frequency = 8; frequency = 8;
ulaw_buf = (Uint8 *)malloc(fragsize); ulaw_buf = (Uint8 *)SDL_malloc(fragsize);
if ( ulaw_buf == NULL ) { if ( ulaw_buf == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
@ -375,7 +375,7 @@ int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
memset(mixbuf, spec->silence, spec->size); SDL_memset(mixbuf, spec->silence, spec->size);
/* We're ready to rock and roll. :-) */ /* We're ready to rock and roll. :-) */
return(0); return(0);

View file

@ -84,11 +84,11 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(_THIS) static void Audio_DeleteDevice(_THIS)
{ {
if(this->hidden->playbuf._buffer) free(this->hidden->playbuf._buffer); if(this->hidden->playbuf._buffer) SDL_free(this->hidden->playbuf._buffer);
if(this->hidden->fillbuf._buffer) free(this->hidden->fillbuf._buffer); if(this->hidden->fillbuf._buffer) SDL_free(this->hidden->fillbuf._buffer);
_somFree( this->hidden->umsdev ); _somFree( this->hidden->umsdev );
free(this->hidden); SDL_free(this->hidden);
free(this); SDL_free(this);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -99,19 +99,19 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
* Allocate and initialize management storage and private management * Allocate and initialize management storage and private management
* storage for this SDL-using library. * storage for this SDL-using library.
*/ */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *)malloc((sizeof *this->hidden)); this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
fprintf(stderr, "Creating UMS Audio device\n"); fprintf(stderr, "Creating UMS Audio device\n");
#endif #endif
@ -204,9 +204,9 @@ static void UMS_PlayAudio(_THIS)
while(samplesToWrite>0); while(samplesToWrite>0);
SDL_LockAudio(); SDL_LockAudio();
memcpy( &swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer) ); SDL_memcpy( &swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer) );
memcpy( &this->hidden->playbuf, &this->hidden->fillbuf, sizeof(UMSAudioTypes_Buffer) ); SDL_memcpy( &this->hidden->playbuf, &this->hidden->fillbuf, sizeof(UMSAudioTypes_Buffer) );
memcpy( &this->hidden->fillbuf, &swpbuf, sizeof(UMSAudioTypes_Buffer) ); SDL_memcpy( &this->hidden->fillbuf, &swpbuf, sizeof(UMSAudioTypes_Buffer) );
SDL_UnlockAudio(); SDL_UnlockAudio();
#ifdef DEBUG_AUDIO #ifdef DEBUG_AUDIO
@ -330,10 +330,10 @@ static int UMS_OpenAudio(_THIS, SDL_AudioSpec *spec)
this->hidden->playbuf._length = 0; this->hidden->playbuf._length = 0;
this->hidden->playbuf._maximum = spec->size; this->hidden->playbuf._maximum = spec->size;
this->hidden->playbuf._buffer = (unsigned char*)malloc(spec->size); this->hidden->playbuf._buffer = (unsigned char*)SDL_malloc(spec->size);
this->hidden->fillbuf._length = 0; this->hidden->fillbuf._length = 0;
this->hidden->fillbuf._maximum = spec->size; this->hidden->fillbuf._maximum = spec->size;
this->hidden->fillbuf._buffer = (unsigned char*)malloc(spec->size); this->hidden->fillbuf._buffer = (unsigned char*)SDL_malloc(spec->size);
rc = UADSetBitsPerSample(this, bitsPerSample ); rc = UADSetBitsPerSample(this, bitsPerSample );
rc = UADSetDMABufferSize(this, frag_spec, &outBufSize ); rc = UADSetDMABufferSize(this, frag_spec, &outBufSize );

View file

@ -55,8 +55,8 @@ static int Audio_Available(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -64,20 +64,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
SDL_AudioDevice *this; SDL_AudioDevice *this;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = DIB_OpenAudio; this->OpenAudio = DIB_OpenAudio;
@ -125,8 +125,8 @@ static void SetMMerror(char *function, MMRESULT code)
wchar_t werrbuf[MAXERRORLENGTH]; wchar_t werrbuf[MAXERRORLENGTH];
#endif #endif
snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
len = strlen(errbuf); len = SDL_strlen(errbuf);
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
/* UNICODE version */ /* UNICODE version */
@ -213,7 +213,7 @@ void DIB_CloseAudio(_THIS)
} }
/* Free raw mixing buffer */ /* Free raw mixing buffer */
if ( mixbuf != NULL ) { if ( mixbuf != NULL ) {
free(mixbuf); SDL_free(mixbuf);
mixbuf = NULL; mixbuf = NULL;
} }
} }
@ -232,7 +232,7 @@ int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec)
mixbuf = NULL; mixbuf = NULL;
/* Set basic WAVE format parameters */ /* Set basic WAVE format parameters */
memset(&waveformat, 0, sizeof(waveformat)); SDL_memset(&waveformat, 0, sizeof(waveformat));
waveformat.wFormatTag = WAVE_FORMAT_PCM; waveformat.wFormatTag = WAVE_FORMAT_PCM;
/* Determine the audio parameters from the AudioSpec */ /* Determine the audio parameters from the AudioSpec */
@ -299,13 +299,13 @@ int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec)
} }
/* Create the sound buffers */ /* Create the sound buffers */
mixbuf = (Uint8 *)malloc(NUM_BUFFERS*spec->size); mixbuf = (Uint8 *)SDL_malloc(NUM_BUFFERS*spec->size);
if ( mixbuf == NULL ) { if ( mixbuf == NULL ) {
SDL_SetError("Out of memory"); SDL_SetError("Out of memory");
return(-1); return(-1);
} }
for ( i = 0; i < NUM_BUFFERS; ++i ) { for ( i = 0; i < NUM_BUFFERS; ++i ) {
memset(&wavebuf[i], 0, sizeof(wavebuf[i])); SDL_memset(&wavebuf[i], 0, sizeof(wavebuf[i]));
wavebuf[i].lpData = (LPSTR) &mixbuf[i*spec->size]; wavebuf[i].lpData = (LPSTR) &mixbuf[i*spec->size];
wavebuf[i].dwBufferLength = spec->size; wavebuf[i].dwBufferLength = spec->size;
wavebuf[i].dwFlags = WHDR_DONE; wavebuf[i].dwFlags = WHDR_DONE;

View file

@ -133,8 +133,8 @@ static int DX5_Load(void)
static void Audio_DeleteDevice(SDL_AudioDevice *device) static void Audio_DeleteDevice(SDL_AudioDevice *device)
{ {
DX5_Unload(); DX5_Unload();
free(device->hidden); SDL_free(device->hidden);
free(device); SDL_free(device);
} }
static SDL_AudioDevice *Audio_CreateDevice(int devindex) static SDL_AudioDevice *Audio_CreateDevice(int devindex)
@ -147,20 +147,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
} }
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
if ( this ) { if ( this ) {
memset(this, 0, (sizeof *this)); SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateAudioData *) this->hidden = (struct SDL_PrivateAudioData *)
malloc((sizeof *this->hidden)); SDL_malloc((sizeof *this->hidden));
} }
if ( (this == NULL) || (this->hidden == NULL) ) { if ( (this == NULL) || (this->hidden == NULL) ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
if ( this ) { if ( this ) {
free(this); SDL_free(this);
} }
return(0); return(0);
} }
memset(this->hidden, 0, (sizeof *this->hidden)); SDL_memset(this->hidden, 0, (sizeof *this->hidden));
/* Set the function pointers */ /* Set the function pointers */
this->OpenAudio = DX5_OpenAudio; this->OpenAudio = DX5_OpenAudio;
@ -223,13 +223,13 @@ static void SetDSerror(const char *function, int code)
error = "Function not supported"; error = "Function not supported";
break; break;
default: default:
snprintf(errbuf, SDL_arraysize(errbuf), SDL_snprintf(errbuf, SDL_arraysize(errbuf),
"%s: Unknown DirectSound error: 0x%x", "%s: Unknown DirectSound error: 0x%x",
function, code); function, code);
break; break;
} }
if ( ! errbuf[0] ) { if ( ! errbuf[0] ) {
snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error); SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
} }
SDL_SetError("%s", errbuf); SDL_SetError("%s", errbuf);
return; return;
@ -386,7 +386,7 @@ static void DX5_WaitDone(_THIS)
/* Wait for the playing chunk to finish */ /* Wait for the playing chunk to finish */
stream = this->GetAudioBuf(this); stream = this->GetAudioBuf(this);
if ( stream != NULL ) { if ( stream != NULL ) {
memset(stream, silence, mixlen); SDL_memset(stream, silence, mixlen);
this->PlayAudio(this); this->PlayAudio(this);
} }
this->WaitAudio(this); this->WaitAudio(this);
@ -435,7 +435,7 @@ static int CreatePrimary(LPDIRECTSOUND sndObj, HWND focus,
} }
/* Try to create the primary buffer */ /* Try to create the primary buffer */
memset(&format, 0, sizeof(format)); SDL_memset(&format, 0, sizeof(format));
format.dwSize = sizeof(format); format.dwSize = sizeof(format);
format.dwFlags=(DSBCAPS_PRIMARYBUFFER|DSBCAPS_GETCURRENTPOSITION2); format.dwFlags=(DSBCAPS_PRIMARYBUFFER|DSBCAPS_GETCURRENTPOSITION2);
format.dwFlags |= DSBCAPS_STICKYFOCUS; format.dwFlags |= DSBCAPS_STICKYFOCUS;
@ -451,7 +451,7 @@ static int CreatePrimary(LPDIRECTSOUND sndObj, HWND focus,
} }
/* Check the size of the fragment buffer */ /* Check the size of the fragment buffer */
memset(&caps, 0, sizeof(caps)); SDL_memset(&caps, 0, sizeof(caps));
caps.dwSize = sizeof(caps); caps.dwSize = sizeof(caps);
result = IDirectSoundBuffer_GetCaps(*sndbuf, &caps); result = IDirectSoundBuffer_GetCaps(*sndbuf, &caps);
if ( result != DS_OK ) { if ( result != DS_OK ) {
@ -516,7 +516,7 @@ static int CreateSecondary(LPDIRECTSOUND sndObj, HWND focus,
} }
/* Try to create the secondary buffer */ /* Try to create the secondary buffer */
memset(&format, 0, sizeof(format)); SDL_memset(&format, 0, sizeof(format));
format.dwSize = sizeof(format); format.dwSize = sizeof(format);
format.dwFlags = DSBCAPS_GETCURRENTPOSITION2; format.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
#ifdef USE_POSITION_NOTIFY #ifdef USE_POSITION_NOTIFY
@ -550,9 +550,9 @@ static int CreateSecondary(LPDIRECTSOUND sndObj, HWND focus,
DSBLOCK_ENTIREBUFFER); DSBLOCK_ENTIREBUFFER);
if ( result == DS_OK ) { if ( result == DS_OK ) {
if ( wavefmt->wBitsPerSample == 8 ) { if ( wavefmt->wBitsPerSample == 8 ) {
memset(pvAudioPtr1, 0x80, dwAudioBytes1); SDL_memset(pvAudioPtr1, 0x80, dwAudioBytes1);
} else { } else {
memset(pvAudioPtr1, 0x00, dwAudioBytes1); SDL_memset(pvAudioPtr1, 0x00, dwAudioBytes1);
} }
IDirectSoundBuffer_Unlock(*sndbuf, IDirectSoundBuffer_Unlock(*sndbuf,
(LPVOID)pvAudioPtr1, dwAudioBytes1, (LPVOID)pvAudioPtr1, dwAudioBytes1,
@ -584,7 +584,7 @@ static int CreateAudioEvent(_THIS)
} }
/* Allocate the notify structures */ /* Allocate the notify structures */
notify_positions = (DSBPOSITIONNOTIFY *)malloc(NUM_BUFFERS* notify_positions = (DSBPOSITIONNOTIFY *)SDL_malloc(NUM_BUFFERS*
sizeof(*notify_positions)); sizeof(*notify_positions));
if ( notify_positions == NULL ) { if ( notify_positions == NULL ) {
goto done; goto done;
@ -620,7 +620,7 @@ static int DX5_OpenAudio(_THIS, SDL_AudioSpec *spec)
WAVEFORMATEX waveformat; WAVEFORMATEX waveformat;
/* Set basic WAVE format parameters */ /* Set basic WAVE format parameters */
memset(&waveformat, 0, sizeof(waveformat)); SDL_memset(&waveformat, 0, sizeof(waveformat));
waveformat.wFormatTag = WAVE_FORMAT_PCM; waveformat.wFormatTag = WAVE_FORMAT_PCM;
/* Determine the audio parameters from the AudioSpec */ /* Determine the audio parameters from the AudioSpec */

View file

@ -117,15 +117,15 @@ SDL_CD *SDL_CDOpen(int drive)
SDL_SetError("Invalid CD-ROM drive index"); SDL_SetError("Invalid CD-ROM drive index");
return(NULL); return(NULL);
} }
cdrom = (SDL_CD *)malloc(sizeof(*cdrom)); cdrom = (SDL_CD *)SDL_malloc(sizeof(*cdrom));
if ( cdrom == NULL ) { if ( cdrom == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(NULL); return(NULL);
} }
memset(cdrom, 0, sizeof(*cdrom)); SDL_memset(cdrom, 0, sizeof(*cdrom));
cdrom->id = SDL_CDcaps.Open(drive); cdrom->id = SDL_CDcaps.Open(drive);
if ( cdrom->id < 0 ) { if ( cdrom->id < 0 ) {
free(cdrom); SDL_free(cdrom);
return(NULL); return(NULL);
} }
default_cdrom = cdrom; default_cdrom = cdrom;
@ -332,7 +332,7 @@ void SDL_CDClose(SDL_CD *cdrom)
return; return;
} }
SDL_CDcaps.Close(cdrom); SDL_CDcaps.Close(cdrom);
free(cdrom); SDL_free(cdrom);
default_cdrom = NULL; default_cdrom = NULL;
} }

View file

@ -2,7 +2,7 @@
SDL - Simple DirectMedia Layer SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or This library is SDL_free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.

View file

@ -128,12 +128,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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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
@ -149,7 +149,7 @@ static void CheckMounts()
struct vmount* ptr; struct vmount* ptr;
int ret; int ret;
buffer = (char*)malloc(10); buffer = (char*)SDL_malloc(10);
bufsz = 10; bufsz = 10;
if ( buffer==NULL ) if ( buffer==NULL )
{ {
@ -167,8 +167,8 @@ static void CheckMounts()
bufsz = *(int*)buffer; /* Required size is in first word. */ bufsz = *(int*)buffer; /* Required size is in first word. */
/* (whatever a word is in AIX 4.3.3) */ /* (whatever a word is in AIX 4.3.3) */
/* int seems to be OK in 32bit mode. */ /* int seems to be OK in 32bit mode. */
free(buffer); SDL_free(buffer);
buffer = (char*)malloc(bufsz); buffer = (char*)SDL_malloc(bufsz);
if ( buffer==NULL ) if ( buffer==NULL )
{ {
fprintf(stderr, fprintf(stderr,
@ -237,9 +237,9 @@ static int CheckNonmounts()
{ {
ret = getfsent_r ( &entry, &fsFile, &passNo ); ret = getfsent_r ( &entry, &fsFile, &passNo );
if ( ret == 0 ) { if ( ret == 0 ) {
char* l = strrchr(entry.fs_spec,'/'); char* l = SDL_strrchr(entry.fs_spec,'/');
if ( l != NULL ) { if ( l != NULL ) {
if ( !strncmp("cd",++l,2) ) { if ( !SDL_strncmp("cd",++l,2) ) {
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
fprintf(stderr, fprintf(stderr,
"Found unmounted CD ROM drive with device name %s\n", "Found unmounted CD ROM drive with device name %s\n",
@ -266,9 +266,9 @@ static int CheckNonmounts()
{ {
entry = getfsent(); entry = getfsent();
if ( entry != NULL ) { if ( entry != NULL ) {
char* l = strrchr(entry->fs_spec,'/'); char* l = SDL_strrchr(entry->fs_spec,'/');
if ( l != NULL ) { if ( l != NULL ) {
if ( !strncmp("cd",++l,2) ) { if ( !SDL_strncmp("cd",++l,2) ) {
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
fprintf(stderr,"Found unmounted CD ROM drive with device name %s", entry->fs_spec); fprintf(stderr,"Found unmounted CD ROM drive with device name %s", entry->fs_spec);
#endif #endif
@ -303,15 +303,15 @@ int SDL_SYS_CDInit(void)
SDL_CDcaps.Close = SDL_SYS_CDClose; SDL_CDcaps.Close = SDL_SYS_CDClose;
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = malloc(strlen(SDLcdrom)+1); cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if ( delim ) { if ( delim ) {
*delim++ = '\0'; *delim++ = '\0';
} }
@ -327,7 +327,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -369,13 +369,13 @@ static int SDL_SYS_CDOpen(int drive)
* 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*)malloc( strlen(SDL_cdlist[drive]+2) ); cdromname = (char*)SDL_malloc( SDL_strlen(SDL_cdlist[drive]+2) );
strcpy(cdromname,SDL_cdlist[drive]); SDL_strcpy(cdromname,SDL_cdlist[drive]);
lastsl = strrchr(cdromname,'/'); lastsl = SDL_strrchr(cdromname,'/');
if (lastsl) { if (lastsl) {
*lastsl = 0; *lastsl = 0;
strcat(cdromname,"/r"); strcat(cdromname,"/r");
lastsl = strrchr(SDL_cdlist[drive],'/'); lastsl = SDL_strrchr(SDL_cdlist[drive],'/');
if (lastsl) { if (lastsl) {
lastsl++; lastsl++;
strcat(cdromname,lastsl); strcat(cdromname,lastsl);
@ -459,7 +459,7 @@ static int SDL_SYS_CDOpen(int drive)
#endif #endif
} }
} }
free(cdromname); SDL_free(cdromname);
return fd; return fd;
} }
@ -650,7 +650,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -116,12 +116,12 @@ 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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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);
@ -165,15 +165,15 @@ int SDL_SYS_CDInit(void)
SDL_CDcaps.Close = SDL_SYS_CDClose; SDL_CDcaps.Close = SDL_SYS_CDClose;
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = (char *)malloc(strlen(SDLcdrom)+1); cdpath = (char *)SDL_malloc(SDL_strlen(SDLcdrom)+1);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if ( delim ) { if ( delim ) {
*delim++ = '\0'; *delim++ = '\0';
} }
@ -186,7 +186,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -223,7 +223,7 @@ int try_dir(const char *directory)
continue; continue;
if(entry.IsDirectory()) { if(entry.IsDirectory()) {
if(strcmp(e.name, "floppy") == 0) if(SDL_strcmp(e.name, "floppy") == 0)
continue; /* ignore floppy (it is not silent) */ continue; /* ignore floppy (it is not silent) */
int devfd = try_dir(name); int devfd = try_dir(name);
if(devfd >= 0) if(devfd >= 0)
@ -233,7 +233,7 @@ int try_dir(const char *directory)
int devfd; int devfd;
device_geometry g; device_geometry g;
if(strcmp(e.name, "raw") != 0) if(SDL_strcmp(e.name, "raw") != 0)
continue; /* ignore partitions */ continue; /* ignore partitions */
devfd = open(name, O_RDONLY); devfd = open(name, O_RDONLY);
@ -401,7 +401,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -229,12 +229,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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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
@ -267,15 +267,15 @@ int SDL_SYS_CDInit(void)
SDL_CDcaps.Close = SDL_SYS_CDClose; SDL_CDcaps.Close = SDL_SYS_CDClose;
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = malloc(strlen(SDLcdrom)+1); cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if ( delim ) { if ( delim ) {
*delim++ = '\0'; *delim++ = '\0';
} }
@ -288,7 +288,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -304,7 +304,7 @@ int SDL_SYS_CDInit(void)
exists = 1; exists = 1;
for ( j=checklist[i][1]; exists; ++j ) { for ( j=checklist[i][1]; exists; ++j ) {
sprintf(drive, "/dev/%sc", &checklist[i][3]); sprintf(drive, "/dev/%sc", &checklist[i][3]);
insert = strchr(drive, '?'); insert = SDL_strchr(drive, '?');
if ( insert != NULL ) { if ( insert != NULL ) {
*insert = j; *insert = j;
} }
@ -360,7 +360,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
ntracks = last_track - first_track + 1; ntracks = last_track - first_track + 1;
cdrom->numtracks = ntracks; cdrom->numtracks = ntracks;
toc_size = 4 + (ntracks + 1) * 8; toc_size = 4 + (ntracks + 1) * 8;
toc = (u_char *)malloc(toc_size); toc = (u_char *)SDL_malloc(toc_size);
if (toc == NULL) if (toc == NULL)
return(-1); return(-1);
bzero(cdb, sizeof (cdb)); bzero(cdb, sizeof (cdb));
@ -373,7 +373,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
&sus); &sus);
if (sts < 0) if (sts < 0)
{ {
free(toc); SDL_free(toc);
return(-1); return(-1);
} }
@ -393,7 +393,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
cdrom->track[i-1].length = cdrom->track[i].offset - cdrom->track[i-1].length = cdrom->track[i].offset -
cdrom->track[i-1].offset; cdrom->track[i-1].offset;
} }
free(toc); SDL_free(toc);
return(0); return(0);
} }
@ -535,7 +535,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
} }
SDL_numcds = 0; SDL_numcds = 0;

View file

@ -114,12 +114,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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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
@ -153,15 +153,15 @@ int SDL_SYS_CDInit(void)
SDL_CDcaps.Close = SDL_SYS_CDClose; SDL_CDcaps.Close = SDL_SYS_CDClose;
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = malloc(strlen(SDLcdrom)+1); cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if ( delim ) { if ( delim ) {
*delim++ = '\0'; *delim++ = '\0';
} }
@ -174,7 +174,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -190,7 +190,7 @@ int SDL_SYS_CDInit(void)
exists = 1; exists = 1;
for ( j=checklist[i][1]; exists; ++j ) { for ( j=checklist[i][1]; exists; ++j ) {
sprintf(drive, "/dev/%sc", &checklist[i][3]); sprintf(drive, "/dev/%sc", &checklist[i][3]);
insert = strchr(drive, '?'); insert = SDL_strchr(drive, '?');
if ( insert != NULL ) { if ( insert != NULL ) {
*insert = j; *insert = j;
} }
@ -398,7 +398,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -142,7 +142,7 @@ static int CheckDrive(char *drive, char *mnttype, struct stat *stbuf)
} }
#ifdef USE_MNTENT #ifdef USE_MNTENT
/* Even if we can't read it, it might be mounted */ /* Even if we can't read it, it might be mounted */
else if ( mnttype && (strcmp(mnttype, MNTTYPE_CDROM) == 0) ) { else if ( mnttype && (SDL_strcmp(mnttype, MNTTYPE_CDROM) == 0) ) {
is_cd = 1; is_cd = 1;
} }
#endif #endif
@ -170,12 +170,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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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
@ -198,45 +198,45 @@ static void CheckMounts(const char *mtab)
char *mnt_dev; char *mnt_dev;
while ( (mntent=getmntent(mntfp)) != NULL ) { while ( (mntent=getmntent(mntfp)) != NULL ) {
mnt_type = malloc(strlen(mntent->mnt_type) + 1); mnt_type = SDL_malloc(SDL_strlen(mntent->mnt_type) + 1);
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 = malloc(strlen(mntent->mnt_fsname) + 1); mnt_dev = SDL_malloc(SDL_strlen(mntent->mnt_fsname) + 1);
if (mnt_dev == NULL) { if (mnt_dev == NULL) {
free(mnt_type); SDL_free(mnt_type);
continue; continue;
} }
strcpy(mnt_type, mntent->mnt_type); SDL_strcpy(mnt_type, mntent->mnt_type);
strcpy(mnt_dev, mntent->mnt_fsname); SDL_strcpy(mnt_dev, mntent->mnt_fsname);
/* Handle "supermount" filesystem mounts */ /* Handle "supermount" filesystem mounts */
if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) { if ( SDL_strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
tmp = strstr(mntent->mnt_opts, "fs="); tmp = SDL_strstr(mntent->mnt_opts, "fs=");
if ( tmp ) { if ( tmp ) {
free(mnt_type); SDL_free(mnt_type);
mnt_type = strdup(tmp + strlen("fs=")); mnt_type = strdup(tmp + SDL_strlen("fs="));
if ( mnt_type ) { if ( mnt_type ) {
tmp = strchr(mnt_type, ','); tmp = SDL_strchr(mnt_type, ',');
if ( tmp ) { if ( tmp ) {
*tmp = '\0'; *tmp = '\0';
} }
} }
} }
tmp = strstr(mntent->mnt_opts, "dev="); tmp = SDL_strstr(mntent->mnt_opts, "dev=");
if ( tmp ) { if ( tmp ) {
free(mnt_dev); SDL_free(mnt_dev);
mnt_dev = strdup(tmp + strlen("dev=")); mnt_dev = strdup(tmp + SDL_strlen("dev="));
if ( mnt_dev ) { if ( mnt_dev ) {
tmp = strchr(mnt_dev, ','); tmp = SDL_strchr(mnt_dev, ',');
if ( tmp ) { if ( tmp ) {
*tmp = '\0'; *tmp = '\0';
} }
} }
} }
} }
if ( strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) { if ( SDL_strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) {
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
fprintf(stderr, "Checking mount path from %s: %s mounted on %s of %s\n", fprintf(stderr, "Checking mount path from %s: %s mounted on %s of %s\n",
mtab, mnt_dev, mntent->mnt_dir, mnt_type); mtab, mnt_dev, mntent->mnt_dir, mnt_type);
@ -245,8 +245,8 @@ static void CheckMounts(const char *mtab)
AddDrive(mnt_dev, &stbuf); AddDrive(mnt_dev, &stbuf);
} }
} }
free(mnt_dev); SDL_free(mnt_dev);
free(mnt_type); SDL_free(mnt_type);
} }
endmntent(mntfp); endmntent(mntfp);
} }
@ -277,15 +277,15 @@ int SDL_SYS_CDInit(void)
SDL_CDcaps.Close = SDL_SYS_CDClose; SDL_CDcaps.Close = SDL_SYS_CDClose;
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = malloc(strlen(SDLcdrom)+1); cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if ( delim ) { if ( delim ) {
*delim++ = '\0'; *delim++ = '\0';
} }
@ -301,7 +301,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -337,7 +337,7 @@ int SDL_SYS_CDInit(void)
exists = 1; exists = 1;
for ( j=checklist[i][1]; exists; ++j ) { for ( j=checklist[i][1]; exists; ++j ) {
sprintf(drive, "/dev/%s", &checklist[i][3]); sprintf(drive, "/dev/%s", &checklist[i][3]);
insert = strchr(drive, '?'); insert = SDL_strchr(drive, '?');
if ( insert != NULL ) { if ( insert != NULL ) {
*insert = j; *insert = j;
} }
@ -551,7 +551,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -160,7 +160,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
long i, leadout; long i, leadout;
/* Get the number of tracks on the CD by examining the TOC */ /* Get the number of tracks on the CD by examining the TOC */
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kReadTOC; cdpb.csCode = kReadTOC;
@ -181,7 +181,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
/* Get the lead out area of the CD by examining the TOC */ /* Get the lead out area of the CD by examining the TOC */
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kReadTOC; cdpb.csCode = kReadTOC;
@ -197,8 +197,8 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
SDL_SYS_BCDToShort(cdpb.csParam.bytes[2])); SDL_SYS_BCDToShort(cdpb.csParam.bytes[2]));
/* Get an array of track locations by examining the TOC */ /* Get an array of track locations by examining the TOC */
memset(tracks, 0, sizeof(tracks)); SDL_memset(tracks, 0, sizeof(tracks));
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kReadTOC; cdpb.csCode = kReadTOC;
@ -255,7 +255,7 @@ static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
if ( ! get_drivenum(cdrom->id) ) { if ( ! get_drivenum(cdrom->id) ) {
return(CD_TRAYEMPTY); return(CD_TRAYEMPTY);
} }
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kReadTOC; cdpb.csCode = kReadTOC;
@ -276,7 +276,7 @@ static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
if (1 || SDL_cdlist[cdrom->id].hasAudio) { if (1 || SDL_cdlist[cdrom->id].hasAudio) {
/* Get the current playback status */ /* Get the current playback status */
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioStatus; cdpb.csCode = kAudioStatus;
@ -335,7 +335,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
} }
/* Specify the AudioCD playback mode */ /* Specify the AudioCD playback mode */
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kSetPlayMode; cdpb.csCode = kSetPlayMode;
@ -346,7 +346,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
#if 1 #if 1
/* Specify the end of audio playback */ /* Specify the end of audio playback */
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioStop; cdpb.csCode = kAudioStop;
@ -358,7 +358,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
} }
/* Specify the start of audio playback, and start it */ /* Specify the start of audio playback, and start it */
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioPlay; cdpb.csCode = kAudioPlay;
@ -373,7 +373,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
#else #else
/* Specify the end of audio playback */ /* Specify the end of audio playback */
FRAMES_TO_MSF(start+length, &m, &s, &f); FRAMES_TO_MSF(start+length, &m, &s, &f);
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioStop; cdpb.csCode = kAudioStop;
@ -388,7 +388,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
/* Specify the start of audio playback, and start it */ /* Specify the start of audio playback, and start it */
FRAMES_TO_MSF(start, &m, &s, &f); FRAMES_TO_MSF(start, &m, &s, &f);
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioPlay; cdpb.csCode = kAudioPlay;
@ -411,7 +411,7 @@ static int SDL_SYS_CDPause(SDL_CD *cdrom)
{ {
CDCntrlParam cdpb; CDCntrlParam cdpb;
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioPause; cdpb.csCode = kAudioPause;
@ -429,7 +429,7 @@ static int SDL_SYS_CDResume(SDL_CD *cdrom)
{ {
CDCntrlParam cdpb; CDCntrlParam cdpb;
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioPause; cdpb.csCode = kAudioPause;
@ -447,7 +447,7 @@ static int SDL_SYS_CDStop(SDL_CD *cdrom)
{ {
CDCntrlParam cdpb; CDCntrlParam cdpb;
memset(&cdpb, 0, sizeof(cdpb)); SDL_memset(&cdpb, 0, sizeof(cdpb));
cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cdpb.csCode = kAudioStop; cdpb.csCode = kAudioStop;
@ -481,7 +481,7 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom)
} }
/* Does drive contain mounted volume? If not, skip */ /* Does drive contain mounted volume? If not, skip */
memset(&hpb, 0, sizeof(hpb)); SDL_memset(&hpb, 0, sizeof(hpb));
hpb.volumeParam.ioVRefNum = driveElem->dQDrive; hpb.volumeParam.ioVRefNum = driveElem->dQDrive;
if ( PBHGetVInfoSync(&hpb) != noErr ) { if ( PBHGetVInfoSync(&hpb) != noErr ) {
continue; continue;
@ -495,7 +495,7 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom)
/* If no disk is present, just eject the tray */ /* If no disk is present, just eject the tray */
if (! disk) { if (! disk) {
memset(&cpb, 0, sizeof(cpb)); SDL_memset(&cpb, 0, sizeof(cpb));
cpb.cntrlParam.ioVRefNum = 0; /* No Drive */ cpb.cntrlParam.ioVRefNum = 0; /* No Drive */
cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
cpb.cntrlParam.csCode = kEjectTheDisc; cpb.cntrlParam.csCode = kEjectTheDisc;
@ -516,6 +516,6 @@ static void SDL_SYS_CDClose(SDL_CD *cdrom)
void SDL_SYS_CDQuit(void) void SDL_SYS_CDQuit(void)
{ {
while(SDL_numcds--) while(SDL_numcds--)
memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0])); SDL_memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0]));
} }

View file

@ -64,7 +64,7 @@ static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inD
if (afp->mConnected) if (afp->mConnected)
return 0 ; return 0 ;
memcpy(&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit)); SDL_memcpy(&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit));
OSStatus result = noErr; OSStatus result = noErr;
@ -155,7 +155,7 @@ void delete_AudioFilePlayer(AudioFilePlayer *afp)
FSClose (afp->mForkRefNum); FSClose (afp->mForkRefNum);
afp->mForkRefNum = 0; afp->mForkRefNum = 0;
} }
free(afp); SDL_free(afp);
} }
} }
@ -304,10 +304,10 @@ AudioFilePlayer *new_AudioFilePlayer (const FSRef *inFileRef)
{ {
SInt64 fileDataSize = 0; SInt64 fileDataSize = 0;
AudioFilePlayer *afp = (AudioFilePlayer *) malloc(sizeof (AudioFilePlayer)); AudioFilePlayer *afp = (AudioFilePlayer *) SDL_malloc(sizeof (AudioFilePlayer));
if (afp == NULL) if (afp == NULL)
return NULL; return NULL;
memset(afp, '\0', sizeof (*afp)); SDL_memset(afp, '\0', sizeof (*afp));
#define SET_AUDIOFILEPLAYER_METHOD(m) afp->m = AudioFilePlayer_##m #define SET_AUDIOFILEPLAYER_METHOD(m) afp->m = AudioFilePlayer_##m
SET_AUDIOFILEPLAYER_METHOD(SetDestination); SET_AUDIOFILEPLAYER_METHOD(SetDestination);
@ -326,7 +326,7 @@ AudioFilePlayer *new_AudioFilePlayer (const FSRef *inFileRef)
if (!afp->OpenFile (afp, inFileRef, &fileDataSize)) if (!afp->OpenFile (afp, inFileRef, &fileDataSize))
{ {
free(afp); SDL_free(afp);
return NULL; return NULL;
} }

View file

@ -86,7 +86,7 @@ static int FileReaderThread_TryNextRead (FileReaderThread *frt, AudioFileManager
FileData *i = frt->mFileData; FileData *i = frt->mFileData;
FileData *prev = NULL; FileData *prev = NULL;
FileData *newfd = (FileData *) malloc(sizeof (FileData)); FileData *newfd = (FileData *) SDL_malloc(sizeof (FileData));
newfd->obj = inItem; newfd->obj = inItem;
newfd->next = NULL; newfd->next = NULL;
@ -136,7 +136,7 @@ static void FileReaderThread_RemoveReader (FileReaderThread *frt, AudioFileMa
frt->mFileData = next; frt->mFileData = next;
else else
prev->next = next; prev->next = next;
free(i); SDL_free(i);
} }
i = next; i = next;
} }
@ -279,7 +279,7 @@ static void FileReaderThread_ReadNextChunk (FileReaderThread *frt)
{ {
FileData *next = frt->mFileData->next; FileData *next = frt->mFileData->next;
theItem = frt->mFileData->obj; theItem = frt->mFileData->obj;
free(frt->mFileData); SDL_free(frt->mFileData);
frt->mFileData = next; frt->mFileData = next;
} }
@ -330,21 +330,21 @@ void delete_FileReaderThread(FileReaderThread *frt)
if (frt != NULL) if (frt != NULL)
{ {
delete_SDLOSXCAGuard(frt->mGuard); delete_SDLOSXCAGuard(frt->mGuard);
free(frt); SDL_free(frt);
} }
} }
FileReaderThread *new_FileReaderThread () FileReaderThread *new_FileReaderThread ()
{ {
FileReaderThread *frt = (FileReaderThread *) malloc(sizeof (FileReaderThread)); FileReaderThread *frt = (FileReaderThread *) SDL_malloc(sizeof (FileReaderThread));
if (frt == NULL) if (frt == NULL)
return NULL; return NULL;
memset(frt, '\0', sizeof (*frt)); SDL_memset(frt, '\0', sizeof (*frt));
frt->mGuard = new_SDLOSXCAGuard(); frt->mGuard = new_SDLOSXCAGuard();
if (frt->mGuard == NULL) if (frt->mGuard == NULL)
{ {
free(frt); SDL_free(frt);
return NULL; return NULL;
} }
@ -549,7 +549,7 @@ void delete_AudioFileManager (AudioFileManager *afm)
free (afm->mFileBuffer); free (afm->mFileBuffer);
} }
free(afm); SDL_free(afm);
} }
} }
@ -568,10 +568,10 @@ AudioFileManager *new_AudioFileManager(AudioFilePlayer *inParent,
return NULL; return NULL;
} }
afm = (AudioFileManager *) malloc(sizeof (AudioFileManager)); afm = (AudioFileManager *) SDL_malloc(sizeof (AudioFileManager));
if (afm == NULL) if (afm == NULL)
return NULL; return NULL;
memset(afm, '\0', sizeof (*afm)); SDL_memset(afm, '\0', sizeof (*afm));
#define SET_AUDIOFILEMANAGER_METHOD(m) afm->m = AudioFileManager_##m #define SET_AUDIOFILEMANAGER_METHOD(m) afm->m = AudioFileManager_##m
SET_AUDIOFILEMANAGER_METHOD(Disconnect); SET_AUDIOFILEMANAGER_METHOD(Disconnect);

View file

@ -147,10 +147,10 @@ static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag)
SDLOSXCAGuard *new_SDLOSXCAGuard(void) SDLOSXCAGuard *new_SDLOSXCAGuard(void)
{ {
SDLOSXCAGuard *cag = (SDLOSXCAGuard *) malloc(sizeof (SDLOSXCAGuard)); SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard));
if (cag == NULL) if (cag == NULL)
return NULL; return NULL;
memset(cag, '\0', sizeof (*cag)); SDL_memset(cag, '\0', sizeof (*cag));
#define SET_SDLOSXCAGUARD_METHOD(m) cag->m = SDLOSXCAGuard_##m #define SET_SDLOSXCAGUARD_METHOD(m) cag->m = SDLOSXCAGuard_##m
SET_SDLOSXCAGUARD_METHOD(Lock); SET_SDLOSXCAGUARD_METHOD(Lock);
@ -176,7 +176,7 @@ void delete_SDLOSXCAGuard(SDLOSXCAGuard *cag)
{ {
pthread_mutex_destroy(&cag->mMutex); pthread_mutex_destroy(&cag->mMutex);
pthread_cond_destroy(&cag->mCondVar); pthread_cond_destroy(&cag->mCondVar);
free(cag); SDL_free(cag);
} }
} }

View file

@ -119,12 +119,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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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
@ -162,15 +162,15 @@ int SDL_SYS_CDInit(void)
SDL_CDcaps.Close = SDL_SYS_CDClose; SDL_CDcaps.Close = SDL_SYS_CDClose;
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = malloc(strlen(SDLcdrom)+1); cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if ( delim ) { if ( delim ) {
*delim++ = '\0'; *delim++ = '\0';
} }
@ -183,7 +183,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -199,7 +199,7 @@ int SDL_SYS_CDInit(void)
exists = 1; exists = 1;
for ( j=checklist[i][1]; exists; ++j ) { for ( j=checklist[i][1]; exists; ++j ) {
sprintf(drive, "/dev/%s", &checklist[i][3]); sprintf(drive, "/dev/%s", &checklist[i][3]);
insert = strchr(drive, '?'); insert = SDL_strchr(drive, '?');
if ( insert != NULL ) { if ( insert != NULL ) {
*insert = j; *insert = j;
} }
@ -407,7 +407,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -81,7 +81,7 @@ SDL_CDcaps.Close = SDL_SYS_CDClose;
/* Get the number of CD ROMs in the System */ /* Get the number of CD ROMs in the System */
/* Clean SysInfo structure */ /* Clean SysInfo structure */
memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS)); SDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS));
/* Prepare structure to Ask Numer of Audio CDs */ /* Prepare structure to Ask Numer of Audio CDs */
msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */
msp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */ msp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */
@ -98,13 +98,13 @@ 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 *)malloc(strlen(SysInfoRet)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(SysInfoRet)+1);
if ( SDL_cdlist[i] == NULL ) if ( SDL_cdlist[i] == NULL )
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
strcpy(SDL_cdlist[i], SysInfoRet); SDL_strcpy(SDL_cdlist[i], SysInfoRet);
} }
return(0); return(0);
} }
@ -166,7 +166,7 @@ if ( cdrom->numtracks > SDL_MAX_TRACKS )
cdrom->numtracks = SDL_MAX_TRACKS; cdrom->numtracks = SDL_MAX_TRACKS;
} }
/* Alocate space for TOC data */ /* Alocate space for TOC data */
mtr = (MCI_TOC_REC *)malloc(cdrom->numtracks*sizeof(MCI_TOC_REC)); mtr = (MCI_TOC_REC *)SDL_malloc(cdrom->numtracks*sizeof(MCI_TOC_REC));
if ( mtr == NULL ) if ( mtr == NULL )
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
@ -178,7 +178,7 @@ mtp.ulBufSize = cdrom->numtracks*sizeof(MCI_TOC_REC);
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_GETTOC,MCI_WAIT,&mtp, 0)) != MCIERR_SUCCESS) if (LOUSHORT(mciSendCommand(cdrom->id,MCI_GETTOC,MCI_WAIT,&mtp, 0)) != MCIERR_SUCCESS)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
free(mtr); SDL_free(mtr);
return(CD_ERROR); return(CD_ERROR);
} }
/* Fill SDL Tracks Structure */ /* Fill SDL Tracks Structure */
@ -193,7 +193,7 @@ for (i=0; i<cdrom->numtracks; i++)
msp.ulValue = (ULONG)((mtr+i)->TrackNum); /* Track Number? */ msp.ulValue = (ULONG)((mtr+i)->TrackNum); /* Track Number? */
if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS)
{ {
free(mtr); SDL_free(mtr);
return (CD_ERROR); return (CD_ERROR);
} }
if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK; if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK;
@ -203,7 +203,7 @@ for (i=0; i<cdrom->numtracks; i++)
/* Set Track Offset */ /* Set Track Offset */
cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr); cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr);
} }
free(mtr); SDL_free(mtr);
return(0); return(0);
} }
@ -386,7 +386,7 @@ if ( SDL_numcds > 0 )
{ {
for ( i=0; i<SDL_numcds; ++i ) for ( i=0; i<SDL_numcds; ++i )
{ {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -125,13 +125,13 @@ 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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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
@ -177,15 +177,15 @@ int SDL_SYS_CDInit(void)
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = malloc(strlen(SDLcdrom)+1); cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
if ( cdpath != NULL ) { if ( cdpath != NULL ) {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if ( delim ) { if ( delim ) {
*delim++ = '\0'; *delim++ = '\0';
} }
@ -198,7 +198,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while ( SDLcdrom ); } while ( SDLcdrom );
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -214,9 +214,9 @@ int SDL_SYS_CDInit(void)
devdir = opendir(checklist[i].dir); devdir = opendir(checklist[i].dir);
if (devdir) { if (devdir) {
name_len = strlen(checklist[i].name); name_len = SDL_strlen(checklist[i].name);
while (devent = readdir(devdir)) while (devent = readdir(devdir))
if (memcmp(checklist[i].name, devent->d_name, name_len) == 0) if (SDL_memcmp(checklist[i].name, devent->d_name, name_len) == 0)
if (devent->d_name[devent->d_namlen-1] == 'c') { if (devent->d_name[devent->d_namlen-1] == 'c') {
sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name); sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name);
#ifdef DEBUG_CDROM #ifdef DEBUG_CDROM
@ -234,8 +234,8 @@ int SDL_SYS_CDInit(void)
} }
/* /*
SDLcdrom=malloc(sizeof(char) * 32); SDLcdrom=SDL_malloc(sizeof(char) * 32);
strcpy(SDLcdrom,"/dev/rdisk/cdrom0c"); SDL_strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
SDL_cdlist[0] = SDLcdrom; SDL_cdlist[0] = SDLcdrom;
stat(SDLcdrom, &stbuf); stat(SDLcdrom, &stbuf);
SDL_cdmode[0] = stbuf.st_rdev; SDL_cdmode[0] = stbuf.st_rdev;
@ -449,7 +449,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -128,13 +128,13 @@ 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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if (SDL_cdlist[i] == NULL) if (SDL_cdlist[i] == NULL)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); SDL_strcpy(SDL_cdlist[i], drive);
SDL_cdmode[i] = stbuf->st_rdev; SDL_cdmode[i] = stbuf->st_rdev;
++SDL_numcds; ++SDL_numcds;
} }
@ -169,18 +169,18 @@ int SDL_SYS_CDInit(void)
} }
/* Look in the environment for our CD-ROM drive list */ /* Look in the environment for our CD-ROM drive list */
SDLcdrom = 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 = malloc(strlen(SDLcdrom)+1); cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
if (cdpath != NULL) if (cdpath != NULL)
{ {
strcpy(cdpath, SDLcdrom); SDL_strcpy(cdpath, SDLcdrom);
SDLcdrom = cdpath; SDLcdrom = cdpath;
do { do {
delim = strchr(SDLcdrom, ':'); delim = SDL_strchr(SDLcdrom, ':');
if (delim) if (delim)
{ {
*delim++ = '\0'; *delim++ = '\0';
@ -198,7 +198,7 @@ int SDL_SYS_CDInit(void)
SDLcdrom = NULL; SDLcdrom = NULL;
} }
} while (SDLcdrom); } while (SDLcdrom);
free(cdpath); SDL_free(cdpath);
} }
/* If we found our drives, there's nothing left to do */ /* If we found our drives, there's nothing left to do */
@ -219,7 +219,7 @@ int SDL_SYS_CDInit(void)
for ( j=checklist[i][1]; exists; ++j ) for ( j=checklist[i][1]; exists; ++j )
{ {
sprintf(drive, "/dev/%s", &checklist[i][3]); sprintf(drive, "/dev/%s", &checklist[i][3]);
insert = strchr(drive, '?'); insert = SDL_strchr(drive, '?');
if (insert != NULL) if (insert != NULL)
{ {
*insert = j; *insert = j;
@ -346,7 +346,7 @@ static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
/* if media exists, then do other stuff */ /* if media exists, then do other stuff */
memset(&info, 0x00, sizeof(info)); SDL_memset(&info, 0x00, sizeof(info));
info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION; info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION;
do { do {
@ -544,7 +544,7 @@ void SDL_SYS_CDQuit(void)
{ {
for (i=0; i<SDL_numcds; ++i) for (i=0; i<SDL_numcds; ++i)
{ {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -66,12 +66,12 @@ 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 *)malloc(strlen(drive)+1); SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
if ( SDL_cdlist[i] == NULL ) { if ( SDL_cdlist[i] == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return; return;
} }
strcpy(SDL_cdlist[i], drive); 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);
@ -99,12 +99,12 @@ int SDL_SYS_CDInit(void)
/* Scan the system for CD-ROM drives */ /* Scan the system for CD-ROM drives */
for ( i='A'; i<='Z'; ++i ) { for ( i='A'; i<='Z'; ++i ) {
snprintf(drive, SDL_arraysize(drive), "%c:\\", i); SDL_snprintf(drive, SDL_arraysize(drive), "%c:\\", i);
if ( GetDriveType(drive) == DRIVE_CDROM ) { if ( GetDriveType(drive) == DRIVE_CDROM ) {
AddDrive(drive); AddDrive(drive);
} }
} }
memset(SDL_mciID, 0, sizeof(SDL_mciID)); SDL_memset(SDL_mciID, 0, sizeof(SDL_mciID));
return(0); return(0);
} }
@ -377,7 +377,7 @@ void SDL_SYS_CDQuit(void)
if ( SDL_numcds > 0 ) { if ( SDL_numcds > 0 ) {
for ( i=0; i<SDL_numcds; ++i ) { for ( i=0; i<SDL_numcds; ++i ) {
free(SDL_cdlist[i]); SDL_free(SDL_cdlist[i]);
} }
SDL_numcds = 0; SDL_numcds = 0;
} }

View file

@ -73,7 +73,7 @@ int SDL_PrivateAppActive(Uint8 gain, Uint8 state)
posted = 0; posted = 0;
if ( SDL_ProcessEvents[SDL_ACTIVEEVENT] == SDL_ENABLE ) { if ( SDL_ProcessEvents[SDL_ACTIVEEVENT] == SDL_ENABLE ) {
SDL_Event event; SDL_Event event;
memset(&event, 0, sizeof(event)); SDL_memset(&event, 0, sizeof(event));
event.type = SDL_ACTIVEEVENT; event.type = SDL_ACTIVEEVENT;
event.active.gain = gain; event.active.gain = gain;
event.active.state = state; event.active.state = state;

View file

@ -151,7 +151,7 @@ static int SDL_StartEventThread(Uint32 flags)
{ {
/* Reset everything to zero */ /* Reset everything to zero */
SDL_EventThread = NULL; SDL_EventThread = NULL;
memset(&SDL_EventLock, 0, sizeof(SDL_EventLock)); SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
/* Create the lock and set ourselves active */ /* Create the lock and set ourselves active */
#ifndef DISABLE_THREADS #ifndef DISABLE_THREADS
@ -239,7 +239,7 @@ int SDL_StartEventLoop(Uint32 flags)
/* No filter to start with, process most event types */ /* No filter to start with, process most event types */
SDL_EventOK = NULL; SDL_EventOK = NULL;
memset(SDL_ProcessEvents,SDL_ENABLE,sizeof(SDL_ProcessEvents)); SDL_memset(SDL_ProcessEvents,SDL_ENABLE,sizeof(SDL_ProcessEvents));
SDL_eventstate = ~0; SDL_eventstate = ~0;
/* It's not save to call SDL_EventState() yet */ /* It's not save to call SDL_EventState() yet */
SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT); SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT);
@ -306,7 +306,7 @@ static int SDL_CutEvent(int spot)
{ {
int here, next; int here, next;
/* This can probably be optimized with memcpy() -- careful! */ /* This can probably be optimized with SDL_memcpy() -- careful! */
if ( --SDL_EventQ.tail < 0 ) { if ( --SDL_EventQ.tail < 0 ) {
SDL_EventQ.tail = MAXEVENTS-1; SDL_EventQ.tail = MAXEVENTS-1;
} }
@ -493,7 +493,7 @@ int SDL_PrivateSysWMEvent(SDL_SysWMmsg *message)
posted = 0; posted = 0;
if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
SDL_Event event; SDL_Event event;
memset(&event, 0, sizeof(event)); SDL_memset(&event, 0, sizeof(event));
event.type = SDL_SYSWMEVENT; event.type = SDL_SYSWMEVENT;
event.syswm.msg = message; event.syswm.msg = message;
if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {

View file

@ -60,8 +60,8 @@ int SDL_KeyboardInit(void)
/* Initialize the tables */ /* Initialize the tables */
SDL_ModState = KMOD_NONE; SDL_ModState = KMOD_NONE;
memset(keynames, 0, sizeof(keynames)); SDL_memset(keynames, 0, sizeof(keynames));
memset(SDL_KeyState, 0, sizeof(SDL_KeyState)); SDL_memset(SDL_KeyState, 0, sizeof(SDL_KeyState));
video->InitOSKeymap(this); video->InitOSKeymap(this);
SDL_EnableKeyRepeat(0, 0); SDL_EnableKeyRepeat(0, 0);
@ -319,7 +319,7 @@ void SDL_ResetKeyboard(void)
SDL_keysym keysym; SDL_keysym keysym;
SDLKey key; SDLKey key;
memset(&keysym, 0, (sizeof keysym)); SDL_memset(&keysym, 0, (sizeof keysym));
for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) { for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) {
if ( SDL_KeyState[key] == SDL_PRESSED ) { if ( SDL_KeyState[key] == SDL_PRESSED ) {
keysym.sym = key; keysym.sym = key;
@ -376,7 +376,7 @@ int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *keysym)
int posted, repeatable; int posted, repeatable;
Uint16 modstate; Uint16 modstate;
memset(&event, 0, sizeof(event)); SDL_memset(&event, 0, sizeof(event));
#if 0 #if 0
printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym), printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym),

View file

@ -182,7 +182,7 @@ printf("Mouse event didn't change state - dropped!\n");
posted = 0; posted = 0;
if ( SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE ) { if ( SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE ) {
SDL_Event event; SDL_Event event;
memset(&event, 0, sizeof(event)); SDL_memset(&event, 0, sizeof(event));
event.type = SDL_MOUSEMOTION; event.type = SDL_MOUSEMOTION;
event.motion.state = buttonstate; event.motion.state = buttonstate;
event.motion.x = X; event.motion.x = X;
@ -204,7 +204,7 @@ int SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y)
int move_mouse; int move_mouse;
Uint8 buttonstate; Uint8 buttonstate;
memset(&event, 0, sizeof(event)); SDL_memset(&event, 0, sizeof(event));
/* Check parameters */ /* Check parameters */
if ( x || y ) { if ( x || y ) {

View file

@ -2,7 +2,7 @@
SDL - Simple DirectMedia Layer SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or This library is SDL_free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.

View file

@ -120,7 +120,7 @@ static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)
total_bytes = mem_available; total_bytes = mem_available;
} }
memcpy(ptr, context->hidden.mem.here, total_bytes); SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
context->hidden.mem.here += total_bytes; context->hidden.mem.here += total_bytes;
return (total_bytes / size); return (total_bytes / size);
@ -130,7 +130,7 @@ static int mem_write(SDL_RWops *context, const void *ptr, int size, int num)
if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) { if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) {
num = (context->hidden.mem.stop-context->hidden.mem.here)/size; num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
} }
memcpy(context->hidden.mem.here, ptr, num*size); SDL_memcpy(context->hidden.mem.here, ptr, num*size);
context->hidden.mem.here += num*size; context->hidden.mem.here += num*size;
return(num); return(num);
} }
@ -162,8 +162,8 @@ static int in_sdl = 0;
*/ */
static char *unix_to_mac(const char *file) static char *unix_to_mac(const char *file)
{ {
int flen = strlen(file); int flen = SDL_strlen(file);
char *path = malloc(flen + 2); char *path = SDL_malloc(flen + 2);
const char *src = file; const char *src = file;
char *dst = path; char *dst = path;
if(*src == '/') { if(*src == '/') {
@ -175,7 +175,7 @@ static char *unix_to_mac(const char *file)
*dst++ = ':'; /* relative paths begin with ':' */ *dst++ = ':'; /* relative paths begin with ':' */
} }
while(src < file + flen) { while(src < file + flen) {
const char *end = strchr(src, '/'); const char *end = SDL_strchr(src, '/');
int len; int len;
if(!end) if(!end)
end = file + flen; /* last component */ end = file + flen; /* last component */
@ -186,7 +186,7 @@ static char *unix_to_mac(const char *file)
if(len == 2 && src[0] == '.' && src[1] == '.') { if(len == 2 && src[0] == '.' && src[1] == '.') {
/* replace .. with the empty string */ /* replace .. with the empty string */
} else { } else {
memcpy(dst, src, len); SDL_memcpy(dst, src, len);
dst += len; dst += len;
} }
if(end < file + flen) if(end < file + flen)
@ -209,7 +209,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
{ {
char *mpath = unix_to_mac(file); char *mpath = unix_to_mac(file);
fp = fopen(mpath, mode); fp = fopen(mpath, mode);
free(mpath); SDL_free(mpath);
} }
#else #else
fp = fopen(file, mode); fp = fopen(file, mode);
@ -292,7 +292,7 @@ SDL_RWops *SDL_AllocRW(void)
{ {
SDL_RWops *area; SDL_RWops *area;
area = (SDL_RWops *)malloc(sizeof *area); area = (SDL_RWops *)SDL_malloc(sizeof *area);
if ( area == NULL ) { if ( area == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
} }
@ -301,5 +301,5 @@ SDL_RWops *SDL_AllocRW(void)
void SDL_FreeRW(SDL_RWops *area) void SDL_FreeRW(SDL_RWops *area)
{ {
free(area); SDL_free(area);
} }

View file

@ -51,11 +51,11 @@ int SDL_JoystickInit(void)
status = SDL_SYS_JoystickInit(); status = SDL_SYS_JoystickInit();
if ( status >= 0 ) { if ( status >= 0 ) {
arraylen = (status+1)*sizeof(*SDL_joysticks); arraylen = (status+1)*sizeof(*SDL_joysticks);
SDL_joysticks = (SDL_Joystick **)malloc(arraylen); SDL_joysticks = (SDL_Joystick **)SDL_malloc(arraylen);
if ( SDL_joysticks == NULL ) { if ( SDL_joysticks == NULL ) {
SDL_numjoysticks = 0; SDL_numjoysticks = 0;
} else { } else {
memset(SDL_joysticks, 0, arraylen); SDL_memset(SDL_joysticks, 0, arraylen);
SDL_numjoysticks = status; SDL_numjoysticks = status;
} }
status = 0; status = 0;
@ -113,28 +113,28 @@ SDL_Joystick *SDL_JoystickOpen(int device_index)
} }
/* Create and initialize the joystick */ /* Create and initialize the joystick */
joystick = (SDL_Joystick *)malloc((sizeof *joystick)); joystick = (SDL_Joystick *)SDL_malloc((sizeof *joystick));
if ( joystick != NULL ) { if ( joystick != NULL ) {
memset(joystick, 0, (sizeof *joystick)); SDL_memset(joystick, 0, (sizeof *joystick));
joystick->index = device_index; joystick->index = device_index;
if ( SDL_SYS_JoystickOpen(joystick) < 0 ) { if ( SDL_SYS_JoystickOpen(joystick) < 0 ) {
free(joystick); SDL_free(joystick);
joystick = NULL; joystick = NULL;
} else { } else {
if ( joystick->naxes > 0 ) { if ( joystick->naxes > 0 ) {
joystick->axes = (Sint16 *)malloc joystick->axes = (Sint16 *)SDL_malloc
(joystick->naxes*sizeof(Sint16)); (joystick->naxes*sizeof(Sint16));
} }
if ( joystick->nhats > 0 ) { if ( joystick->nhats > 0 ) {
joystick->hats = (Uint8 *)malloc joystick->hats = (Uint8 *)SDL_malloc
(joystick->nhats*sizeof(Uint8)); (joystick->nhats*sizeof(Uint8));
} }
if ( joystick->nballs > 0 ) { if ( joystick->nballs > 0 ) {
joystick->balls = (struct balldelta *)malloc joystick->balls = (struct balldelta *)SDL_malloc
(joystick->nballs*sizeof(*joystick->balls)); (joystick->nballs*sizeof(*joystick->balls));
} }
if ( joystick->nbuttons > 0 ) { if ( joystick->nbuttons > 0 ) {
joystick->buttons = (Uint8 *)malloc joystick->buttons = (Uint8 *)SDL_malloc
(joystick->nbuttons*sizeof(Uint8)); (joystick->nbuttons*sizeof(Uint8));
} }
if ( ((joystick->naxes > 0) && !joystick->axes) if ( ((joystick->naxes > 0) && !joystick->axes)
@ -146,19 +146,19 @@ SDL_Joystick *SDL_JoystickOpen(int device_index)
joystick = NULL; joystick = NULL;
} }
if ( joystick->axes ) { if ( joystick->axes ) {
memset(joystick->axes, 0, SDL_memset(joystick->axes, 0,
joystick->naxes*sizeof(Sint16)); joystick->naxes*sizeof(Sint16));
} }
if ( joystick->hats ) { if ( joystick->hats ) {
memset(joystick->hats, 0, SDL_memset(joystick->hats, 0,
joystick->nhats*sizeof(Uint8)); joystick->nhats*sizeof(Uint8));
} }
if ( joystick->balls ) { if ( joystick->balls ) {
memset(joystick->balls, 0, SDL_memset(joystick->balls, 0,
joystick->nballs*sizeof(*joystick->balls)); joystick->nballs*sizeof(*joystick->balls));
} }
if ( joystick->buttons ) { if ( joystick->buttons ) {
memset(joystick->buttons, 0, SDL_memset(joystick->buttons, 0,
joystick->nbuttons*sizeof(Uint8)); joystick->nbuttons*sizeof(Uint8));
} }
} }
@ -375,7 +375,7 @@ void SDL_JoystickClose(SDL_Joystick *joystick)
/* Remove joystick from list */ /* Remove joystick from list */
for ( i=0; SDL_joysticks[i]; ++i ) { for ( i=0; SDL_joysticks[i]; ++i ) {
if ( joystick == SDL_joysticks[i] ) { if ( joystick == SDL_joysticks[i] ) {
memcpy(&SDL_joysticks[i], &SDL_joysticks[i+1], SDL_memcpy(&SDL_joysticks[i], &SDL_joysticks[i+1],
(SDL_numjoysticks-i)*sizeof(joystick)); (SDL_numjoysticks-i)*sizeof(joystick));
break; break;
} }
@ -386,18 +386,18 @@ void SDL_JoystickClose(SDL_Joystick *joystick)
/* Free the data associated with this joystick */ /* Free the data associated with this joystick */
if ( joystick->axes ) { if ( joystick->axes ) {
free(joystick->axes); SDL_free(joystick->axes);
} }
if ( joystick->hats ) { if ( joystick->hats ) {
free(joystick->hats); SDL_free(joystick->hats);
} }
if ( joystick->balls ) { if ( joystick->balls ) {
free(joystick->balls); SDL_free(joystick->balls);
} }
if ( joystick->buttons ) { if ( joystick->buttons ) {
free(joystick->buttons); SDL_free(joystick->buttons);
} }
free(joystick); SDL_free(joystick);
} }
void SDL_JoystickQuit(void) void SDL_JoystickQuit(void)
@ -410,7 +410,7 @@ void SDL_JoystickQuit(void)
/* Quit the joystick setup */ /* Quit the joystick setup */
SDL_SYS_JoystickQuit(); SDL_SYS_JoystickQuit();
if ( SDL_joysticks ) { if ( SDL_joysticks ) {
free(SDL_joysticks); SDL_free(SDL_joysticks);
SDL_joysticks = NULL; SDL_joysticks = NULL;
} }
} }

View file

@ -2,7 +2,7 @@
SDL - Simple DirectMedia Layer SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or This library is SDL_free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.

View file

@ -116,7 +116,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
ULONG temp,i; ULONG temp,i;
D(bug("Opening joystick %ld\n",joystick->index)); D(bug("Opening joystick %ld\n",joystick->index));
if(!(joystick->hwdata=malloc(sizeof(struct joystick_hwdata)))) if(!(joystick->hwdata=SDL_malloc(sizeof(struct joystick_hwdata))))
return -1; return -1;
/* This loop is to check if the controller is a joypad */ /* This loop is to check if the controller is a joypad */
@ -215,7 +215,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
void SDL_SYS_JoystickClose(SDL_Joystick *joystick) void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
{ {
if(joystick->hwdata) if(joystick->hwdata)
free(joystick->hwdata); SDL_free(joystick->hwdata);
return; return;
} }

View file

@ -67,8 +67,8 @@ int SDL_SYS_JoystickInit(void)
/* Search for attached joysticks */ /* Search for attached joysticks */
nports = joystick.CountDevices(); nports = joystick.CountDevices();
numjoysticks = 0; numjoysticks = 0;
memset(SDL_joyport, 0, (sizeof SDL_joyport)); SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
memset(SDL_joyname, 0, (sizeof SDL_joyname)); SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) { for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) {
if ( joystick.GetDeviceName(i, name) == B_OK ) { if ( joystick.GetDeviceName(i, name) == B_OK ) {
if ( joystick.Open(name) != B_ERROR ) { if ( joystick.Open(name) != B_ERROR ) {
@ -102,12 +102,12 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
/* Create the joystick data structure */ /* Create the joystick data structure */
joystick->hwdata = (struct joystick_hwdata *) joystick->hwdata = (struct joystick_hwdata *)
malloc(sizeof(*joystick->hwdata)); SDL_malloc(sizeof(*joystick->hwdata));
if ( joystick->hwdata == NULL ) { if ( joystick->hwdata == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
stick = new BJoystick; stick = new BJoystick;
joystick->hwdata->stick = stick; joystick->hwdata->stick = stick;
@ -127,9 +127,9 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
joystick->nhats = stick->CountHats(); joystick->nhats = stick->CountHats();
joystick->hwdata->new_axes = (int16 *) joystick->hwdata->new_axes = (int16 *)
malloc(joystick->naxes*sizeof(int16)); SDL_malloc(joystick->naxes*sizeof(int16));
joystick->hwdata->new_hats = (uint8 *) joystick->hwdata->new_hats = (uint8 *)
malloc(joystick->nhats*sizeof(uint8)); SDL_malloc(joystick->nhats*sizeof(uint8));
if ( ! joystick->hwdata->new_hats || ! joystick->hwdata->new_axes ) { if ( ! joystick->hwdata->new_hats || ! joystick->hwdata->new_axes ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
SDL_SYS_JoystickClose(joystick); SDL_SYS_JoystickClose(joystick);
@ -208,12 +208,12 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
joystick->hwdata->stick->Close(); joystick->hwdata->stick->Close();
delete joystick->hwdata->stick; delete joystick->hwdata->stick;
if ( joystick->hwdata->new_hats ) { if ( joystick->hwdata->new_hats ) {
free(joystick->hwdata->new_hats); SDL_free(joystick->hwdata->new_hats);
} }
if ( joystick->hwdata->new_axes ) { if ( joystick->hwdata->new_axes ) {
free(joystick->hwdata->new_axes); SDL_free(joystick->hwdata->new_axes);
} }
free(joystick->hwdata); SDL_free(joystick->hwdata);
joystick->hwdata = NULL; joystick->hwdata = NULL;
} }
} }
@ -224,12 +224,12 @@ void SDL_SYS_JoystickQuit(void)
int i; int i;
for ( i=0; SDL_joyport[i]; ++i ) { for ( i=0; SDL_joyport[i]; ++i ) {
free(SDL_joyport[i]); SDL_free(SDL_joyport[i]);
} }
SDL_joyport[0] = NULL; SDL_joyport[0] = NULL;
for ( i=0; SDL_joyname[i]; ++i ) { for ( i=0; SDL_joyname[i]; ++i ) {
free(SDL_joyname[i]); SDL_free(SDL_joyname[i]);
} }
SDL_joyname[0] = NULL; SDL_joyname[0] = NULL;
} }

View file

@ -139,8 +139,8 @@ SDL_SYS_JoystickInit(void)
SDL_numjoysticks = 0; SDL_numjoysticks = 0;
memset(joynames, 0, sizeof(joynames)); SDL_memset(joynames, 0, sizeof(joynames));
memset(joydevnames, 0, sizeof(joydevnames)); SDL_memset(joydevnames, 0, sizeof(joydevnames));
for (i = 0; i < MAX_UHID_JOYS; i++) { for (i = 0; i < MAX_UHID_JOYS; i++) {
SDL_Joystick nj; SDL_Joystick nj;
@ -154,7 +154,7 @@ SDL_SYS_JoystickInit(void)
SDL_SYS_JoystickClose(&nj); SDL_SYS_JoystickClose(&nj);
SDL_numjoysticks++; SDL_numjoysticks++;
} else { } else {
free(joynames[nj.index]); SDL_free(joynames[nj.index]);
joynames[nj.index] = NULL; joynames[nj.index] = NULL;
} }
} }
@ -241,7 +241,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
return (-1); return (-1);
} }
hw = (struct joystick_hwdata *)malloc(sizeof(struct joystick_hwdata)); hw = (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata));
if (hw == NULL) { if (hw == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
close(fd); close(fd);
@ -250,7 +250,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
joy->hwdata = hw; joy->hwdata = hw;
hw->fd = fd; hw->fd = fd;
hw->path = strdup(path); hw->path = strdup(path);
if (! strncmp(path, "/dev/joy", 8)) { if (! SDL_strncmp(path, "/dev/joy", 8)) {
hw->type = BSDJOY_JOY; hw->type = BSDJOY_JOY;
joy->naxes = 2; joy->naxes = 2;
joy->nbuttons = 2; joy->nbuttons = 2;
@ -311,7 +311,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
case HUG_JOYSTICK: case HUG_JOYSTICK:
case HUG_GAME_PAD: case HUG_GAME_PAD:
s = hid_usage_in_page(hitem.usage); s = hid_usage_in_page(hitem.usage);
sp = malloc(strlen(s) + 5); sp = SDL_malloc(SDL_strlen(s) + 5);
sprintf(sp, "%s (%d)", s, sprintf(sp, "%s (%d)", s,
joy->index); joy->index);
joydevnames[joy->index] = sp; joydevnames[joy->index] = sp;
@ -351,8 +351,8 @@ usbend:
return (0); return (0);
usberr: usberr:
close(hw->fd); close(hw->fd);
free(hw->path); SDL_free(hw->path);
free(hw); SDL_free(hw);
return (-1); return (-1);
} }
@ -482,13 +482,13 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy)
void void
SDL_SYS_JoystickClose(SDL_Joystick *joy) SDL_SYS_JoystickClose(SDL_Joystick *joy)
{ {
if (strncmp(joy->hwdata->path, "/dev/joy", 8)) { if (SDL_strncmp(joy->hwdata->path, "/dev/joy", 8)) {
report_free(&joy->hwdata->inreport); report_free(&joy->hwdata->inreport);
hid_dispose_report_desc(joy->hwdata->repdesc); hid_dispose_report_desc(joy->hwdata->repdesc);
} }
close(joy->hwdata->fd); close(joy->hwdata->fd);
free(joy->hwdata->path); SDL_free(joy->hwdata->path);
free(joy->hwdata); SDL_free(joy->hwdata);
return; return;
} }
@ -500,9 +500,9 @@ SDL_SYS_JoystickQuit(void)
for (i = 0; i < MAX_JOYS; i++) { for (i = 0; i < MAX_JOYS; i++) {
if (joynames[i] != NULL) if (joynames[i] != NULL)
free(joynames[i]); SDL_free(joynames[i]);
if (joydevnames[i] != NULL) if (joydevnames[i] != NULL)
free(joydevnames[i]); SDL_free(joydevnames[i]);
} }
return; return;
@ -538,7 +538,7 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
r->size = len; r->size = len;
if (r->size > 0) { if (r->size > 0) {
r->buf = malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) +
r->size); r->size);
if (r->buf == NULL) { if (r->buf == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
@ -556,7 +556,7 @@ static void
report_free(struct report *r) report_free(struct report *r)
{ {
if (r->buf != NULL) { if (r->buf != NULL) {
free(r->buf); SDL_free(r->buf);
} }
r->status = SREPORT_UNINIT; r->status = SREPORT_UNINIT;
} }

View file

@ -90,13 +90,13 @@ const char *SDL_SYS_JoystickName(int index)
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
{ {
/* allocate memory for system specific hardware data */ /* allocate memory for system specific hardware data */
joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata)); joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
if (joystick->hwdata == NULL) if (joystick->hwdata == NULL)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
/* fill nbuttons, naxes, and nhats fields */ /* fill nbuttons, naxes, and nhats fields */
joystick->nbuttons = MAX_BUTTONS; joystick->nbuttons = MAX_BUTTONS;
@ -182,7 +182,7 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
{ {
if (joystick->hwdata != NULL) { if (joystick->hwdata != NULL) {
/* free system specific hardware data */ /* free system specific hardware data */
free(joystick->hwdata); SDL_free(joystick->hwdata);
} }
} }

View file

@ -23,7 +23,7 @@
/* This is the system specific header for the SDL joystick API */ /* This is the system specific header for the SDL joystick API */
#include <stdio.h> /* For the definition of NULL */ #include <stdio.h> /* For the definition of NULL */
#include <stdlib.h> /* For getenv() prototype */ #include <stdlib.h> /* For SDL_getenv() prototype */
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@ -187,9 +187,9 @@ static char *mystrdup(const char *string)
{ {
char *newstring; char *newstring;
newstring = (char *)malloc(strlen(string)+1); newstring = (char *)SDL_malloc(SDL_strlen(string)+1);
if ( newstring ) { if ( newstring ) {
strcpy(newstring, string); SDL_strcpy(newstring, string);
} }
return(newstring); return(newstring);
} }
@ -209,7 +209,7 @@ static int CountLogicalJoysticks(int max)
if (name) { if (name) {
for(j = 0; j < SDL_TABLESIZE(joystick_logicalmap); j++) { for(j = 0; j < SDL_TABLESIZE(joystick_logicalmap); j++) {
if (!strcmp(name, joystick_logicalmap[j].name)) { if (!SDL_strcmp(name, joystick_logicalmap[j].name)) {
prev = i; prev = i;
SDL_joylist[prev].map = joystick_logicalmap+j; SDL_joylist[prev].map = joystick_logicalmap+j;
@ -243,7 +243,7 @@ static void LogicalSuffix(int logicalno, char* namebuf, int len)
"20212223242526272829303132"; "20212223242526272829303132";
const char* suffix; const char* suffix;
slen = strlen(namebuf); slen = SDL_strlen(namebuf);
suffix = NULL; suffix = NULL;
@ -306,8 +306,8 @@ int SDL_SYS_JoystickInit(void)
numjoysticks = 0; numjoysticks = 0;
/* First see if the user specified a joystick to use */ /* First see if the user specified a joystick to use */
if ( getenv("SDL_JOYSTICK_DEVICE") != NULL ) { if ( SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL ) {
strncpy(path, getenv("SDL_JOYSTICK_DEVICE"), sizeof(path)); SDL_strncpy(path, SDL_getenv("SDL_JOYSTICK_DEVICE"), sizeof(path));
path[sizeof(path)-1] = '\0'; 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);
@ -426,7 +426,7 @@ static int allocate_hatdata(SDL_Joystick *joystick)
{ {
int i; int i;
joystick->hwdata->hats = (struct hwdata_hat *)malloc( joystick->hwdata->hats = (struct hwdata_hat *)SDL_malloc(
joystick->nhats * sizeof(struct hwdata_hat)); joystick->nhats * sizeof(struct hwdata_hat));
if ( joystick->hwdata->hats == NULL ) { if ( joystick->hwdata->hats == NULL ) {
return(-1); return(-1);
@ -442,7 +442,7 @@ static int allocate_balldata(SDL_Joystick *joystick)
{ {
int i; int i;
joystick->hwdata->balls = (struct hwdata_ball *)malloc( joystick->hwdata->balls = (struct hwdata_ball *)SDL_malloc(
joystick->nballs * sizeof(struct hwdata_ball)); joystick->nballs * sizeof(struct hwdata_ball));
if ( joystick->hwdata->balls == NULL ) { if ( joystick->hwdata->balls == NULL ) {
return(-1); return(-1);
@ -481,8 +481,8 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd)
old_axes = joystick->naxes; old_axes = joystick->naxes;
/* Generic analog joystick support */ /* Generic analog joystick support */
if ( strstr(name, "Analog") == name && strstr(name, "-hat") ) { if ( SDL_strstr(name, "Analog") == name && SDL_strstr(name, "-hat") ) {
if ( sscanf(name,"Analog %d-axis %*d-button %d-hat", if ( SDL_sscanf(name,"Analog %d-axis %*d-button %d-hat",
&tmp_naxes, &tmp_nhats) == 2 ) { &tmp_naxes, &tmp_nhats) == 2 ) {
joystick->naxes = tmp_naxes; joystick->naxes = tmp_naxes;
@ -494,7 +494,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_TABLESIZE(special_joysticks); ++i ) {
if ( 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;
joystick->nhats = special_joysticks[i].nhats; joystick->nhats = special_joysticks[i].nhats;
@ -506,16 +506,16 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd)
} }
/* User environment joystick support */ /* User environment joystick support */
if ( (env = getenv("SDL_LINUX_JOYSTICK")) ) { if ( (env = SDL_getenv("SDL_LINUX_JOYSTICK")) ) {
strcpy(env_name, ""); SDL_strcpy(env_name, "");
if ( *env == '\'' && sscanf(env, "'%[^']s'", env_name) == 1 ) if ( *env == '\'' && SDL_sscanf(env, "'%[^']s'", env_name) == 1 )
env += strlen(env_name)+2; env += SDL_strlen(env_name)+2;
else if ( sscanf(env, "%s", env_name) == 1 ) else if ( SDL_sscanf(env, "%s", env_name) == 1 )
env += strlen(env_name); env += SDL_strlen(env_name);
if ( strcmp(name, env_name) == 0 ) { if ( SDL_strcmp(name, env_name) == 0 ) {
if ( sscanf(env, "%d %d %d", &tmp_naxes, &tmp_nhats, if ( SDL_sscanf(env, "%d %d %d", &tmp_naxes, &tmp_nhats,
&tmp_nballs) == 3 ) { &tmp_nballs) == 3 ) {
joystick->naxes = tmp_naxes; joystick->naxes = tmp_naxes;
@ -697,13 +697,13 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
return(-1); return(-1);
} }
joystick->hwdata = (struct joystick_hwdata *) joystick->hwdata = (struct joystick_hwdata *)
malloc(sizeof(*joystick->hwdata)); SDL_malloc(sizeof(*joystick->hwdata));
if ( joystick->hwdata == NULL ) { if ( joystick->hwdata == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
close(fd); close(fd);
return(-1); return(-1);
} }
memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
joystick->hwdata->fd = fd; joystick->hwdata->fd = fd;
/* Set the joystick to non-blocking read mode */ /* Set the joystick to non-blocking read mode */
@ -1064,12 +1064,12 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
#endif #endif
close(joystick->hwdata->fd); close(joystick->hwdata->fd);
if ( joystick->hwdata->hats ) { if ( joystick->hwdata->hats ) {
free(joystick->hwdata->hats); SDL_free(joystick->hwdata->hats);
} }
if ( joystick->hwdata->balls ) { if ( joystick->hwdata->balls ) {
free(joystick->hwdata->balls); SDL_free(joystick->hwdata->balls);
} }
free(joystick->hwdata); SDL_free(joystick->hwdata);
joystick->hwdata = NULL; joystick->hwdata = NULL;
} }
} }
@ -1080,7 +1080,7 @@ void SDL_SYS_JoystickQuit(void)
int i; int i;
for ( i=0; SDL_joylist[i].fname; ++i ) { for ( i=0; SDL_joylist[i].fname; ++i ) {
free(SDL_joylist[i].fname); SDL_free(SDL_joylist[i].fname);
} }
SDL_joylist[0].fname = NULL; SDL_joylist[0].fname = NULL;
} }

View file

@ -137,7 +137,7 @@ const char *SDL_SYS_JoystickName(int index)
if ( len >= sizeof(name) ) { if ( len >= sizeof(name) ) {
len = (sizeof(name) - 1); len = (sizeof(name) - 1);
} }
memcpy(name, &SYS_DevDef[index].deviceName[1], len); SDL_memcpy(name, &SYS_DevDef[index].deviceName[1], len);
name[len] = '\0'; name[len] = '\0';
return name; return name;
@ -161,14 +161,14 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
index = joystick->index; index = joystick->index;
/* allocate memory for system specific hardware data */ /* allocate memory for system specific hardware data */
joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata)); joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
if (joystick->hwdata == NULL) if (joystick->hwdata == NULL)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index)); SDL_strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index));
joystick->name = joystick->hwdata->name; joystick->name = joystick->hwdata->name;
ISpElementList_ExtractByKind( ISpElementList_ExtractByKind(

View file

@ -162,13 +162,13 @@ int SDL_SYS_JoystickInit(void)
{ {
int i; int i;
unsigned long cookie_mch; unsigned long cookie_mch;
const char *envr=getenv("SDL_JOYSTICK_ATARI"); const char *envr=SDL_getenv("SDL_JOYSTICK_ATARI");
#define TEST_JOY_ENABLED(env,idstring,num) \ #define TEST_JOY_ENABLED(env,idstring,num) \
if (strstr(env,idstring"-off")) { \ if (SDL_strstr(env,idstring"-off")) { \
atarijoysticks[num].enabled=SDL_FALSE; \ atarijoysticks[num].enabled=SDL_FALSE; \
} \ } \
if (strstr(env,idstring"-on")) { \ if (SDL_strstr(env,idstring"-on")) { \
atarijoysticks[num].enabled=SDL_TRUE; \ atarijoysticks[num].enabled=SDL_TRUE; \
} }

View file

@ -326,14 +326,14 @@ int index; /* Index shortcut for index in joystick structure */
int i; /* Generic Counter */ int i; /* Generic Counter */
/* allocate memory for system specific hardware data */ /* allocate memory for system specific hardware data */
joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata)); joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
if (joystick->hwdata == NULL) if (joystick->hwdata == NULL)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
/* Reset Hardware Data */ /* Reset Hardware Data */
memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
/* ShortCut Pointer */ /* ShortCut Pointer */
index = joystick->index; index = joystick->index;
@ -517,7 +517,7 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
if (joystick->hwdata != NULL) if (joystick->hwdata != NULL)
{ {
/* free system specific hardware data */ /* free system specific hardware data */
free(joystick->hwdata); SDL_free(joystick->hwdata);
} }
} }
@ -602,7 +602,7 @@ int joyGetEnv(struct _joycfg * joydata)
char *joyenv; /* Pointer to tested character */ char *joyenv; /* Pointer to tested character */
char tempnumber[5]; /* Temporary place to put numeric texts */ char tempnumber[5]; /* Temporary place to put numeric texts */
joyenv = getenv("SDL_OS2_JOYSTICK"); joyenv = SDL_getenv("SDL_OS2_JOYSTICK");
if (joyenv == NULL) return 0; if (joyenv == NULL) return 0;
/* Joystick Environment is defined! */ /* Joystick Environment is defined! */
while (*joyenv==' ' && *joyenv!=0) joyenv++; /* jump spaces... */ while (*joyenv==' ' && *joyenv!=0) joyenv++; /* jump spaces... */

View file

@ -89,7 +89,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
{ {
_kernel_swi_regs regs; _kernel_swi_regs regs;
if(!(joystick->hwdata=malloc(sizeof(struct joystick_hwdata)))) if(!(joystick->hwdata=SDL_malloc(sizeof(struct joystick_hwdata))))
return -1; return -1;
regs.r[0] = joystick->index; regs.r[0] = joystick->index;
@ -161,7 +161,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
void SDL_SYS_JoystickClose(SDL_Joystick *joystick) void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
{ {
if(joystick->hwdata) if(joystick->hwdata)
free(joystick->hwdata); SDL_free(joystick->hwdata);
return; return;
} }

View file

@ -82,7 +82,7 @@ static char *GetJoystickName(int index, const char *szRegKey)
unsigned char regvalue[256]; unsigned char regvalue[256];
unsigned char regname[256]; unsigned char regname[256];
snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s", SDL_snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
REGSTR_PATH_JOYCONFIG, REGSTR_PATH_JOYCONFIG,
szRegKey, szRegKey,
REGSTR_KEY_JOYCURR); REGSTR_KEY_JOYCURR);
@ -95,7 +95,7 @@ static char *GetJoystickName(int index, const char *szRegKey)
joystick's properties joystick's properties
*/ */
regsize = sizeof(regname); regsize = sizeof(regname);
snprintf((char *) regvalue, SDL_arraysize(regvalue), SDL_snprintf((char *) regvalue, SDL_arraysize(regvalue),
"Joystick%d%s", index+1, "Joystick%d%s", index+1,
REGSTR_VAL_JOYOEMNAME); REGSTR_VAL_JOYOEMNAME);
regresult = RegQueryValueExA(hKey, regresult = RegQueryValueExA(hKey,
@ -105,7 +105,7 @@ static char *GetJoystickName(int index, const char *szRegKey)
if (regresult == ERROR_SUCCESS) if (regresult == ERROR_SUCCESS)
{ {
/* open that registry key */ /* open that registry key */
snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s", SDL_snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s",
REGSTR_PATH_JOYOEM, regname); REGSTR_PATH_JOYOEM, regname);
regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
(char *) regkey, 0, KEY_READ, &hKey); (char *) regkey, 0, KEY_READ, &hKey);
@ -124,7 +124,7 @@ static char *GetJoystickName(int index, const char *szRegKey)
allocate enough memory allocate enough memory
for the OEM name text ... for the OEM name text ...
*/ */
name = (char *) malloc(regsize); name = (char *) SDL_malloc(regsize);
/* ... and read it from the registry */ /* ... and read it from the registry */
regresult = regresult =
RegQueryValueExA(hKey, RegQueryValueExA(hKey,
@ -227,13 +227,13 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
axis_max[5] = SYS_Joystick[index].wVmax; axis_max[5] = SYS_Joystick[index].wVmax;
/* allocate memory for system specific hardware data */ /* allocate memory for system specific hardware data */
joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata)); joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
if (joystick->hwdata == NULL) if (joystick->hwdata == NULL)
{ {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
} }
memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
/* set hardware data */ /* set hardware data */
joystick->hwdata->id = SYS_JoystickID[index]; joystick->hwdata->id = SYS_JoystickID[index];
@ -359,7 +359,7 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
{ {
if (joystick->hwdata != NULL) { if (joystick->hwdata != NULL) {
/* free system specific hardware data */ /* free system specific hardware data */
free(joystick->hwdata); SDL_free(joystick->hwdata);
} }
} }
@ -369,7 +369,7 @@ void SDL_SYS_JoystickQuit(void)
int i; int i;
for (i = 0; i < MAX_JOYSTICKS; i++) { for (i = 0; i < MAX_JOYSTICKS; i++) {
if ( SYS_JoystickName[i] != NULL ) { if ( SYS_JoystickName[i] != NULL ) {
free(SYS_JoystickName[i]); SDL_free(SYS_JoystickName[i]);
} }
} }
} }
@ -406,14 +406,14 @@ void SetMMerror(char *function, int code)
break; break;
default: default:
snprintf(errbuf, SDL_arraysize(errbuf), SDL_snprintf(errbuf, SDL_arraysize(errbuf),
"%s: Unknown Multimedia system error: 0x%x", "%s: Unknown Multimedia system error: 0x%x",
function, code); function, code);
break; break;
} }
if ( ! errbuf[0] ) { if ( ! errbuf[0] ) {
snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error); SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
} }
SDL_SetError("%s", errbuf); SDL_SetError("%s", errbuf);
} }

View file

@ -52,7 +52,7 @@ void *SDL_LoadObject(const char *sofile)
OSErr error; OSErr error;
char psofile[512]; char psofile[512];
strncpy(psofile, sofile, SDL_TABLESIZE(psofile)); SDL_strncpy(psofile, sofile, SDL_TABLESIZE(psofile));
psofile[SDL_TABLESIZE(psofile)-1] = '\0'; 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);
@ -90,7 +90,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];
strncpy(pname, name, SDL_TABLESIZE(pname)); SDL_strncpy(pname, name, SDL_TABLESIZE(pname));
pname[SDL_TABLESIZE(pname)-1] = '\0'; 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 ) {

View file

@ -282,7 +282,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;
strncpy(err_str, "dlcompat: ", ERR_STR_LEN); SDL_strncpy(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);
@ -298,7 +298,7 @@ static void warning(const char *str)
static const char *safegetenv(const char *s) static const char *safegetenv(const char *s)
{ {
const char *ss = getenv(s); const char *ss = SDL_getenv(s);
return ss ? ss : ""; return ss ? ss : "";
} }
@ -338,7 +338,7 @@ static const struct mach_header *get_mach_header_from_NSModule(NSModule * mod)
debug("Module name: %s", mod_name); debug("Module name: %s", mod_name);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if (!strcmp(mod_name, _dyld_get_image_name(i))) if (!SDL_strcmp(mod_name, _dyld_get_image_name(i)))
{ {
mh = _dyld_get_image_header(i); mh = _dyld_get_image_header(i);
break; break;
@ -362,14 +362,14 @@ static const char *searchList()
static char *buf=NULL; static char *buf=NULL;
const char *ldlp = safegetenv("LD_LIBRARY_PATH"); const char *ldlp = safegetenv("LD_LIBRARY_PATH");
const char *dyldlp = safegetenv("DYLD_LIBRARY_PATH"); const char *dyldlp = safegetenv("DYLD_LIBRARY_PATH");
const char *stdpath = getenv("DYLD_FALLBACK_LIBRARY_PATH"); const char *stdpath = SDL_getenv("DYLD_FALLBACK_LIBRARY_PATH");
if (!stdpath) if (!stdpath)
stdpath = "/usr/local/lib:/lib:/usr/lib"; stdpath = "/usr/local/lib:/lib:/usr/lib";
if (!buf) if (!buf)
{ {
buf_size = strlen(ldlp) + strlen(dyldlp) + strlen(stdpath) + 4; buf_size = SDL_strlen(ldlp) + SDL_strlen(dyldlp) + SDL_strlen(stdpath) + 4;
buf = malloc(buf_size); buf = SDL_malloc(buf_size);
snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), SDL_snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""),
stdpath, '\0'); stdpath, '\0');
} }
return buf; return buf;
@ -383,7 +383,7 @@ static const char *getSearchPath(int i)
static int end = 0; static int end = 0;
static int numsize = MAX_SEARCH_PATHS; static int numsize = MAX_SEARCH_PATHS;
static char **tmp; static char **tmp;
/* So we can call free() in the "destructor" we use i=-1 to return the alloc'd array */ /* So we can call SDL_free() in the "destructor" we use i=-1 to return the alloc'd array */
if (i == -1) if (i == -1)
{ {
return (const char*)path; return (const char*)path;
@ -400,8 +400,8 @@ static const char *getSearchPath(int i)
tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **)); tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **));
if (tmp) if (tmp)
{ {
memcpy(tmp, path, sizeof(char **) * numsize); SDL_memcpy(tmp, path, sizeof(char **) * numsize);
free(path); SDL_free(path);
path = tmp; path = tmp;
numsize += MAX_SEARCH_PATHS; numsize += MAX_SEARCH_PATHS;
} }
@ -428,7 +428,7 @@ static const char *getFullPath(int i, const char *file)
const char *path = getSearchPath(i); const char *path = getSearchPath(i);
if (path) if (path)
{ {
snprintf(buf, PATH_MAX, "%s/%s", path, file); SDL_snprintf(buf, PATH_MAX, "%s/%s", path, file);
} }
return path ? buf : 0; return path ? buf : 0;
} }
@ -446,7 +446,7 @@ static const struct stat *findFile(const char *file, const char **fullPath)
*fullPath = file; *fullPath = file;
if (0 == stat(file, &sbuf)) if (0 == stat(file, &sbuf))
return &sbuf; return &sbuf;
if (strchr(file, '/')) if (SDL_strchr(file, '/'))
return 0; /* If the path had a / we don't look in env var places */ return 0; /* If the path had a / we don't look in env var places */
fileName = NULL; fileName = NULL;
if (!fileName) if (!fileName)
@ -567,7 +567,7 @@ static const struct mach_header *my_find_image(const char *name)
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
{ {
id = _dyld_get_image_name(j); id = _dyld_get_image_name(j);
if (!strcmp(id, name)) if (!SDL_strcmp(id, name))
{ {
mh = _dyld_get_image_header(j); mh = _dyld_get_image_header(j);
break; break;
@ -620,7 +620,7 @@ static NSSymbol *search_linked_libs(const struct mach_header * mh, const char *s
return nssym; return nssym;
} }
/* Up to the caller to free() returned string */ /* Up to the caller to SDL_free() returned string */
static inline const char *dyld_error_str() static inline const char *dyld_error_str()
{ {
NSLinkEditErrors dylder; NSLinkEditErrors dylder;
@ -629,10 +629,10 @@ static inline const char *dyld_error_str()
const char *dyldfile; const char *dyldfile;
const char* retStr = NULL; const char* retStr = NULL;
NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
if (dylderrstr && strlen(dylderrstr)) if (dylderrstr && SDL_strlen(dylderrstr))
{ {
retStr = malloc(strlen(dylderrstr) +1); retStr = SDL_malloc(SDL_strlen(dylderrstr) +1);
strcpy((char*)retStr,dylderrstr); SDL_strcpy((char*)retStr,dylderrstr);
} }
return retStr; return retStr;
} }
@ -735,21 +735,21 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
else else
{ {
if (savedErrorStr) if (savedErrorStr)
free((char*)savedErrorStr); SDL_free((char*)savedErrorStr);
savedErrorStr = malloc(256); savedErrorStr = SDL_malloc(256);
snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol); SDL_snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol);
} }
} }
} }
/* Error reporting */ /* Error reporting */
if (!nssym) if (!nssym)
{ {
if (!savedErrorStr || !strlen(savedErrorStr)) if (!savedErrorStr || !SDL_strlen(savedErrorStr))
{ {
if (savedErrorStr) if (savedErrorStr)
free((char*)savedErrorStr); SDL_free((char*)savedErrorStr);
savedErrorStr = malloc(256); savedErrorStr = SDL_malloc(256);
snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol); SDL_snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol);
} }
if (canSetError) if (canSetError)
{ {
@ -760,7 +760,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
debug(savedErrorStr); debug(savedErrorStr);
} }
if (savedErrorStr) if (savedErrorStr)
free((char*)savedErrorStr); SDL_free((char*)savedErrorStr);
return NULL; return NULL;
} }
return NSAddressOfSymbol(nssym); return NSAddressOfSymbol(nssym);
@ -839,13 +839,13 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
if (!(dls->module)) if (!(dls->module))
{ {
NSLinkEditError(&ler, &lerno, &file, &errstr); NSLinkEditError(&ler, &lerno, &file, &errstr);
if (!errstr || (!strlen(errstr))) if (!errstr || (!SDL_strlen(errstr)))
error("Can't open this file type"); error("Can't open this file type");
else else
error(errstr); error(errstr);
if ((dls->flags & DL_IN_LIST) == 0) if ((dls->flags & DL_IN_LIST) == 0)
{ {
free(dls); SDL_free(dls);
} }
return NULL; return NULL;
} }
@ -867,7 +867,7 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in
NSLinkEditError(&ler, &lerno, &file, &errstr); NSLinkEditError(&ler, &lerno, &file, &errstr);
if ((dls->flags & DL_IN_LIST) == 0) if ((dls->flags & DL_IN_LIST) == 0)
{ {
free(dls); SDL_free(dls);
} }
error(errstr); error(errstr);
return NULL; return NULL;
@ -917,7 +917,7 @@ static void resetdlerror()
static void dlerrorfree(void *data) static void dlerrorfree(void *data)
{ {
free(data); SDL_free(data);
} }
/* We kind of want a recursive lock here, but meet a little trouble /* We kind of want a recursive lock here, but meet a little trouble
@ -932,7 +932,7 @@ static inline void dolock(void)
tss = pthread_getspecific(dlerror_key); tss = pthread_getspecific(dlerror_key);
if (!tss) if (!tss)
{ {
tss = malloc(sizeof(struct dlthread)); tss = SDL_malloc(sizeof(struct dlthread));
tss->lockcnt = 0; tss->lockcnt = 0;
tss->errset = 0; tss->errset = 0;
if (pthread_setspecific(dlerror_key, tss)) if (pthread_setspecific(dlerror_key, tss))
@ -1010,16 +1010,16 @@ static void *SDL_OSX_dlopen(const char *path, int mode)
#if !FINK_BUILD #if !FINK_BUILD
static void *SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol) static void *SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol)
{ {
int sym_len = strlen(symbol); int sym_len = SDL_strlen(symbol);
void *value = NULL; void *value = NULL;
char *malloc_sym = NULL; char *malloc_sym = NULL;
dolock(); dolock();
malloc_sym = malloc(sym_len + 2); malloc_sym = SDL_malloc(sym_len + 2);
if (malloc_sym) if (malloc_sym)
{ {
sprintf(malloc_sym, "_%s", symbol); sprintf(malloc_sym, "_%s", symbol);
value = dlsymIntern(handle, malloc_sym, 1); value = dlsymIntern(handle, malloc_sym, 1);
free(malloc_sym); SDL_free(malloc_sym);
} }
else else
{ {
@ -1056,15 +1056,15 @@ static void *dlsym_prepend_underscore_intern(void *handle, const char *symbol)
* the underscore always, or not at all. These global functions need to go away * the underscore always, or not at all. These global functions need to go away
* for opendarwin. * for opendarwin.
*/ */
int sym_len = strlen(symbol); int sym_len = SDL_strlen(symbol);
void *value = NULL; void *value = NULL;
char *malloc_sym = NULL; char *malloc_sym = NULL;
malloc_sym = malloc(sym_len + 2); malloc_sym = SDL_malloc(sym_len + 2);
if (malloc_sym) if (malloc_sym)
{ {
sprintf(malloc_sym, "_%s", symbol); sprintf(malloc_sym, "_%s", symbol);
value = dlsymIntern(handle, malloc_sym, 1); value = dlsymIntern(handle, malloc_sym, 1);
free(malloc_sym); SDL_free(malloc_sym);
} }
else else
{ {
@ -1273,7 +1273,7 @@ static int SDL_OSX_dladdr(const void * dl_restrict p, SDL_OSX_Dl_info * dl_restr
{ {
if (LC_SEGMENT == lc->cmd) if (LC_SEGMENT == lc->cmd)
{ {
if (!strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT")) if (!SDL_strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT"))
break; break;
} }
} }
@ -1341,15 +1341,15 @@ static dlfunc_t SDL_OSX_dlfunc(void * dl_restrict handle, const char * dl_restri
void *d; void *d;
dlfunc_t f; dlfunc_t f;
} rv; } rv;
int sym_len = strlen(symbol); int sym_len = SDL_strlen(symbol);
char *malloc_sym = NULL; char *malloc_sym = NULL;
dolock(); dolock();
malloc_sym = malloc(sym_len + 2); malloc_sym = SDL_malloc(sym_len + 2);
if (malloc_sym) if (malloc_sym)
{ {
sprintf(malloc_sym, "_%s", symbol); sprintf(malloc_sym, "_%s", symbol);
rv.d = dlsymIntern(handle, malloc_sym, 1); rv.d = dlsymIntern(handle, malloc_sym, 1);
free(malloc_sym); SDL_free(malloc_sym);
} }
else else
{ {

View file

@ -45,8 +45,8 @@ void *SDL_LoadObject(const char *sofile)
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
char errbuf[512]; char errbuf[512];
wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t)); wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
wchar_t *sofile_t = malloc((MAX_PATH+1) * sizeof(wchar_t)); wchar_t *sofile_t = SDL_malloc((MAX_PATH+1) * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH);
handle = (void *)LoadLibrary(sofile_t); handle = (void *)LoadLibrary(sofile_t);
@ -62,8 +62,8 @@ void *SDL_LoadObject(const char *sofile)
loaderror = errbuf; loaderror = errbuf;
} }
free(sofile_t); SDL_free(sofile_t);
free(errbuf_t); SDL_free(errbuf_t);
#else /*if defined(WIN32)*/ #else /*if defined(WIN32)*/
char errbuf[512]; char errbuf[512];
@ -94,10 +94,10 @@ void *SDL_LoadFunction(void *handle, const char *name)
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
char errbuf[512]; char errbuf[512];
int length = strlen(name); int length = SDL_strlen(name);
wchar_t *name_t = malloc((length + 1) * sizeof(wchar_t)); wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t)); wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);
@ -112,8 +112,8 @@ void *SDL_LoadFunction(void *handle, const char *name)
loaderror = errbuf; loaderror = errbuf;
} }
free(name_t); SDL_free(name_t);
free(errbuf_t); SDL_free(errbuf_t);
#else /*if defined(WIN32)*/ #else /*if defined(WIN32)*/
char errbuf[512]; char errbuf[512];

View file

@ -589,7 +589,7 @@ int main(int argc, char *argv[])
/* Parse C-string into argv and argc */ /* Parse C-string into argv and argc */
nargs = ParseCommandLine (commandLine, NULL); nargs = ParseCommandLine (commandLine, NULL);
args = (char **)malloc((nargs+1)*(sizeof *args)); args = (char **)SDL_malloc((nargs+1)*(sizeof *args));
if ( args == NULL ) { if ( args == NULL ) {
exit(-1); exit(-1);
} }

View file

@ -5,12 +5,12 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h> #include "SDL_windows.h"
#include <malloc.h> /* For _alloca() */
#include "SDL_stdlib.h"
#include "SDL_string.h"
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
# define DIR_SEPERATOR TEXT("\\") # define DIR_SEPERATOR TEXT("\\")
@ -56,7 +56,7 @@
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t')) #define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
/* seems to be undefined in Win CE although in online help */ /* seems to be undefined in Win CE although in online help */
char *strrchr(char *str, int c) char *SDL_strrchr(char *str, int c)
{ {
char *p; char *p;
@ -195,15 +195,15 @@ int console_main(int argc, char *argv[])
/* Get the class name from argv[0] */ /* Get the class name from argv[0] */
appname = argv[0]; appname = argv[0];
if ( (bufp=strrchr(argv[0], '\\')) != NULL ) { if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) {
appname = bufp+1; appname = bufp+1;
} else } else
if ( (bufp=strrchr(argv[0], '/')) != NULL ) { if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) {
appname = bufp+1; appname = bufp+1;
} }
if ( (bufp=strrchr(appname, '.')) == NULL ) if ( (bufp=SDL_strrchr(appname, '.')) == NULL )
n = strlen(appname); n = SDL_strlen(appname);
else else
n = (bufp-appname); n = (bufp-appname);
@ -211,7 +211,7 @@ int console_main(int argc, char *argv[])
if ( bufp == NULL ) { if ( bufp == NULL ) {
return OutOfMemory(); return OutOfMemory();
} }
strncpy(bufp, appname, n); SDL_strncpy(bufp, appname, n);
bufp[n] = '\0'; bufp[n] = '\0';
appname = bufp; appname = bufp;
@ -298,8 +298,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
} }
path[pathlen] = '\0'; path[pathlen] = '\0';
strcpy( stdoutPath, path ); SDL_strcpy( stdoutPath, path );
strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE ); SDL_strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE );
/* Redirect standard input and standard output */ /* Redirect standard input and standard output */
newfp = freopen(stdoutPath, TEXT("w"), stdout); newfp = freopen(stdoutPath, TEXT("w"), stdout);
@ -317,8 +317,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
} }
#endif /* _WIN32_WCE */ #endif /* _WIN32_WCE */
strcpy( stderrPath, path ); SDL_strcpy( stderrPath, path );
strcat( stderrPath, DIR_SEPERATOR STDERR_FILE ); SDL_strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );
newfp = freopen(stderrPath, TEXT("w"), stderr); newfp = freopen(stderrPath, TEXT("w"), stderr);
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
@ -354,11 +354,11 @@ 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(strlen(bufp)+1); cmdline = (char *)alloca(SDL_strlen(bufp)+1);
if ( cmdline == NULL ) { if ( cmdline == NULL ) {
return OutOfMemory(); return OutOfMemory();
} }
strcpy(cmdline, bufp); SDL_strcpy(cmdline, bufp);
#endif #endif
/* Parse it into argv and argc */ /* Parse it into argv and argc */

View file

@ -42,20 +42,20 @@ int SDL_putenv(const char *variable)
char *value; char *value;
const char *sep; const char *sep;
sep = strchr(variable, '='); sep = SDL_strchr(variable, '=');
if ( sep == NULL ) { if ( sep == NULL ) {
return -1; return -1;
} }
bufferlen = strlen(variable)+1; bufferlen = SDL_strlen(variable)+1;
if ( bufferlen > SDL_envmemlen ) { if ( bufferlen > SDL_envmemlen ) {
char *newmem = (char *)realloc(SDL_envmem, bufferlen); char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
if ( newmem == NULL ) { if ( newmem == NULL ) {
return -1; return -1;
} }
SDL_envmem = newmem; SDL_envmem = newmem;
SDL_envmemlen = bufferlen; SDL_envmemlen = bufferlen;
} }
strcpy(SDL_envmem, variable); SDL_strcpy(SDL_envmem, variable);
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) ) {
@ -74,7 +74,7 @@ char *SDL_getenv(const char *name)
return NULL; return NULL;
} }
if ( bufferlen > SDL_envmemlen ) { if ( bufferlen > SDL_envmemlen ) {
char *newmem = (char *)realloc(SDL_envmem, bufferlen); char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
if ( newmem == NULL ) { if ( newmem == NULL ) {
return NULL; return NULL;
} }
@ -140,7 +140,7 @@ int SDL_putenv(const char *variable)
/* Didn't find it in the environment, expand and add */ /* Didn't find it in the environment, expand and add */
if ( ! added ) { if ( ! added ) {
new_env = realloc(SDL_env, (i+2)*sizeof(char *)); new_env = SDL_realloc(SDL_env, (i+2)*sizeof(char *));
if ( new_env ) { if ( new_env ) {
SDL_env = new_env; SDL_env = new_env;
SDL_env[i++] = new_variable; SDL_env[i++] = new_variable;

View file

@ -39,6 +39,11 @@
#define LACKS_ERRNO_H #define LACKS_ERRNO_H
#define LACKS_STDLIB_H #define LACKS_STDLIB_H
#define ABORT #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 This is a version (aka dlmalloc) of malloc/free/realloc written by

View file

@ -233,9 +233,9 @@ typedef struct { char * first; char * last; } stack_entry;
/* Shift everything in [test,first) \ /* Shift everything in [test,first) \
* up by one, and place |first| \ * up by one, and place |first| \
* where |test| is. */ \ * where |test| is. */ \
memcpy(pivot,first,size); \ SDL_memcpy(pivot,first,size); \
memmove(test+size,test,first-test); \ SDL_memmove(test+size,test,first-test); \
memcpy(test,pivot,size); \ 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]; stack_entry stack[STACK_SIZE];
int stacktop=0; int stacktop=0;
char *first,*last; char *first,*last;
char *pivot=malloc(size); char *pivot=SDL_malloc(size);
size_t trunc=TRUNC_nonaligned*size; size_t trunc=TRUNC_nonaligned*size;
assert(pivot!=0); assert(pivot!=0);
@ -310,7 +310,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
/* Select pivot */ /* Select pivot */
{ char * mid=first+size*((last-first)/size >> 1); { char * mid=first+size*((last-first)/size >> 1);
Pivot(SWAP_nonaligned,size); Pivot(SWAP_nonaligned,size);
memcpy(pivot,mid,size); SDL_memcpy(pivot,mid,size);
} }
/* Partition. */ /* Partition. */
Partition(SWAP_nonaligned,size); 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); PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size);
Insertion(SWAP_nonaligned); Insertion(SWAP_nonaligned);
free(pivot); SDL_free(pivot);
} }
static void qsort_aligned(void *base, size_t nmemb, size_t size, 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]; stack_entry stack[STACK_SIZE];
int stacktop=0; int stacktop=0;
char *first,*last; char *first,*last;
char *pivot=malloc(size); char *pivot=SDL_malloc(size);
size_t trunc=TRUNC_aligned*size; size_t trunc=TRUNC_aligned*size;
assert(pivot!=0); assert(pivot!=0);
@ -341,7 +341,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size,
/* Select pivot */ /* Select pivot */
{ char * mid=first+size*((last-first)/size >> 1); { char * mid=first+size*((last-first)/size >> 1);
Pivot(SWAP_aligned,size); Pivot(SWAP_aligned,size);
memcpy(pivot,mid,size); SDL_memcpy(pivot,mid,size);
} }
/* Partition. */ /* Partition. */
Partition(SWAP_aligned,size); 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); PreInsertion(SWAP_aligned,TRUNC_aligned,size);
Insertion(SWAP_aligned); Insertion(SWAP_aligned);
free(pivot); SDL_free(pivot);
} }
static void qsort_words(void *base, size_t nmemb, 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]; stack_entry stack[STACK_SIZE];
int stacktop=0; int stacktop=0;
char *first,*last; char *first,*last;
char *pivot=malloc(WORD_BYTES); char *pivot=SDL_malloc(WORD_BYTES);
assert(pivot!=0); assert(pivot!=0);
first=(char*)base; last=first+(nmemb-1)*WORD_BYTES; first=(char*)base; last=first+(nmemb-1)*WORD_BYTES;
@ -398,7 +398,7 @@ fprintf(stderr,"pivot=%d\n",*(int*)pivot);
*pr=*pl; } *pr=*pl; }
if (pr!=(int*)first) *pr=*(int*)pivot; if (pr!=(int*)first) *pr=*(int*)pivot;
} }
free(pivot); SDL_free(pivot);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View file

@ -375,7 +375,7 @@ char *SDL_strchr(const char *string, int c)
#ifndef HAVE_STRRCHR #ifndef HAVE_STRRCHR
char *SDL_strrchr(const char *string, int c) 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 ) { while ( bufp >= string ) {
if ( *bufp == c ) { if ( *bufp == c ) {
return (char *)bufp; return (char *)bufp;
@ -388,9 +388,9 @@ char *SDL_strrchr(const char *string, int c)
#ifndef HAVE_STRSTR #ifndef HAVE_STRSTR
char *SDL_strstr(const char *haystack, const char *needle) char *SDL_strstr(const char *haystack, const char *needle)
{ {
size_t length = strlen(needle); size_t length = SDL_strlen(needle);
while ( *haystack ) { while ( *haystack ) {
if ( strncmp(haystack, needle, length) == 0 ) { if ( SDL_strncmp(haystack, needle, length) == 0 ) {
return (char *)haystack; return (char *)haystack;
} }
} }
@ -429,9 +429,9 @@ char *SDL_ltoa(long value, char *string, int radix)
/* The numbers went into the string backwards. :) */ /* The numbers went into the string backwards. :) */
if ( *string == '-' ) { if ( *string == '-' ) {
_strrev(string+1); SDL_strrev(string+1);
} else { } else {
_strrev(string); SDL_strrev(string);
} }
return string; return string;
@ -454,7 +454,7 @@ char *SDL_ultoa(unsigned long value, char *string, int radix)
*bufp = '\0'; *bufp = '\0';
/* The numbers went into the string backwards. :) */ /* The numbers went into the string backwards. :) */
_strrev(string); SDL_strrev(string);
return string; return string;
} }
@ -497,9 +497,9 @@ char *SDL_lltoa(Sint64 value, char *string, int radix)
/* The numbers went into the string backwards. :) */ /* The numbers went into the string backwards. :) */
if ( *string == '-' ) { if ( *string == '-' ) {
_strrev(string+1); SDL_strrev(string+1);
} else { } else {
_strrev(string); SDL_strrev(string);
} }
return string; return string;
@ -522,7 +522,7 @@ char *SDL_ulltoa(Uint64 value, char *string, int radix)
*bufp = '\0'; *bufp = '\0';
/* The numbers went into the string backwards. :) */ /* The numbers went into the string backwards. :) */
_strrev(string); SDL_strrev(string);
return string; return string;
} }
@ -878,12 +878,12 @@ static size_t SDL_PrintLong(char *text, long value, int radix, size_t maxlen)
char num[130]; char num[130];
size_t size; size_t size;
_ltoa(value, num, radix); SDL_ltoa(value, num, radix);
size = SDL_strlen(num); size = SDL_strlen(num);
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
strncpy(text, num, size); SDL_strncpy(text, num, size);
return size; return size;
} }
@ -892,12 +892,12 @@ static size_t SDL_PrintUnsignedLong(char *text, unsigned long value, int radix,
char num[130]; char num[130];
size_t size; size_t size;
_ultoa(value, num, radix); SDL_ultoa(value, num, radix);
size = SDL_strlen(num); size = SDL_strlen(num);
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
strncpy(text, num, size); SDL_strncpy(text, num, size);
return size; return size;
} }
@ -907,12 +907,12 @@ static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxl
char num[130]; char num[130];
size_t size; size_t size;
_i64toa(value, num, radix); SDL_lltoa(value, num, radix);
size = SDL_strlen(num); size = SDL_strlen(num);
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
strncpy(text, num, size); SDL_strncpy(text, num, size);
return size; return size;
} }
@ -921,12 +921,12 @@ static size_t SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, siz
char num[130]; char num[130];
size_t size; size_t size;
_ui64toa(value, num, radix); SDL_ulltoa(value, num, radix);
size = SDL_strlen(num); size = SDL_strlen(num);
if ( size > maxlen ) { if ( size > maxlen ) {
size = maxlen; size = maxlen;
} }
strncpy(text, num, size); SDL_strncpy(text, num, size);
return size; return size;
} }
@ -1076,7 +1076,7 @@ int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
break; break;
} }
if ( do_lowercase ) { if ( do_lowercase ) {
_strlwr(text); SDL_strlwr(text);
} }
done = SDL_TRUE; done = SDL_TRUE;
break; break;

View file

@ -99,16 +99,16 @@ static void SDL_AddThread(SDL_Thread *thread)
SDL_numthreads, SDL_maxthreads); SDL_numthreads, SDL_maxthreads);
#endif #endif
if ( SDL_numthreads == SDL_maxthreads ) { if ( SDL_numthreads == SDL_maxthreads ) {
threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
(sizeof *threads)); (sizeof *threads));
if ( threads == NULL ) { if ( threads == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
goto done; goto done;
} }
memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
SDL_maxthreads += ARRAY_CHUNKSIZE; SDL_maxthreads += ARRAY_CHUNKSIZE;
if ( SDL_Threads ) { if ( SDL_Threads ) {
free(SDL_Threads); SDL_free(SDL_Threads);
} }
SDL_Threads = threads; SDL_Threads = threads;
} }
@ -136,7 +136,7 @@ static void SDL_DelThread(SDL_Thread *thread)
} }
} else { } else {
SDL_maxthreads = 0; SDL_maxthreads = 0;
free(SDL_Threads); SDL_free(SDL_Threads);
SDL_Threads = NULL; SDL_Threads = NULL;
} }
#ifdef DEBUG_THREADS #ifdef DEBUG_THREADS
@ -223,19 +223,19 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
int ret; int ret;
/* Allocate memory for the thread info structure */ /* Allocate memory for the thread info structure */
thread = (SDL_Thread *)malloc(sizeof(*thread)); thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
if ( thread == NULL ) { if ( thread == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(NULL); return(NULL);
} }
memset(thread, 0, (sizeof *thread)); SDL_memset(thread, 0, (sizeof *thread));
thread->status = -1; thread->status = -1;
/* Set up the arguments for the thread */ /* Set up the arguments for the thread */
args = (thread_args *)malloc(sizeof(*args)); args = (thread_args *)SDL_malloc(sizeof(*args));
if ( args == NULL ) { if ( args == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
free(thread); SDL_free(thread);
return(NULL); return(NULL);
} }
args->func = fn; args->func = fn;
@ -243,8 +243,8 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
args->info = thread; args->info = thread;
args->wait = SDL_CreateSemaphore(0); args->wait = SDL_CreateSemaphore(0);
if ( args->wait == NULL ) { if ( args->wait == NULL ) {
free(thread); SDL_free(thread);
free(args); SDL_free(args);
return(NULL); return(NULL);
} }
@ -263,11 +263,11 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data)
} else { } else {
/* Oops, failed. Gotta free everything */ /* Oops, failed. Gotta free everything */
SDL_DelThread(thread); SDL_DelThread(thread);
free(thread); SDL_free(thread);
thread = NULL; thread = NULL;
} }
SDL_DestroySemaphore(args->wait); SDL_DestroySemaphore(args->wait);
free(args); SDL_free(args);
/* Everything is running now */ /* Everything is running now */
return(thread); return(thread);
@ -281,7 +281,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status)
*status = thread->status; *status = thread->status;
} }
SDL_DelThread(thread); SDL_DelThread(thread);
free(thread); SDL_free(thread);
} }
} }

View file

@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{ {
SDL_sem *sem; SDL_sem *sem;
sem = (SDL_sem *)malloc(sizeof(*sem)); sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if ( ! sem ) { if ( ! sem ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
@ -53,7 +53,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
D(bug("Creating semaphore %lx...\n",sem)); D(bug("Creating semaphore %lx...\n",sem));
memset(sem,0,sizeof(*sem)); SDL_memset(sem,0,sizeof(*sem));
InitSemaphore(&sem->Sem); InitSemaphore(&sem->Sem);
@ -66,7 +66,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
if ( sem ) { if ( sem ) {
// Condizioni per liberare i task in attesa? // Condizioni per liberare i task in attesa?
free(sem); SDL_free(sem);
} }
} }

View file

@ -84,16 +84,16 @@ static void SDL_AddThread(SDL_Thread *thread)
SDL_numthreads, SDL_maxthreads); SDL_numthreads, SDL_maxthreads);
#endif #endif
if ( SDL_numthreads == SDL_maxthreads ) { if ( SDL_numthreads == SDL_maxthreads ) {
threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
(sizeof *threads)); (sizeof *threads));
if ( threads == NULL ) { if ( threads == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
goto done; goto done;
} }
memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
SDL_maxthreads += ARRAY_CHUNKSIZE; SDL_maxthreads += ARRAY_CHUNKSIZE;
if ( SDL_Threads ) { if ( SDL_Threads ) {
free(SDL_Threads); SDL_free(SDL_Threads);
} }
SDL_Threads = threads; SDL_Threads = threads;
} }
@ -198,19 +198,19 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
int ret; int ret;
/* Allocate memory for the thread info structure */ /* Allocate memory for the thread info structure */
thread = (SDL_Thread *)malloc(sizeof(*thread)); thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
if ( thread == NULL ) { if ( thread == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(NULL); return(NULL);
} }
memset(thread, 0, (sizeof *thread)); SDL_memset(thread, 0, (sizeof *thread));
thread->status = -1; thread->status = -1;
/* Set up the arguments for the thread */ /* Set up the arguments for the thread */
args = (thread_args *)malloc(sizeof(*args)); args = (thread_args *)SDL_malloc(sizeof(*args));
if ( args == NULL ) { if ( args == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
free(thread); SDL_free(thread);
return(NULL); return(NULL);
} }
args->func = fn; args->func = fn;
@ -218,8 +218,8 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
args->info = thread; args->info = thread;
args->wait = FindTask(NULL); args->wait = FindTask(NULL);
if ( args->wait == NULL ) { if ( args->wait == NULL ) {
free(thread); SDL_free(thread);
free(args); SDL_free(args);
SDL_OutOfMemory(); SDL_OutOfMemory();
return(NULL); return(NULL);
} }
@ -239,10 +239,10 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
} else { } else {
/* Oops, failed. Gotta free everything */ /* Oops, failed. Gotta free everything */
SDL_DelThread(thread); SDL_DelThread(thread);
free(thread); SDL_free(thread);
thread = NULL; thread = NULL;
} }
free(args); SDL_free(args);
/* Everything is running now */ /* Everything is running now */
return(thread); return(thread);
@ -256,7 +256,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status)
*status = thread->status; *status = thread->status;
} }
SDL_DelThread(thread); SDL_DelThread(thread);
free(thread); SDL_free(thread);
} }
} }

View file

@ -37,12 +37,12 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{ {
SDL_sem *sem; SDL_sem *sem;
sem = (SDL_sem *)malloc(sizeof(*sem)); sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if ( sem ) { if ( sem ) {
sem->id = create_sem(initial_value, "SDL semaphore"); sem->id = create_sem(initial_value, "SDL semaphore");
if ( sem->id < B_NO_ERROR ) { if ( sem->id < B_NO_ERROR ) {
SDL_SetError("create_sem() failed"); SDL_SetError("create_sem() failed");
free(sem); SDL_free(sem);
sem = NULL; sem = NULL;
} }
} else { } else {
@ -58,7 +58,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
if ( sem->id >= B_NO_ERROR ) { if ( sem->id >= B_NO_ERROR ) {
delete_sem(sem->id); delete_sem(sem->id);
} }
free(sem); SDL_free(sem);
} }
} }

View file

@ -113,11 +113,11 @@ struct SDL_semaphore {
/* Create a semaphore, initialized with value */ /* Create a semaphore, initialized with value */
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{ {
SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem)); SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
if ( sem ) { if ( sem ) {
if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) { if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
SDL_SetError("sem_init() failed"); SDL_SetError("sem_init() failed");
free(sem); SDL_free(sem);
sem = NULL; sem = NULL;
} else { } else {
sem->sem = &sem->sem_data; sem->sem = &sem->sem_data;
@ -132,7 +132,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
{ {
if ( sem ) { if ( sem ) {
sem_destroy(sem->sem); sem_destroy(sem->sem);
free(sem); SDL_free(sem);
} }
} }
@ -322,7 +322,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value)
goto RETURN; goto RETURN;
} }
*sem = (sem_t)malloc(sizeof(struct sem)); *sem = (sem_t)SDL_malloc(sizeof(struct sem));
if (*sem == NULL) { if (*sem == NULL) {
errno = ENOSPC; errno = ENOSPC;
retval = -1; retval = -1;
@ -333,7 +333,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value)
* Initialize the semaphore. * Initialize the semaphore.
*/ */
if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) { if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) {
free(*sem); SDL_free(*sem);
errno = ENOSPC; errno = ENOSPC;
retval = -1; retval = -1;
goto RETURN; goto RETURN;
@ -341,7 +341,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value)
if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) { if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) {
pthread_mutex_destroy(&(*sem)->lock); pthread_mutex_destroy(&(*sem)->lock);
free(*sem); SDL_free(*sem);
errno = ENOSPC; errno = ENOSPC;
retval = -1; retval = -1;
goto RETURN; goto RETURN;
@ -377,7 +377,7 @@ sem_destroy(sem_t *sem)
pthread_cond_destroy(&(*sem)->gtzero); pthread_cond_destroy(&(*sem)->gtzero);
(*sem)->magic = 0; (*sem)->magic = 0;
free(*sem); SDL_free(*sem);
retval = 0; retval = 0;
RETURN: RETURN:

View file

@ -46,7 +46,7 @@ SDL_cond * SDL_CreateCond(void)
{ {
SDL_cond *cond; SDL_cond *cond;
cond = (SDL_cond *) malloc(sizeof(SDL_cond)); cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
if ( cond ) { if ( cond ) {
cond->lock = SDL_CreateMutex(); cond->lock = SDL_CreateMutex();
cond->wait_sem = SDL_CreateSemaphore(0); cond->wait_sem = SDL_CreateSemaphore(0);
@ -75,7 +75,7 @@ void SDL_DestroyCond(SDL_cond *cond)
if ( cond->lock ) { if ( cond->lock ) {
SDL_DestroyMutex(cond->lock); SDL_DestroyMutex(cond->lock);
} }
free(cond); SDL_free(cond);
} }
} }

View file

@ -43,7 +43,7 @@ SDL_mutex *SDL_CreateMutex(void)
SDL_mutex *mutex; SDL_mutex *mutex;
/* Allocate mutex memory */ /* Allocate mutex memory */
mutex = (SDL_mutex *)malloc(sizeof(*mutex)); mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
if ( mutex ) { if ( mutex ) {
spinlock_init(&mutex->mutex); spinlock_init(&mutex->mutex);
mutex->recursive = 0; mutex->recursive = 0;
@ -58,7 +58,7 @@ SDL_mutex *SDL_CreateMutex(void)
void SDL_DestroyMutex(SDL_mutex *mutex) void SDL_DestroyMutex(SDL_mutex *mutex)
{ {
if ( mutex ) { if ( mutex ) {
free(mutex); SDL_free(mutex);
} }
} }

View file

@ -44,7 +44,7 @@ SDL_cond * SDL_CreateCond(void)
{ {
SDL_cond *cond; SDL_cond *cond;
cond = (SDL_cond *) malloc(sizeof(SDL_cond)); cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
if ( cond ) { if ( cond ) {
cond->lock = SDL_CreateMutex(); cond->lock = SDL_CreateMutex();
cond->wait_sem = SDL_CreateSemaphore(0); cond->wait_sem = SDL_CreateSemaphore(0);
@ -73,7 +73,7 @@ void SDL_DestroyCond(SDL_cond *cond)
if ( cond->lock ) { if ( cond->lock ) {
SDL_DestroyMutex(cond->lock); SDL_DestroyMutex(cond->lock);
} }
free(cond); SDL_free(cond);
} }
} }

View file

@ -40,14 +40,14 @@ SDL_mutex *SDL_CreateMutex(void)
SDL_mutex *mutex; SDL_mutex *mutex;
/* Allocate mutex memory */ /* Allocate mutex memory */
mutex = (SDL_mutex *)malloc(sizeof(*mutex)); mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
if ( mutex ) { if ( mutex ) {
/* Create the mutex semaphore, with initial value 1 */ /* Create the mutex semaphore, with initial value 1 */
mutex->sem = SDL_CreateSemaphore(1); mutex->sem = SDL_CreateSemaphore(1);
mutex->recursive = 0; mutex->recursive = 0;
mutex->owner = 0; mutex->owner = 0;
if ( ! mutex->sem ) { if ( ! mutex->sem ) {
free(mutex); SDL_free(mutex);
mutex = NULL; mutex = NULL;
} }
} else { } else {
@ -63,7 +63,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
if ( mutex->sem ) { if ( mutex->sem ) {
SDL_DestroySemaphore(mutex->sem); SDL_DestroySemaphore(mutex->sem);
} }
free(mutex); SDL_free(mutex);
} }
} }

View file

@ -85,7 +85,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{ {
SDL_sem *sem; SDL_sem *sem;
sem = (SDL_sem *)malloc(sizeof(*sem)); sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if ( ! sem ) { if ( ! sem ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(0); return(0);
@ -118,7 +118,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
SDL_mutexP(sem->count_lock); SDL_mutexP(sem->count_lock);
SDL_mutexV(sem->count_lock); SDL_mutexV(sem->count_lock);
SDL_DestroyMutex(sem->count_lock); SDL_DestroyMutex(sem->count_lock);
free(sem); SDL_free(sem);
} }
} }

View file

@ -62,11 +62,11 @@ SDL_cond * SDL_CreateCond(void)
{ {
SDL_cond *cond; SDL_cond *cond;
cond = (SDL_cond *) malloc(sizeof(SDL_cond)); cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
if ( cond ) { if ( cond ) {
if ( pthread_cond_init(&cond->cond, NULL) < 0 ) { if ( pthread_cond_init(&cond->cond, NULL) < 0 ) {
SDL_SetError("pthread_cond_init() failed"); SDL_SetError("pthread_cond_init() failed");
free(cond); SDL_free(cond);
cond = NULL; cond = NULL;
} }
} }
@ -78,7 +78,7 @@ void SDL_DestroyCond(SDL_cond *cond)
{ {
if ( cond ) { if ( cond ) {
pthread_cond_destroy(&cond->cond); pthread_cond_destroy(&cond->cond);
free(cond); SDL_free(cond);
} }
} }

View file

@ -71,7 +71,7 @@ SDL_mutex *SDL_CreateMutex (void)
#endif /* PTHREAD_RECURSIVE_MUTEX */ #endif /* PTHREAD_RECURSIVE_MUTEX */
if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) { if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
SDL_SetError("pthread_mutex_init() failed"); SDL_SetError("pthread_mutex_init() failed");
free(mutex); SDL_free(mutex);
mutex = NULL; mutex = NULL;
} }
} else { } else {
@ -84,7 +84,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex)
{ {
if ( mutex ) { if ( mutex ) {
pthread_mutex_destroy(&mutex->id); pthread_mutex_destroy(&mutex->id);
free(mutex); SDL_free(mutex);
} }
} }

View file

@ -68,7 +68,7 @@ struct SDL_semaphore {
/* Create a semaphore, initialized with value */ /* Create a semaphore, initialized with value */
SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
{ {
SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem)); SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
if ( sem ) { if ( sem ) {
#ifdef USE_NAMED_SEMAPHORES #ifdef USE_NAMED_SEMAPHORES
static int semnum = 0; static int semnum = 0;
@ -78,7 +78,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
sem->sem = sem_open(name, O_CREAT, 0600, initial_value); sem->sem = sem_open(name, O_CREAT, 0600, initial_value);
if ( sem->sem == (sem_t *)SEM_FAILED ) { if ( sem->sem == (sem_t *)SEM_FAILED ) {
SDL_SetError("sem_open(%s) failed", name); SDL_SetError("sem_open(%s) failed", name);
free(sem); SDL_free(sem);
sem = NULL; sem = NULL;
} else { } else {
sem_unlink(name); sem_unlink(name);
@ -86,7 +86,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
#else #else
if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) { if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
SDL_SetError("sem_init() failed"); SDL_SetError("sem_init() failed");
free(sem); SDL_free(sem);
sem = NULL; sem = NULL;
} else { } else {
sem->sem = &sem->sem_data; sem->sem = &sem->sem_data;
@ -106,7 +106,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
#else #else
sem_destroy(sem->sem); sem_destroy(sem->sem);
#endif #endif
free(sem); SDL_free(sem);
} }
} }
@ -245,7 +245,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
union semun init; union semun init;
key_t key; key_t key;
sem = (SDL_sem *)malloc(sizeof(*sem)); sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if ( sem == NULL ) { if ( sem == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(NULL); return(NULL);
@ -269,7 +269,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
/* Report the error if we eventually failed */ /* Report the error if we eventually failed */
if ( sem->id < 0 ) { if ( sem->id < 0 ) {
SDL_SetError("Couldn't create semaphore"); SDL_SetError("Couldn't create semaphore");
free(sem); SDL_free(sem);
return(NULL); return(NULL);
} }
init.val = initial_value; /* Initialize semaphore */ init.val = initial_value; /* Initialize semaphore */
@ -287,7 +287,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
dummy.val = 0; dummy.val = 0;
semctl(sem->id, 0, IPC_RMID, dummy); semctl(sem->id, 0, IPC_RMID, dummy);
#endif #endif
free(sem); SDL_free(sem);
} }
} }

View file

@ -172,7 +172,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
void *stack; void *stack;
/* Allocate memory for thread stack */ /* Allocate memory for thread stack */
stack = malloc(STACKSIZE); stack = SDL_malloc(STACKSIZE);
if ( stack == (void *)0 ) { if ( stack == (void *)0 ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return(-1); return(-1);
@ -186,7 +186,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
thread->handle = clone(RunThread, stack, thread->handle = clone(RunThread, stack,
(CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND), args); (CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND), args);
if ( thread->handle < 0 ) { if ( thread->handle < 0 ) {
free(thread->data); SDL_free(thread->data);
SDL_SetError("Not enough resources to create thread"); SDL_SetError("Not enough resources to create thread");
return(-1); return(-1);
} }
@ -233,7 +233,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread)
while ( system(command) == 0 ) while ( system(command) == 0 )
sleep(1); sleep(1);
#endif #endif
free(thread->data); SDL_free(thread->data);
} }
void SDL_SYS_KillThread(SDL_Thread *thread) void SDL_SYS_KillThread(SDL_Thread *thread)

View file

@ -46,7 +46,7 @@ DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void)
{ {
SDL_cond *cond; SDL_cond *cond;
cond = (SDL_cond *) malloc(sizeof(SDL_cond)); cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
if ( cond ) { if ( cond ) {
cond->lock = SDL_CreateMutex(); cond->lock = SDL_CreateMutex();
cond->wait_sem = SDL_CreateSemaphore(0); cond->wait_sem = SDL_CreateSemaphore(0);
@ -75,7 +75,7 @@ DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond)
if ( cond->lock ) { if ( cond->lock ) {
SDL_DestroyMutex(cond->lock); SDL_DestroyMutex(cond->lock);
} }
free(cond); SDL_free(cond);
} }
} }

View file

@ -43,7 +43,7 @@ DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void)
APIRET ulrc; APIRET ulrc;
/* Allocate mutex memory */ /* Allocate mutex memory */
mutex = (SDL_mutex *)malloc(sizeof(*mutex)); mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
if (mutex) if (mutex)
{ {
/* Create the mutex, with initial value signaled */ /* Create the mutex, with initial value signaled */
@ -54,7 +54,7 @@ DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void)
if (ulrc!=NO_ERROR) if (ulrc!=NO_ERROR)
{ {
SDL_SetError("Couldn't create mutex"); SDL_SetError("Couldn't create mutex");
free(mutex); SDL_free(mutex);
mutex = NULL; mutex = NULL;
} }
} else { } else {
@ -73,7 +73,7 @@ DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex)
DosCloseMutexSem(mutex->hmtxID); DosCloseMutexSem(mutex->hmtxID);
mutex->hmtxID = 0; mutex->hmtxID = 0;
} }
free(mutex); SDL_free(mutex);
} }
} }

View file

@ -48,13 +48,13 @@ DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value)
ULONG ulrc; ULONG ulrc;
/* Allocate sem memory */ /* Allocate sem memory */
sem = (SDL_sem *)malloc(sizeof(*sem)); sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
if ( sem ) { if ( sem ) {
/* Create the mutex semaphore */ /* Create the mutex semaphore */
ulrc = DosCreateMutexSem(NULL,&(sem->id),0,TRUE); ulrc = DosCreateMutexSem(NULL,&(sem->id),0,TRUE);
if ( ulrc ) { if ( ulrc ) {
SDL_SetError("Couldn't create semaphore"); SDL_SetError("Couldn't create semaphore");
free(sem); SDL_free(sem);
sem = NULL; sem = NULL;
} else } else
{ {
@ -77,7 +77,7 @@ DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem)
DosCloseMutexSem(sem->id); DosCloseMutexSem(sem->id);
sem->id = 0; sem->id = 0;
} }
free(sem); SDL_free(sem);
} }
} }

Some files were not shown because too many files have changed in this diff Show more