From 41ee6dff2ec1941e60acfcae4a4bde8fa6ad3bd6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 7 Feb 2006 06:59:48 +0000 Subject: [PATCH] Use SDL_ prefixed versions of C library functions. FIXME: Change #include to #include "SDL_stdlib.h" Change #include to #include "SDL_string.h" Make sure nothing else broke because of this... --- include/SDL_config.h | 12 ++- include/SDL_getenv.h | 37 +------ include/SDL_stdlib.h | 21 ++-- include/SDL_string.h | 73 +++++-------- src/SDL.c | 4 +- src/SDL_error.c | 24 ++--- src/audio/SDL_audio.c | 24 ++--- src/audio/SDL_audiodev.c | 16 +-- src/audio/SDL_audiomem.c | 4 +- src/audio/SDL_sysaudio.h | 2 +- src/audio/SDL_wave.c | 22 ++-- src/audio/SDL_wave.h | 2 +- src/audio/alsa/SDL_alsa_audio.c | 18 ++-- src/audio/amigaos/SDL_ahiaudio.c | 20 ++-- src/audio/arts/SDL_artsaudio.c | 16 +-- src/audio/baudio/SDL_beaudio.cc | 18 ++-- src/audio/dart/SDL_dart.c | 38 +++---- src/audio/dc/SDL_dcaudio.c | 16 +-- src/audio/disk/SDL_diskaudio.c | 28 ++--- src/audio/dma/SDL_dmaaudio.c | 18 ++-- src/audio/dmedia/SDL_irixaudio.c | 16 +-- src/audio/dsp/SDL_dspaudio.c | 16 +-- src/audio/esd/SDL_esdaudio.c | 18 ++-- src/audio/macosx/SDL_coreaudio.c | 24 ++--- src/audio/macrom/SDL_romaudio.c | 32 +++--- src/audio/mint/SDL_mintaudio.c | 8 +- src/audio/mint/SDL_mintaudio_dma8.c | 20 ++-- src/audio/mint/SDL_mintaudio_gsxb.c | 20 ++-- src/audio/mint/SDL_mintaudio_mcsn.c | 20 ++-- src/audio/mint/SDL_mintaudio_stfa.c | 20 ++-- src/audio/mint/SDL_mintaudio_xbios.c | 22 ++-- src/audio/mme/SDL_mmeaudio.c | 16 +-- src/audio/nas/SDL_nasaudio.c | 16 +-- src/audio/nto/SDL_nto_audio.c | 24 ++--- src/audio/openbsd/SDL_openbsdaudio.c | 16 +-- src/audio/paudio/SDL_paudio.c | 18 ++-- src/audio/sun/SDL_sunaudio.c | 20 ++-- src/audio/ums/SDL_umsaudio.c | 28 ++--- src/audio/windib/SDL_dibaudio.c | 26 ++--- src/audio/windx5/SDL_dx5audio.c | 34 +++--- src/cdrom/SDL_cdrom.c | 8 +- src/cdrom/SDL_syscdrom.h | 2 +- src/cdrom/aix/SDL_syscdrom.c | 40 +++---- src/cdrom/beos/SDL_syscdrom.cc | 20 ++-- src/cdrom/bsdi/SDL_syscdrom.c | 24 ++--- src/cdrom/freebsd/SDL_syscdrom.c | 18 ++-- src/cdrom/linux/SDL_syscdrom.c | 54 +++++----- src/cdrom/macos/SDL_syscdrom.c | 34 +++--- src/cdrom/macosx/AudioFilePlayer.c | 10 +- src/cdrom/macosx/AudioFileReaderThread.c | 20 ++-- src/cdrom/macosx/SDLOSXCAGuard.c | 6 +- src/cdrom/openbsd/SDL_syscdrom.c | 18 ++-- src/cdrom/os2/SDL_syscdrom.c | 16 +-- src/cdrom/osf/SDL_syscdrom.c | 24 ++--- src/cdrom/qnx/SDL_syscdrom.c | 20 ++-- src/cdrom/win32/SDL_syscdrom.c | 10 +- src/events/SDL_active.c | 2 +- src/events/SDL_events.c | 8 +- src/events/SDL_keyboard.c | 8 +- src/events/SDL_mouse.c | 4 +- src/events/SDL_sysevents.h | 2 +- src/file/SDL_rwops.c | 18 ++-- src/joystick/SDL_joystick.c | 40 +++---- src/joystick/SDL_sysjoystick.h | 2 +- src/joystick/amigaos/SDL_sysjoystick.c | 4 +- src/joystick/beos/SDL_bejoystick.cc | 22 ++-- src/joystick/bsd/SDL_sysjoystick.c | 30 +++--- src/joystick/dc/SDL_sysjoystick.c | 6 +- src/joystick/linux/SDL_sysjoystick.c | 52 ++++----- src/joystick/macos/SDL_sysjoystick.c | 8 +- src/joystick/mint/SDL_sysjoystick.c | 6 +- src/joystick/os2/SDL_sysjoystick.c | 8 +- src/joystick/riscos/SDL_sysjoystick.c | 4 +- src/joystick/win32/SDL_mmjoystick.c | 20 ++-- src/loadso/macos/SDL_loadso.c | 4 +- src/loadso/macosx/SDL_loadso.c | 80 +++++++------- src/loadso/windows/SDL_loadso.c | 18 ++-- src/main/macos/SDL_main.c | 2 +- src/main/win32/SDL_win32_main.c | 32 +++--- src/stdlib/SDL_getenv.c | 12 +-- src/stdlib/SDL_malloc.c | 5 + src/stdlib/SDL_qsort.c | 22 ++-- src/stdlib/SDL_string.c | 36 +++---- src/thread/SDL_thread.c | 26 ++--- src/thread/amigaos/SDL_syssem.c | 6 +- src/thread/amigaos/SDL_thread.c | 24 ++--- src/thread/beos/SDL_syssem.c | 6 +- src/thread/bsdi/SDL_syssem.c | 14 +-- src/thread/dc/SDL_syscond.c | 4 +- src/thread/dc/SDL_sysmutex.c | 4 +- src/thread/generic/SDL_syscond.c | 4 +- src/thread/generic/SDL_sysmutex.c | 6 +- src/thread/generic/SDL_syssem.c | 4 +- src/thread/linux/SDL_syscond.c | 6 +- src/thread/linux/SDL_sysmutex.c | 4 +- src/thread/linux/SDL_syssem.c | 14 +-- src/thread/linux/SDL_systhread.c | 6 +- src/thread/os2/SDL_syscond.c | 4 +- src/thread/os2/SDL_sysmutex.c | 6 +- src/thread/os2/SDL_syssem.c | 6 +- src/thread/os2/SDL_systhread.c | 4 +- src/thread/pth/SDL_syscond.c | 6 +- src/thread/pth/SDL_sysmutex.c | 6 +- src/thread/riscos/SDL_syscond.c | 6 +- src/thread/riscos/SDL_sysmutex.c | 4 +- src/thread/riscos/SDL_syssem.c | 6 +- src/thread/win32/SDL_sysmutex.c | 6 +- src/thread/win32/SDL_syssem.c | 6 +- src/thread/win32/SDL_systhread.c | 4 +- src/timer/SDL_timer.c | 8 +- src/timer/linux/SDL_systimer.c | 4 +- src/video/SDL_RLEaccel.c | 24 ++--- src/video/SDL_blit_0.c | 2 +- src/video/SDL_blit_N.c | 4 +- src/video/SDL_bmp.c | 6 +- src/video/SDL_cursor.c | 26 ++--- src/video/SDL_gamma.c | 14 +-- src/video/SDL_pixels.c | 38 +++---- src/video/SDL_surface.c | 22 ++-- src/video/SDL_video.c | 74 ++++++------- src/video/SDL_yuv.c | 6 +- src/video/SDL_yuv_sw.c | 20 ++-- src/video/Xext/Xv/Xv.c | 8 +- src/video/Xext/Xxf86dga/XF86DGA.c | 8 +- src/video/aalib/SDL_aavideo.c | 28 ++--- src/video/ataricommon/SDL_atarievents.c | 8 +- src/video/ataricommon/SDL_atarigl.c | 8 +- src/video/ataricommon/SDL_biosevents.c | 8 +- src/video/ataricommon/SDL_gemdosevents.c | 8 +- src/video/ataricommon/SDL_ikbdevents.c | 2 +- src/video/bwindow/SDL_BWin.h | 2 +- src/video/bwindow/SDL_sysmouse.cc | 22 ++-- src/video/bwindow/SDL_sysvideo.cc | 30 +++--- src/video/bwindow/SDL_sysyuv.cc | 2 +- src/video/cybergfx/SDL_amigamouse.c | 2 +- src/video/cybergfx/SDL_cgxaccel.c | 8 +- src/video/cybergfx/SDL_cgximage.c | 24 ++--- src/video/cybergfx/SDL_cgxmodes.c | 12 +-- src/video/cybergfx/SDL_cgxvideo.c | 30 +++--- src/video/cybergfx/SDL_cgxwm.c | 22 ++-- src/video/cybergfx/SDL_cgxyuv.c | 10 +- src/video/dc/SDL_dcevents.c | 2 +- src/video/dc/SDL_dcvideo.c | 16 +-- src/video/dga/SDL_dgavideo.c | 40 +++---- src/video/directfb/SDL_DirectFB_video.c | 14 +-- src/video/dummy/SDL_nullvideo.c | 28 ++--- src/video/epoc/SDL_epocvideo.cpp | 26 ++--- src/video/fbcon/SDL_fbelo.c | 20 ++-- src/video/fbcon/SDL_fbevents.c | 30 +++--- src/video/fbcon/SDL_fbvideo.c | 106 +++++++++---------- src/video/gapi/SDL_gapivideo.c | 36 +++---- src/video/gem/SDL_gemevents.c | 10 +- src/video/gem/SDL_gemmouse.c | 10 +- src/video/gem/SDL_gemvideo.c | 28 ++--- src/video/ggi/SDL_ggivideo.c | 16 +-- src/video/ipod/SDL_ipodvideo.c | 4 +- src/video/maccommon/SDL_macmouse.c | 10 +- src/video/maccommon/SDL_macwm.c | 2 +- src/video/macdsp/SDL_dspvideo.c | 28 ++--- src/video/macrom/SDL_romvideo.c | 22 ++-- src/video/os2fslib/SDL_os2fslib.c | 78 +++++++------- src/video/photon/SDL_ph_gl.c | 2 +- src/video/photon/SDL_ph_image.c | 22 ++-- src/video/photon/SDL_ph_modes.c | 4 +- src/video/photon/SDL_ph_mouse.c | 10 +- src/video/photon/SDL_ph_video.c | 28 ++--- src/video/photon/SDL_ph_wm.c | 2 +- src/video/photon/SDL_phyuv.c | 8 +- src/video/picogui/SDL_pgevents.c | 4 +- src/video/picogui/SDL_pgvideo.c | 14 +-- src/video/ps2gs/SDL_gsevents.c | 16 +-- src/video/ps2gs/SDL_gsvideo.c | 24 ++--- src/video/ps2gs/SDL_gsyuv.c | 16 +-- src/video/qtopia/SDL_QWin.cc | 8 +- src/video/qtopia/SDL_sysevents.cc | 4 +- src/video/qtopia/SDL_sysvideo.cc | 22 ++-- src/video/riscos/SDL_riscosFullScreenVideo.c | 24 ++--- src/video/riscos/SDL_riscosevents.c | 2 +- src/video/riscos/SDL_riscosmouse.c | 10 +- src/video/riscos/SDL_riscossprite.c | 8 +- src/video/riscos/SDL_riscostask.c | 44 ++++---- src/video/riscos/SDL_riscosvideo.c | 16 +-- src/video/riscos/SDL_wimppoll.c | 2 +- src/video/riscos/SDL_wimpvideo.c | 12 +-- src/video/svga/SDL_svgaevents.c | 6 +- src/video/svga/SDL_svgavideo.c | 30 +++--- src/video/vgl/SDL_vglevents.c | 4 +- src/video/vgl/SDL_vglvideo.c | 34 +++--- src/video/wincommon/SDL_lowvideo.h | 6 +- src/video/wincommon/SDL_sysevents.c | 14 +-- src/video/wincommon/SDL_sysmouse.c | 22 ++-- src/video/wincommon/SDL_syswm.c | 6 +- src/video/wincommon/SDL_wingl.c | 12 +-- src/video/windib/SDL_dibevents.c | 10 +- src/video/windib/SDL_dibvideo.c | 54 +++++----- src/video/windx5/SDL_dx5events.c | 14 +-- src/video/windx5/SDL_dx5video.c | 92 ++++++++-------- src/video/windx5/SDL_dx5yuv.c | 18 ++-- src/video/wscons/SDL_wsconsvideo.c | 40 +++---- src/video/x11/SDL_x11dga.c | 4 +- src/video/x11/SDL_x11events.c | 6 +- src/video/x11/SDL_x11gl.c | 16 +-- src/video/x11/SDL_x11image.c | 4 +- src/video/x11/SDL_x11modes.c | 34 +++--- src/video/x11/SDL_x11mouse.c | 26 ++--- src/video/x11/SDL_x11video.c | 70 ++++++------ src/video/x11/SDL_x11video.h | 2 +- src/video/x11/SDL_x11wm.c | 16 +-- src/video/x11/SDL_x11yuv.c | 20 ++-- src/video/xbios/SDL_xbios.c | 42 ++++---- src/video/xbios/SDL_xbios_centscreen.c | 4 +- src/video/xbios/SDL_xbios_sb3.c | 2 +- 212 files changed, 1840 insertions(+), 1884 deletions(-) diff --git a/include/SDL_config.h b/include/SDL_config.h index f0c33183e..21f602ae8 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -54,16 +54,16 @@ #endif /* !_WIN32_WCE */ /* 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_REALLOC #define HAVE_FREE #ifndef HAVE_ALLOCA #define HAVE_ALLOCA #endif +#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */ +#define HAVE_GETENV +#define HAVE_PUTENV +#endif /*#define HAVE_QSORT*/ /* Features provided by SDL_string.h */ @@ -74,6 +74,8 @@ #define HAVE_STRLEN #define HAVE_STRCPY #define HAVE_STRNCPY +#define HAVE_STRCAT +#define HAVE_STRNCAT /*#define HAVE__STRREV*/ /*#define HAVE__STRUPR*/ /*#define HAVE__STRLWR*/ @@ -94,7 +96,7 @@ /*#define HAVE_STRCASECMP*/ #define HAVE_SSCANF /*#define HAVE_SNPRINTF*/ -#define HAVE_VSNPRINTF +/*#define HAVE_VSNPRINTF*/ #endif /* HAVE_LIBC */ diff --git a/include/SDL_getenv.h b/include/SDL_getenv.h index 66cdb477a..6301485fa 100644 --- a/include/SDL_getenv.h +++ b/include/SDL_getenv.h @@ -20,39 +20,4 @@ slouken@libsdl.org */ -#ifndef _SDL_getenv_h -#define _SDL_getenv_h - -#include "SDL_config.h" - -#ifdef HAVE_STDLIB_H -#include -#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 */ +#include "SDL_stdlib.h" diff --git a/include/SDL_stdlib.h b/include/SDL_stdlib.h index 26673bfdc..ce01a7dcc 100644 --- a/include/SDL_stdlib.h +++ b/include/SDL_stdlib.h @@ -49,9 +49,6 @@ char *alloca (); #endif #include "SDL_types.h" -#include "SDL_stdarg.h" -#include "SDL_getenv.h" - #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -62,21 +59,18 @@ extern "C" { #ifdef HAVE_MALLOC #define SDL_malloc malloc #else -#define malloc SDL_malloc extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); #endif #ifdef HAVE_REALLOC #define SDL_realloc realloc #else -#define realloc SDL_realloc extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); #endif #ifdef HAVE_FREE #define SDL_free free #else -#define free SDL_free extern DECLSPEC void SDLCALL SDL_free(void *mem); #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_free(data) #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) #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 #define SDL_qsort qsort #else -#define qsort SDL_qsort extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *)); #endif diff --git a/include/SDL_string.h b/include/SDL_string.h index b23db482a..b235f5a51 100644 --- a/include/SDL_string.h +++ b/include/SDL_string.h @@ -44,10 +44,9 @@ extern "C" { #endif -#ifndef HAVE_MEMSET -#define memset SDL_memset -#endif -#ifndef SDL_memset +#ifdef HAVE_MEMSET +#define SDL_memset memset +#else extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); #endif @@ -98,23 +97,14 @@ do { \ : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ : "memory" ); \ } 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 #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); #endif +#endif #if defined(__GNUC__) && defined(i386) #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); #endif -#ifndef HAVE_MEMMOVE -#define memmove SDL_memmove -#endif +#ifdef HAVE_MEMMOVE +#define SDL_memmove memmove +#else #define SDL_memmove(dst, src, len) \ do { \ if ( dst < src ) { \ @@ -173,109 +163,107 @@ do { \ SDL_revcpy(dst, src, len); \ } \ } while(0) - -#ifndef HAVE_MEMCMP -#define memcmp SDL_memcmp #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); #endif #ifdef HAVE_STRLEN #define SDL_strlen strlen #else -#define strlen SDL_strlen extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); #endif #ifdef HAVE_STRCPY #define SDL_strcpy strcpy #else -#define strcpy SDL_strcpy extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src); #endif #ifdef HAVE_STRNCPY #define SDL_strncpy strncpy #else -#define strncpy SDL_strncpy extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen); #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 #define SDL_strrev _strrev #else -#define _strrev SDL_strrev extern DECLSPEC char * SDLCALL SDL_strrev(char *string); #endif #ifdef HAVE__STRUPR #define SDL_strupr _strupr #else -#define _strupr SDL_strupr extern DECLSPEC char * SDLCALL SDL_strupr(char *string); #endif #ifdef HAVE__STRLWR #define SDL_strlwr _strlwr #else -#define _strlwr SDL_strlwr extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); #endif #ifdef HAVE_STRCHR #define SDL_strchr strchr #else -#define strchr SDL_strchr extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); #endif #ifdef HAVE_STRRCHR #define SDL_strrchr strrchr #else -#define strrchr SDL_strrchr extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); #endif #ifdef HAVE_STRSTR #define SDL_strstr strstr #else -#define strstr SDL_strstr extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); #endif #ifdef HAVE_ITOA #define SDL_itoa itoa #else -#define itoa SDL_itoa #define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) #endif #ifdef HAVE__LTOA #define SDL_ltoa _ltoa #else -#define _ltoa SDL_ltoa extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); #endif #ifdef HAVE__UITOA #define SDL_uitoa _uitoa #else -#define _uitoa SDL_uitoa #define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) #endif #ifdef HAVE__ULTOA #define SDL_ultoa _ultoa #else -#define _ultoa SDL_ultoa extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); #endif #ifdef HAVE_STRTOL #define SDL_strtol strtol #else -#define strtol SDL_strtol extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); #endif @@ -284,21 +272,18 @@ extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int bas #ifdef HAVE__I64TOA #define SDL_lltoa _i64toa #else -#define _i64toa SDL_lltoa extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); #endif #ifdef HAVE__UI64TOA #define SDL_ulltoa _ui64toa #else -#define _ui64toa SDL_ulltoa extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); #endif #ifdef HAVE_STRTOLL #define SDL_strtoll strtoll #else -#define strtoll SDL_strtoll extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); #endif @@ -307,14 +292,12 @@ extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int #ifdef HAVE_STRCMP #define SDL_strcmp strcmp #else -#define strcmp SDL_strcmp extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); #endif #ifdef HAVE_STRNCMP #define SDL_strncmp strncmp #else -#define strncmp SDL_strncmp extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); #endif @@ -325,28 +308,24 @@ extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size #ifdef HAVE_STRCASECMP #define SDL_strcasecmp strcasecmp #else -#define strcasecmp SDL_strcasecmp extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); #endif #ifdef HAVE_SSCANF #define SDL_sscanf sscanf #else -#define sscanf SDL_sscanf extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); #endif #ifdef HAVE_SNPRINTF #define SDL_snprintf snprintf #else -#define snprintf SDL_snprintf extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); #endif #ifdef HAVE_VSNPRINTF #define SDL_vsnprintf vsnprintf #else -#define vsnprintf SDL_vsnprintf extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); #endif diff --git a/src/SDL.c b/src/SDL.c index b86bc26bb..9d18916b2 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -66,7 +66,7 @@ int SDL_InitSubSystem(Uint32 flags) #ifndef DISABLE_VIDEO /* Initialize the video/event subsystem */ 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 ) { return(-1); } @@ -82,7 +82,7 @@ int SDL_InitSubSystem(Uint32 flags) #ifndef DISABLE_AUDIO /* Initialize the audio subsystem */ 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); } SDL_initialized |= SDL_INIT_AUDIO; diff --git a/src/SDL_error.c b/src/SDL_error.c index 79de509ce..bdf58feec 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -63,7 +63,7 @@ void SDL_SetError (const char *fmt, ...) /* Copy in the key, mark error as valid */ error = SDL_GetErrBuf(); 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'; va_start(ap, fmt); @@ -98,7 +98,7 @@ void SDL_SetError (const char *fmt, ...) char *str = va_arg(ap, char *); if (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->argc++; } @@ -125,9 +125,9 @@ static int PrintInt(Uint16 *str, unsigned int maxlen, int value) char tmp[128]; int len, i; - snprintf(tmp, SDL_arraysize(tmp), "%d", value); + SDL_snprintf(tmp, SDL_arraysize(tmp), "%d", value); len = 0; - if ( strlen(tmp) < maxlen ) { + if ( SDL_strlen(tmp) < maxlen ) { for ( i=0; tmp[i]; ++i ) { *str++ = tmp[i]; ++len; @@ -141,9 +141,9 @@ static int PrintDouble(Uint16 *str, unsigned int maxlen, double value) char tmp[128]; int len, i; - snprintf(tmp, SDL_arraysize(tmp), "%f", value); + SDL_snprintf(tmp, SDL_arraysize(tmp), "%f", value); len = 0; - if ( strlen(tmp) < maxlen ) { + if ( SDL_strlen(tmp) < maxlen ) { for ( i=0; tmp[i]; ++i ) { *str++ = tmp[i]; ++len; @@ -157,9 +157,9 @@ static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value) char tmp[128]; int len, i; - snprintf(tmp, SDL_arraysize(tmp), "%p", value); + SDL_snprintf(tmp, SDL_arraysize(tmp), "%p", value); len = 0; - if ( strlen(tmp) < maxlen ) { + if ( SDL_strlen(tmp) < maxlen ) { for ( i=0; tmp[i]; ++i ) { *str++ = tmp[i]; ++len; @@ -253,9 +253,9 @@ Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen) unsigned int i; /* Allocate the UNICODE buffer */ - errstr16 = (Uint16 *)malloc(maxlen * (sizeof *errstr16)); + errstr16 = (Uint16 *)SDL_malloc(maxlen * (sizeof *errstr16)); if ( ! errstr16 ) { - strncpy((char *)errstr, "Out of memory", maxlen); + SDL_strncpy((char *)errstr, "Out of memory", maxlen); errstr[maxlen-1] = '\0'; return(errstr); } @@ -269,7 +269,7 @@ Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen) } /* Free UNICODE buffer (if necessary) */ - free(errstr16); + SDL_free(errstr16); return(errstr); } @@ -320,7 +320,7 @@ int main(int argc, char *argv[]) SDL_SetError("Hi there!"); printf("Error 1: %s\n", SDL_GetError()); SDL_ClearError(); - memset(buffer, '1', BUFSIZ); + SDL_memset(buffer, '1', BUFSIZ); buffer[BUFSIZ] = 0; SDL_SetError("This is the error: %s (%f)", buffer, 1.0); printf("Error 2: %s\n", SDL_GetError()); diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 57091dca0..6f505eafe 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -220,7 +220,7 @@ int SDL_RunAudio(void *audiop) stream = audio->fake_stream; } } - memset(stream, silence, stream_len); + SDL_memset(stream, silence, stream_len); if ( ! audio->paused ) { SDL_mutexP(audio->mixer_lock); @@ -235,7 +235,7 @@ int SDL_RunAudio(void *audiop) if ( stream == NULL ) { stream = audio->fake_stream; } - memcpy(stream, audio->convert.buf, + SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt); } @@ -299,17 +299,17 @@ int SDL_AudioInit(const char *driver_name) audio = NULL; idx = 0; #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 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! :) */ 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; /* 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 ) { putenv("ESD_NO_SPAWN=1"); } @@ -329,13 +329,13 @@ int SDL_AudioInit(const char *driver_name) if ( audio == NULL ) { if ( driver_name != NULL ) { #if 0 /* This will be replaced with a better driver selection API */ - if ( strrchr(driver_name, ':') != NULL ) { - idx = atoi(strrchr(driver_name, ':')+1); + if ( SDL_strrchr(driver_name, ':') != NULL ) { + idx = atoi(SDL_strrchr(driver_name, ':')+1); } #endif for ( i=0; bootstrap[i]; ++i ) { - if (strncmp(bootstrap[i]->name, driver_name, - strlen(bootstrap[i]->name)) == 0) { + if (SDL_strncmp(bootstrap[i]->name, driver_name, + SDL_strlen(bootstrap[i]->name)) == 0) { if ( bootstrap[i]->available() ) { audio=bootstrap[i]->create(idx); break; @@ -375,7 +375,7 @@ int SDL_AudioInit(const char *driver_name) char *SDL_AudioDriverName(char *namebuf, int maxlen) { if ( current_audio != NULL ) { - strncpy(namebuf, current_audio->name, maxlen-1); + SDL_strncpy(namebuf, current_audio->name, maxlen-1); namebuf[maxlen-1] = '\0'; return(namebuf); } @@ -436,7 +436,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) SDL_CalculateAudioSpec(desired); /* Open the audio subsystem */ - memcpy(&audio->spec, desired, sizeof(audio->spec)); + SDL_memcpy(&audio->spec, desired, sizeof(audio->spec)); audio->convert.needed = 0; audio->enabled = 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 */ 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 || desired->format != audio->spec.format || desired->channels != audio->spec.channels ) { diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index 6279b19e1..e2d0542d7 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -55,8 +55,8 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) char audiopath[1024]; /* Figure out what our audio device is */ - if ( ((audiodev=getenv("SDL_PATH_DSP")) == NULL) && - ((audiodev=getenv("AUDIODEV")) == NULL) ) { + if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) && + ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) { if ( classic ) { audiodev = _PATH_DEV_AUDIO; } else { @@ -74,7 +74,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) audio_fd = open(audiodev, flags, 0); /* 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; struct stat sb; @@ -90,7 +90,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) audiodev = audiopath; } if ( path != NULL ) { - strncpy(path, audiodev, maxlen); + SDL_strncpy(path, audiodev, maxlen); path[maxlen-1] = '\0'; } return(audio_fd); @@ -130,15 +130,15 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags) int audio_fd; /* Figure out what our audio device is */ - if ((audiodev=getenv("SDL_PATH_DSP")) == NULL) { - audiodev=getenv("AUDIODEV"); + if ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) { + audiodev=SDL_getenv("AUDIODEV"); } if ( audiodev == NULL ) { return -1; } audio_fd = open(audiodev, flags, 0); if ( path != NULL ) { - strncpy(path, audiodev, maxlen); + SDL_strncpy(path, audiodev, maxlen); path[maxlen-1] = '\0'; } return audio_fd; @@ -168,7 +168,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) audio_fd = open(audiopath, flags, 0); if ( audio_fd > 0 ) { if ( path != NULL ) { - strncpy( path, audiopath, maxlen ); + SDL_strncpy( path, audiopath, maxlen ); path[maxlen-1] = '\0'; } return audio_fd; diff --git a/src/audio/SDL_audiomem.c b/src/audio/SDL_audiomem.c index c03f3d150..6333ffbc6 100644 --- a/src/audio/SDL_audiomem.c +++ b/src/audio/SDL_audiomem.c @@ -52,7 +52,7 @@ void *SDL_AllocAudioMem(int size) /* Set the segment for deletion when it is detatched */ shmctl(semid, IPC_RMID, NULL); /* Delets semid if shmat() fails */ #else - chunk = malloc(size); + chunk = SDL_malloc(size); #endif return((void *)chunk); } @@ -62,6 +62,6 @@ void SDL_FreeAudioMem(void *chunk) #ifdef FORK_HACK shmdt(chunk); #else - free(chunk); + SDL_free(chunk); #endif } diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 683dc5813..32754e4c1 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -2,7 +2,7 @@ SDL - Simple DirectMedia Layer 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 License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 5c8f33e6a..9a2af7ede 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -135,7 +135,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len) *audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) * MS_ADPCM_state.wSamplesPerBlock* MS_ADPCM_state.wavefmt.channels*sizeof(Sint16); - *audio_buf = (Uint8 *)malloc(*audio_len); + *audio_buf = (Uint8 *)SDL_malloc(*audio_len); if ( *audio_buf == NULL ) { SDL_Error(SDL_ENOMEM); return(-1); @@ -214,7 +214,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len) } encoded_len -= MS_ADPCM_state.wavefmt.blockalign; } - free(freeable); + SDL_free(freeable); 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) * IMA_ADPCM_state.wSamplesPerBlock* IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16); - *audio_buf = (Uint8 *)malloc(*audio_len); + *audio_buf = (Uint8 *)SDL_malloc(*audio_len); if ( *audio_buf == NULL ) { SDL_Error(SDL_ENOMEM); return(-1); @@ -394,7 +394,7 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len) } encoded_len -= IMA_ADPCM_state.wavefmt.blockalign; } - free(freeable); + SDL_free(freeable); return(0); } @@ -444,7 +444,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc, chunk.data = NULL; do { if ( chunk.data != NULL ) { - free(chunk.data); + SDL_free(chunk.data); } lenread = ReadChunk(src, &chunk); if ( lenread < 0 ) { @@ -489,7 +489,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc, was_error = 1; goto done; } - memset(spec, 0, (sizeof *spec)); + SDL_memset(spec, 0, (sizeof *spec)); spec->freq = SDL_SwapLE32(format->frequency); switch (SDL_SwapLE16(format->bitspersample)) { case 4: @@ -521,7 +521,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc, *audio_buf = NULL; do { if ( *audio_buf != NULL ) { - free(*audio_buf); + SDL_free(*audio_buf); } lenread = ReadChunk(src, &chunk); if ( lenread < 0 ) { @@ -553,7 +553,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc, done: if ( format != NULL ) { - free(format); + SDL_free(format); } if ( freesrc && src ) { SDL_RWclose(src); @@ -574,7 +574,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc, void SDL_FreeWAV(Uint8 *audio_buf) { 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->length = SDL_ReadLE32(src); - chunk->data = (Uint8 *)malloc(chunk->length); + chunk->data = (Uint8 *)SDL_malloc(chunk->length); if ( chunk->data == NULL ) { SDL_Error(SDL_ENOMEM); return(-1); } if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) { SDL_Error(SDL_EFREAD); - free(chunk->data); + SDL_free(chunk->data); return(-1); } return(chunk->length); diff --git a/src/audio/SDL_wave.h b/src/audio/SDL_wave.h index ae20b3035..38620cde7 100644 --- a/src/audio/SDL_wave.h +++ b/src/audio/SDL_wave.h @@ -2,7 +2,7 @@ SDL - Simple DirectMedia Layer 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 License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 9880e0071..4f40fff70 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -170,7 +170,7 @@ static const char *get_audio_device(int channels) { 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 (channels == 6) device = "surround51"; else if (channels == 4) device = "surround40"; @@ -202,8 +202,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); UnloadALSALibrary(); } @@ -213,20 +213,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) /* Initialize all variables that we clean on shutdown */ LoadALSALibrary(); - this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = ALSA_OpenAudio; @@ -435,7 +435,7 @@ static int ALSA_OpenAudio(_THIS, SDL_AudioSpec *spec) ALSA_CloseAudio(this); 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) */ parent = getpid(); diff --git a/src/audio/amigaos/SDL_ahiaudio.c b/src/audio/amigaos/SDL_ahiaudio.c index 0a3490f49..9ec263021 100644 --- a/src/audio/amigaos/SDL_ahiaudio.c +++ b/src/audio/amigaos/SDL_ahiaudio.c @@ -74,8 +74,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -87,20 +87,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) #endif /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = AHI_OpenAudio; @@ -316,7 +316,7 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) 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 ) { SDL_OutOfMemory(); @@ -325,8 +325,8 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) D(bug("Before mixbuf memset\n")); - memset(mixbuf[0], spec->silence, spec->size); - memset(mixbuf[1], spec->silence, spec->size); + SDL_memset(mixbuf[0], spec->silence, spec->size); + SDL_memset(mixbuf[1], spec->silence, spec->size); current_buffer=0; playing=0; diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index e3cc118b7..366421d26 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -152,8 +152,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); UnloadARTSLibrary(); } @@ -163,20 +163,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) /* Initialize all variables that we clean on shutdown */ LoadARTSLibrary(); - this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); stream = 0; /* Set the function pointers */ @@ -331,7 +331,7 @@ static int ARTSC_OpenAudio(_THIS, SDL_AudioSpec *spec) if ( mixbuf == NULL ) { 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) */ parent = getpid(); diff --git a/src/audio/baudio/SDL_beaudio.cc b/src/audio/baudio/SDL_beaudio.cc index b874a53c9..3a2727c6e 100644 --- a/src/audio/baudio/SDL_beaudio.cc +++ b/src/audio/baudio/SDL_beaudio.cc @@ -54,8 +54,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -63,20 +63,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *device; /* 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 ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->OpenAudio = BE_OpenAudio; @@ -102,7 +102,7 @@ static void FillSound(void *device, void *stream, size_t len, SDL_AudioDevice *audio = (SDL_AudioDevice *)device; /* 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 */ if ( ! audio->enabled ) @@ -115,7 +115,7 @@ static void FillSound(void *device, void *stream, size_t len, (Uint8 *)audio->convert.buf,audio->convert.len); SDL_mutexV(audio->mixer_lock); SDL_ConvertAudio(&audio->convert); - memcpy(stream,audio->convert.buf,audio->convert.len_cvt); + SDL_memcpy(stream,audio->convert.buf,audio->convert.len_cvt); } else { SDL_mutexP(audio->mixer_lock); (*audio->spec.callback)(audio->spec.userdata, diff --git a/src/audio/dart/SDL_dart.c b/src/audio/dart/SDL_dart.c index c364e2416..cf6e5f689 100644 --- a/src/audio/dart/SDL_dart.c +++ b/src/audio/dart/SDL_dart.c @@ -94,7 +94,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec) int rc; // 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! AmpOpenParms.pszDeviceType = (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16)); @@ -138,7 +138,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec) iBufSize = spec->size; // 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.ulFormatTag = MCI_WAVE_FORMAT_PCM; _this->hidden->MixSetupParms.ulSamplesPerSec = iFreq; @@ -170,7 +170,7 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec) // Ok, the device is initialized. // Now we should allocate buffers. For this, we need a place where // 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)) { // Not enough memory! // 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)) { // Could not allocate memory! // 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); SDL_SetError("DART could not allocate buffers"); return(-1); @@ -200,18 +200,18 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec) int i; for (i=0; ihidden->pMixBuffers[i].pBuffer)) || (!pBufferDesc)) { // Wrong buffer! // Close DART, and exit with error code! // Free buffer descriptions { int j; - for (j=0; jhidden->pMixBuffers[j].ulUserParm)); + for (j=0; jhidden->pMixBuffers[j].ulUserParm)); } // and cleanup 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); SDL_SetError("Error at internal buffer check"); 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 // audio data, but as we will continously send // 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; @@ -235,10 +235,10 @@ int DART_OpenAudio(_THIS, SDL_AudioSpec *spec) // Could not create event semaphore! { int i; - for (i=0; ihidden->pMixBuffers[i].ulUserParm)); + for (i=0; ihidden->pMixBuffers[i].ulUserParm)); } 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); SDL_SetError("Could not create event semaphore"); return(-1); @@ -363,14 +363,14 @@ void DART_CloseAudio(_THIS) // Free memory of buffer descriptions { 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 rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0); // Free bufferlist - free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; + SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; // Close dart 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) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -394,21 +394,21 @@ SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) - free(this); + SDL_free(this); return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DART_OpenAudio; diff --git a/src/audio/dc/SDL_dcaudio.c b/src/audio/dc/SDL_dcaudio.c index c565c6475..869d92676 100644 --- a/src/audio/dc/SDL_dcaudio.c +++ b/src/audio/dc/SDL_dcaudio.c @@ -60,8 +60,8 @@ static int DCAUD_Available(void) static void DCAUD_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *DCAUD_CreateDevice(int devindex) @@ -69,20 +69,20 @@ static SDL_AudioDevice *DCAUD_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DCAUD_OpenAudio; @@ -229,7 +229,7 @@ static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) if ( this->hidden->mixbuf == NULL ) { 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->rightpos = 0x11000+spec->size; this->hidden->playing = 0; diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index c63d8a583..c834f5d78 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -62,7 +62,7 @@ static void DISKAUD_CloseAudio(_THIS); 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); } @@ -75,10 +75,10 @@ static int DISKAUD_Available(void) int exists = 0; struct stat statbuf; const char *fname = DISKAUD_GetOutputFilename(); - const char *envr = getenv("SDL_AUDIODRIVER"); + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); available = 0; - if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { + if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { if (stat(fname, &statbuf) == 0) exists = 1; @@ -93,8 +93,8 @@ static int DISKAUD_Available(void) } return(available); #else - const char *envr = getenv("SDL_AUDIODRIVER"); - if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); + if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { return(1); } @@ -104,8 +104,8 @@ static int DISKAUD_Available(void) static void DISKAUD_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex) @@ -114,22 +114,22 @@ static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex) const char *envr; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } 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; /* Set the function pointers */ @@ -216,7 +216,7 @@ static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) if ( this->hidden->mixbuf == NULL ) { 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. :-) */ return(0); diff --git a/src/audio/dma/SDL_dmaaudio.c b/src/audio/dma/SDL_dmaaudio.c index e98e35ef9..e04cd4745 100644 --- a/src/audio/dma/SDL_dmaaudio.c +++ b/src/audio/dma/SDL_dmaaudio.c @@ -93,8 +93,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -102,20 +102,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -428,11 +428,11 @@ static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec) dma_buf = NULL; 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 */ { char *workaround; - workaround = getenv("SDL_DSP_NOSELECT"); + workaround = SDL_getenv("SDL_DSP_NOSELECT"); if ( workaround ) { frame_ticks = (float)(spec->samples*1000)/spec->freq; next_frame = SDL_GetTicks()+frame_ticks; diff --git a/src/audio/dmedia/SDL_irixaudio.c b/src/audio/dmedia/SDL_irixaudio.c index 93a7436f8..a6efe9666 100644 --- a/src/audio/dmedia/SDL_irixaudio.c +++ b/src/audio/dmedia/SDL_irixaudio.c @@ -62,8 +62,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -71,20 +71,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = AL_OpenAudio; @@ -211,7 +211,7 @@ static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec) SDL_OutOfMemory(); return(-1); } - memset(mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* We're ready to rock and roll. :-) */ return(0); diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index 2bb0d0cbd..714436a31 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -82,8 +82,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -91,20 +91,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -322,7 +322,7 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) DSP_CloseAudio(this); 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) */ parent = getpid(); diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index e57f0279c..f1a03ac5e 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -142,8 +142,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); UnloadESDLibrary(); } @@ -153,20 +153,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) /* Initialize all variables that we clean on shutdown */ LoadESDLibrary(); - this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -261,7 +261,7 @@ static char *get_progname(void) fp = fopen(temp, "r"); if ( fp != NULL ) { if ( fgets(temp, sizeof(temp)-1, fp) ) { - progname = strrchr(temp, '/'); + progname = SDL_strrchr(temp, '/'); if ( progname == NULL ) { progname = temp; } else { @@ -318,7 +318,7 @@ static int ESD_OpenAudio(_THIS, SDL_AudioSpec *spec) if ( mixbuf == NULL ) { 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) */ parent = getpid(); diff --git a/src/audio/macosx/SDL_coreaudio.c b/src/audio/macosx/SDL_coreaudio.c index ceed2e305..85bd9c6f3 100644 --- a/src/audio/macosx/SDL_coreaudio.c +++ b/src/audio/macosx/SDL_coreaudio.c @@ -52,8 +52,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -61,20 +61,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Core_OpenAudio; @@ -106,7 +106,7 @@ static OSStatus audioCallback (void *inRefCon, /* Only do anything if audio is enabled and not 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; } @@ -121,7 +121,7 @@ static OSStatus audioCallback (void *inRefCon, while (remaining > 0) { if (bufferOffset >= bufferSize) { /* Generate the data */ - memset(buffer, this->spec.silence, bufferSize); + SDL_memset(buffer, this->spec.silence, bufferSize); SDL_mutexP(this->mixer_lock); (*this->spec.callback)(this->spec.userdata, buffer, bufferSize); @@ -132,7 +132,7 @@ static OSStatus audioCallback (void *inRefCon, len = bufferSize - bufferOffset; if (len > remaining) len = remaining; - memcpy(ptr, buffer + bufferOffset, len); + SDL_memcpy(ptr, buffer + bufferOffset, len); ptr += len; remaining -= len; bufferOffset += len; @@ -189,7 +189,7 @@ void Core_CloseAudio(_THIS) return; } - free(buffer); + SDL_free(buffer); } #define CHECK_RESULT(msg) \ @@ -269,7 +269,7 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec) /* Allocate a sample buffer */ bufferOffset = bufferSize = this->spec.size; - buffer = malloc(bufferSize); + buffer = SDL_malloc(bufferSize); assert(buffer); /* Finally, start processing of the audio unit */ diff --git a/src/audio/macrom/SDL_romaudio.c b/src/audio/macrom/SDL_romaudio.c index bf924e67f..cf4912bec 100644 --- a/src/audio/macrom/SDL_romaudio.c +++ b/src/audio/macrom/SDL_romaudio.c @@ -66,8 +66,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -75,20 +75,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ 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 ) { /* 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 { 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 */ - channel = (SndChannelPtr)malloc(sizeof(*channel)); + channel = (SndChannelPtr)SDL_malloc(sizeof(*channel)); if ( channel == NULL ) { SDL_OutOfMemory(); return(-1); @@ -281,7 +281,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) { channel->qLength = 128; if ( SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr ) { SDL_SetError("Unable to create audio channel"); - free(channel); + SDL_free(channel); channel = NULL; return(-1); } @@ -311,7 +311,7 @@ static void Mac_CloseAudio(_THIS) { for ( i=0; i<2; ++i ) { if ( buffer[i] ) { - free(buffer[i]); + SDL_free(buffer[i]); buffer[i] = NULL; } } @@ -355,7 +355,7 @@ void sndDoubleBackProc (SndChannelPtr chan, SndDoubleBufferPtr newbuf) /* Uh oh... probably crashes here */; } #endif - memcpy(newbuf->dbSoundData, audio->convert.buf, + SDL_memcpy(newbuf->dbSoundData, audio->convert.buf, audio->convert.len_cvt); } else { audio->spec.callback(audio->spec.userdata, @@ -400,7 +400,7 @@ static void Mac_CloseAudio(_THIS) } for ( i=0; i<2; ++i ) { if ( audio_buf[i] ) { - free(audio_buf[i]); + SDL_free(audio_buf[i]); audio_buf[i] = NULL; } } @@ -435,7 +435,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) SDL_CalculateAudioSpec(spec); /* initialize the double-back header */ - memset(&audio_dbh, 0, sizeof(audio_dbh)); + SDL_memset(&audio_dbh, 0, sizeof(audio_dbh)); doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc); 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 */ - channel = (SndChannelPtr)malloc(sizeof(*channel)); + channel = (SndChannelPtr)SDL_malloc(sizeof(*channel)); if ( channel == NULL ) { SDL_OutOfMemory(); return(-1); @@ -481,7 +481,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) channel->qLength = 128; if ( SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr ) { SDL_SetError("Unable to create audio channel"); - free(channel); + SDL_free(channel); channel = NULL; return(-1); } diff --git a/src/audio/mint/SDL_mintaudio.c b/src/audio/mint/SDL_mintaudio.c index e77fb0a7a..76cae3573 100644 --- a/src/audio/mint/SDL_mintaudio.c +++ b/src/audio/mint/SDL_mintaudio.c @@ -63,7 +63,7 @@ void SDL_MintAudio_Callback(void) SDL_AudioDevice *audio = SDL_MintAudio_device; 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) return; @@ -76,11 +76,11 @@ void SDL_MintAudio_Callback(void) } else { 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, (Uint8 *)audio->convert.buf,audio->convert.len); SDL_ConvertAudio(&audio->convert); - memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); + SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); } else { 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 */ if (MINTAUDIO_freqcount>0) { 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)); } } diff --git a/src/audio/mint/SDL_mintaudio_dma8.c b/src/audio/mint/SDL_mintaudio_dma8.c index 16e114073..b7036d6a9 100644 --- a/src/audio/mint/SDL_mintaudio_dma8.c +++ b/src/audio/mint/SDL_mintaudio_dma8.c @@ -81,10 +81,10 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); 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 */ - 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")); return 0; } @@ -121,8 +121,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -130,20 +130,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ 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_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_mutex = 0; diff --git a/src/audio/mint/SDL_mintaudio_gsxb.c b/src/audio/mint/SDL_mintaudio_gsxb.c index 27293171d..8fbfcb70a 100644 --- a/src/audio/mint/SDL_mintaudio_gsxb.c +++ b/src/audio/mint/SDL_mintaudio_gsxb.c @@ -85,10 +85,10 @@ static void Mint_GsxbNullInterrupt(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 */ - 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")); return(0); } @@ -127,8 +127,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -136,20 +136,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ 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_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_mutex = 0; diff --git a/src/audio/mint/SDL_mintaudio_mcsn.c b/src/audio/mint/SDL_mintaudio_mcsn.c index 4b7d61d71..f8e790c09 100644 --- a/src/audio/mint/SDL_mintaudio_mcsn.c +++ b/src/audio/mint/SDL_mintaudio_mcsn.c @@ -84,7 +84,7 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); static int Audio_Available(void) { 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); @@ -94,7 +94,7 @@ static int Audio_Available(void) } /* 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")); return(0); } @@ -141,8 +141,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -150,20 +150,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ 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_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_mutex = 0; diff --git a/src/audio/mint/SDL_mintaudio_stfa.c b/src/audio/mint/SDL_mintaudio_stfa.c index 19b2e90dc..fcb6e94c8 100644 --- a/src/audio/mint/SDL_mintaudio_stfa.c +++ b/src/audio/mint/SDL_mintaudio_stfa.c @@ -89,10 +89,10 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); 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 */ - 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")); return(0); } @@ -121,8 +121,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -130,20 +130,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ 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_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_mutex = 0; diff --git a/src/audio/mint/SDL_mintaudio_xbios.c b/src/audio/mint/SDL_mintaudio_xbios.c index 47e8a7941..bbd8565e1 100644 --- a/src/audio/mint/SDL_mintaudio_xbios.c +++ b/src/audio/mint/SDL_mintaudio_xbios.c @@ -84,7 +84,7 @@ static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec); static int Audio_Available(void) { 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); @@ -94,7 +94,7 @@ static int Audio_Available(void) } /* 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")); return(0); } @@ -124,8 +124,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -133,20 +133,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Mint_OpenAudio; @@ -285,7 +285,7 @@ static void Mint_CheckExternalClock(_THIS) DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n")); return; } - memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE); + SDL_memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE); Buffoper(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_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_mutex = 0; diff --git a/src/audio/mme/SDL_mmeaudio.c b/src/audio/mme/SDL_mmeaudio.c index 9b79254ae..0c60d2155 100644 --- a/src/audio/mme/SDL_mmeaudio.c +++ b/src/audio/mme/SDL_mmeaudio.c @@ -43,10 +43,10 @@ static void Audio_DeleteDevice(SDL_AudioDevice *device) { if ( device ) { if ( device->hidden ) { - free(device->hidden); + SDL_free(device->hidden); device->hidden = NULL; } - free(device); + SDL_free(device); device = NULL; } } @@ -56,19 +56,19 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = malloc(sizeof(SDL_AudioDevice)); + this = SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); - this->hidden = malloc((sizeof *this->hidden)); + SDL_memset(this, 0, (sizeof *this)); + this->hidden = SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = MME_OpenAudio; this->WaitAudio = MME_WaitAudio; @@ -92,7 +92,7 @@ static void SetMMerror(char *function, MMRESULT code) char errbuf[MAXERRORLENGTH]; sprintf(errbuf, "%s: ", function); - len = strlen(errbuf); + len = SDL_strlen(errbuf); waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len); SDL_SetError("%s",errbuf); } diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index 4abdbb196..8a1545f4e 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -66,8 +66,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -75,20 +75,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = NAS_OpenAudio; @@ -293,7 +293,7 @@ static int NAS_OpenAudio(_THIS, SDL_AudioSpec *spec) if ( this->hidden->mixbuf == NULL ) { 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) */ this->hidden->parent = getpid(); diff --git a/src/audio/nto/SDL_nto_audio.c b/src/audio/nto/SDL_nto_audio.c index 07595b6c2..2e9380560 100644 --- a/src/audio/nto/SDL_nto_audio.c +++ b/src/audio/nto/SDL_nto_audio.c @@ -94,7 +94,7 @@ static int NTO_CheckBuggyCards(_THIS, unsigned long checkfor) for (it=0; itchannel = SND_PCM_CHANNEL_PLAYBACK; cpars->mode = SND_PCM_MODE_BLOCK; @@ -172,11 +172,11 @@ static void NTO_DeleteAudioDevice(SDL_AudioDevice *device) { if ((device)&&(device->hidden)) { - free(device->hidden); + SDL_free(device->hidden); } if (device) { - free(device); + SDL_free(device); } } @@ -185,22 +185,22 @@ static SDL_AudioDevice* NTO_CreateAudioDevice(int devindex) SDL_AudioDevice *this; /* 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) { - memset(this, 0, sizeof(SDL_AudioDevice)); - this->hidden = (struct SDL_PrivateAudioData *)malloc(sizeof(struct SDL_PrivateAudioData)); + SDL_memset(this, 0, sizeof(SDL_AudioDevice)); + this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(struct SDL_PrivateAudioData)); } if ((this == NULL) || (this->hidden == NULL)) { SDL_OutOfMemory(); if (this) { - free(this); + SDL_free(this); } return (0); } - memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData)); + SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData)); audio_handle = NULL; /* Set the function pointers */ @@ -280,7 +280,7 @@ static void NTO_PlayAudio(_THIS) { if ((errno == EINVAL) || (errno == EIO)) { - memset(&cstatus, 0, sizeof(cstatus)); + SDL_memset(&cstatus, 0, sizeof(cstatus)); cstatus.channel = SND_PCM_CHANNEL_PLAYBACK; 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 */ - memset(&csetup, 0x00, sizeof(csetup)); + SDL_memset(&csetup, 0x00, sizeof(csetup)); csetup.channel = SND_PCM_CHANNEL_PLAYBACK; 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"); return (-1); } - memset(pcm_buf, spec->silence, pcm_len); + SDL_memset(pcm_buf, spec->silence, pcm_len); /* get the file descriptor */ if ((audio_fd = snd_pcm_file_descriptor(audio_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0) diff --git a/src/audio/openbsd/SDL_openbsdaudio.c b/src/audio/openbsd/SDL_openbsdaudio.c index 03371d99b..a3441a01c 100644 --- a/src/audio/openbsd/SDL_openbsdaudio.c +++ b/src/audio/openbsd/SDL_openbsdaudio.c @@ -95,8 +95,8 @@ Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice @@ -105,18 +105,18 @@ static SDL_AudioDevice SDL_AudioDevice *this; /* 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) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = - (struct SDL_PrivateAudioData*)malloc((sizeof *this->hidden)); + (struct SDL_PrivateAudioData*)SDL_malloc((sizeof *this->hidden)); } if((this == NULL) || (this->hidden == NULL)) { SDL_OutOfMemory(); - if(this) free(this); + if(this) SDL_free(this); return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -397,7 +397,7 @@ OBSD_OpenAudio(_THIS, SDL_AudioSpec *spec) if(mixbuf == NULL) { 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) */ parent = getpid(); diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index db5d600a1..d3c572a33 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -82,8 +82,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -91,20 +91,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -457,7 +457,7 @@ static int Paud_OpenAudio(_THIS, SDL_AudioSpec *spec) if ( mixbuf == NULL ) { 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. @@ -498,7 +498,7 @@ static int Paud_OpenAudio(_THIS, SDL_AudioSpec *spec) /* Check to see if we need to use select() workaround */ { char *workaround; - workaround = getenv("SDL_DSP_NOSELECT"); + workaround = SDL_getenv("SDL_DSP_NOSELECT"); if ( workaround ) { frame_ticks = (float)(spec->samples*1000)/spec->freq; next_frame = SDL_GetTicks()+frame_ticks; diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 3f5c5996e..46540312c 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -75,8 +75,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -84,20 +84,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -236,7 +236,7 @@ void DSP_CloseAudio(_THIS) mixbuf = NULL; } if ( ulaw_buf != NULL ) { - free(ulaw_buf); + SDL_free(ulaw_buf); ulaw_buf = NULL; } close(audio_fd); @@ -349,7 +349,7 @@ int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) spec->freq = desired_freq; fragsize = (spec->samples*1000)/(spec->freq/8); frequency = 8; - ulaw_buf = (Uint8 *)malloc(fragsize); + ulaw_buf = (Uint8 *)SDL_malloc(fragsize); if ( ulaw_buf == NULL ) { SDL_OutOfMemory(); return(-1); @@ -375,7 +375,7 @@ int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) SDL_OutOfMemory(); return(-1); } - memset(mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* We're ready to rock and roll. :-) */ return(0); diff --git a/src/audio/ums/SDL_umsaudio.c b/src/audio/ums/SDL_umsaudio.c index 7920d4e3e..60cd8bebc 100644 --- a/src/audio/ums/SDL_umsaudio.c +++ b/src/audio/ums/SDL_umsaudio.c @@ -84,11 +84,11 @@ static int Audio_Available(void) static void Audio_DeleteDevice(_THIS) { - if(this->hidden->playbuf._buffer) free(this->hidden->playbuf._buffer); - if(this->hidden->fillbuf._buffer) free(this->hidden->fillbuf._buffer); + if(this->hidden->playbuf._buffer) SDL_free(this->hidden->playbuf._buffer); + if(this->hidden->fillbuf._buffer) SDL_free(this->hidden->fillbuf._buffer); _somFree( this->hidden->umsdev ); - free(this->hidden); - free(this); + SDL_free(this->hidden); + SDL_free(this); } 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 * storage for this SDL-using library. */ - this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *)malloc((sizeof *this->hidden)); + SDL_memset(this, 0, (sizeof *this)); + this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); #ifdef DEBUG_AUDIO fprintf(stderr, "Creating UMS Audio device\n"); #endif @@ -204,9 +204,9 @@ static void UMS_PlayAudio(_THIS) while(samplesToWrite>0); SDL_LockAudio(); - memcpy( &swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer) ); - memcpy( &this->hidden->playbuf, &this->hidden->fillbuf, sizeof(UMSAudioTypes_Buffer) ); - memcpy( &this->hidden->fillbuf, &swpbuf, sizeof(UMSAudioTypes_Buffer) ); + SDL_memcpy( &swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer) ); + SDL_memcpy( &this->hidden->playbuf, &this->hidden->fillbuf, sizeof(UMSAudioTypes_Buffer) ); + SDL_memcpy( &this->hidden->fillbuf, &swpbuf, sizeof(UMSAudioTypes_Buffer) ); SDL_UnlockAudio(); #ifdef DEBUG_AUDIO @@ -330,10 +330,10 @@ static int UMS_OpenAudio(_THIS, SDL_AudioSpec *spec) this->hidden->playbuf._length = 0; 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._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 = UADSetDMABufferSize(this, frag_spec, &outBufSize ); diff --git a/src/audio/windib/SDL_dibaudio.c b/src/audio/windib/SDL_dibaudio.c index ca4a1793c..eb63feff1 100644 --- a/src/audio/windib/SDL_dibaudio.c +++ b/src/audio/windib/SDL_dibaudio.c @@ -55,8 +55,8 @@ static int Audio_Available(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice *Audio_CreateDevice(int devindex) @@ -64,20 +64,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) SDL_AudioDevice *this; /* 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 ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DIB_OpenAudio; @@ -125,8 +125,8 @@ static void SetMMerror(char *function, MMRESULT code) wchar_t werrbuf[MAXERRORLENGTH]; #endif - snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); - len = strlen(errbuf); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); + len = SDL_strlen(errbuf); #ifdef _WIN32_WCE /* UNICODE version */ @@ -213,7 +213,7 @@ void DIB_CloseAudio(_THIS) } /* Free raw mixing buffer */ if ( mixbuf != NULL ) { - free(mixbuf); + SDL_free(mixbuf); mixbuf = NULL; } } @@ -232,7 +232,7 @@ int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec) mixbuf = NULL; /* Set basic WAVE format parameters */ - memset(&waveformat, 0, sizeof(waveformat)); + SDL_memset(&waveformat, 0, sizeof(waveformat)); waveformat.wFormatTag = WAVE_FORMAT_PCM; /* Determine the audio parameters from the AudioSpec */ @@ -299,13 +299,13 @@ int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec) } /* Create the sound buffers */ - mixbuf = (Uint8 *)malloc(NUM_BUFFERS*spec->size); + mixbuf = (Uint8 *)SDL_malloc(NUM_BUFFERS*spec->size); if ( mixbuf == NULL ) { SDL_SetError("Out of memory"); return(-1); } 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].dwBufferLength = spec->size; wavebuf[i].dwFlags = WHDR_DONE; diff --git a/src/audio/windx5/SDL_dx5audio.c b/src/audio/windx5/SDL_dx5audio.c index 02beb2891..bc9f555fd 100644 --- a/src/audio/windx5/SDL_dx5audio.c +++ b/src/audio/windx5/SDL_dx5audio.c @@ -133,8 +133,8 @@ static int DX5_Load(void) static void Audio_DeleteDevice(SDL_AudioDevice *device) { DX5_Unload(); - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } 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 */ - this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DX5_OpenAudio; @@ -223,13 +223,13 @@ static void SetDSerror(const char *function, int code) error = "Function not supported"; break; default: - snprintf(errbuf, SDL_arraysize(errbuf), + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: Unknown DirectSound error: 0x%x", function, code); break; } 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); return; @@ -386,7 +386,7 @@ static void DX5_WaitDone(_THIS) /* Wait for the playing chunk to finish */ stream = this->GetAudioBuf(this); if ( stream != NULL ) { - memset(stream, silence, mixlen); + SDL_memset(stream, silence, mixlen); this->PlayAudio(this); } this->WaitAudio(this); @@ -435,7 +435,7 @@ static int CreatePrimary(LPDIRECTSOUND sndObj, HWND focus, } /* Try to create the primary buffer */ - memset(&format, 0, sizeof(format)); + SDL_memset(&format, 0, sizeof(format)); format.dwSize = sizeof(format); format.dwFlags=(DSBCAPS_PRIMARYBUFFER|DSBCAPS_GETCURRENTPOSITION2); format.dwFlags |= DSBCAPS_STICKYFOCUS; @@ -451,7 +451,7 @@ static int CreatePrimary(LPDIRECTSOUND sndObj, HWND focus, } /* Check the size of the fragment buffer */ - memset(&caps, 0, sizeof(caps)); + SDL_memset(&caps, 0, sizeof(caps)); caps.dwSize = sizeof(caps); result = IDirectSoundBuffer_GetCaps(*sndbuf, &caps); if ( result != DS_OK ) { @@ -516,7 +516,7 @@ static int CreateSecondary(LPDIRECTSOUND sndObj, HWND focus, } /* Try to create the secondary buffer */ - memset(&format, 0, sizeof(format)); + SDL_memset(&format, 0, sizeof(format)); format.dwSize = sizeof(format); format.dwFlags = DSBCAPS_GETCURRENTPOSITION2; #ifdef USE_POSITION_NOTIFY @@ -550,9 +550,9 @@ static int CreateSecondary(LPDIRECTSOUND sndObj, HWND focus, DSBLOCK_ENTIREBUFFER); if ( result == DS_OK ) { if ( wavefmt->wBitsPerSample == 8 ) { - memset(pvAudioPtr1, 0x80, dwAudioBytes1); + SDL_memset(pvAudioPtr1, 0x80, dwAudioBytes1); } else { - memset(pvAudioPtr1, 0x00, dwAudioBytes1); + SDL_memset(pvAudioPtr1, 0x00, dwAudioBytes1); } IDirectSoundBuffer_Unlock(*sndbuf, (LPVOID)pvAudioPtr1, dwAudioBytes1, @@ -584,7 +584,7 @@ static int CreateAudioEvent(_THIS) } /* Allocate the notify structures */ - notify_positions = (DSBPOSITIONNOTIFY *)malloc(NUM_BUFFERS* + notify_positions = (DSBPOSITIONNOTIFY *)SDL_malloc(NUM_BUFFERS* sizeof(*notify_positions)); if ( notify_positions == NULL ) { goto done; @@ -620,7 +620,7 @@ static int DX5_OpenAudio(_THIS, SDL_AudioSpec *spec) WAVEFORMATEX waveformat; /* Set basic WAVE format parameters */ - memset(&waveformat, 0, sizeof(waveformat)); + SDL_memset(&waveformat, 0, sizeof(waveformat)); waveformat.wFormatTag = WAVE_FORMAT_PCM; /* Determine the audio parameters from the AudioSpec */ diff --git a/src/cdrom/SDL_cdrom.c b/src/cdrom/SDL_cdrom.c index 9e40bd49e..8411251bf 100644 --- a/src/cdrom/SDL_cdrom.c +++ b/src/cdrom/SDL_cdrom.c @@ -117,15 +117,15 @@ SDL_CD *SDL_CDOpen(int drive) SDL_SetError("Invalid CD-ROM drive index"); return(NULL); } - cdrom = (SDL_CD *)malloc(sizeof(*cdrom)); + cdrom = (SDL_CD *)SDL_malloc(sizeof(*cdrom)); if ( cdrom == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(cdrom, 0, sizeof(*cdrom)); + SDL_memset(cdrom, 0, sizeof(*cdrom)); cdrom->id = SDL_CDcaps.Open(drive); if ( cdrom->id < 0 ) { - free(cdrom); + SDL_free(cdrom); return(NULL); } default_cdrom = cdrom; @@ -332,7 +332,7 @@ void SDL_CDClose(SDL_CD *cdrom) return; } SDL_CDcaps.Close(cdrom); - free(cdrom); + SDL_free(cdrom); default_cdrom = NULL; } diff --git a/src/cdrom/SDL_syscdrom.h b/src/cdrom/SDL_syscdrom.h index 678e391ff..5a3b0ebc9 100644 --- a/src/cdrom/SDL_syscdrom.h +++ b/src/cdrom/SDL_syscdrom.h @@ -2,7 +2,7 @@ SDL - Simple DirectMedia Layer 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 License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/src/cdrom/aix/SDL_syscdrom.c b/src/cdrom/aix/SDL_syscdrom.c index ee8f0437b..b072d2fd4 100644 --- a/src/cdrom/aix/SDL_syscdrom.c +++ b/src/cdrom/aix/SDL_syscdrom.c @@ -128,12 +128,12 @@ static void AddDrive(char *drive, struct stat *stbuf) /* Add this drive to our list */ 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 ) { SDL_OutOfMemory(); return; } - strcpy(SDL_cdlist[i], drive); + SDL_strcpy(SDL_cdlist[i], drive); SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM @@ -149,7 +149,7 @@ static void CheckMounts() struct vmount* ptr; int ret; - buffer = (char*)malloc(10); + buffer = (char*)SDL_malloc(10); bufsz = 10; if ( buffer==NULL ) { @@ -167,8 +167,8 @@ static void CheckMounts() bufsz = *(int*)buffer; /* Required size is in first word. */ /* (whatever a word is in AIX 4.3.3) */ /* int seems to be OK in 32bit mode. */ - free(buffer); - buffer = (char*)malloc(bufsz); + SDL_free(buffer); + buffer = (char*)SDL_malloc(bufsz); if ( buffer==NULL ) { fprintf(stderr, @@ -237,9 +237,9 @@ static int CheckNonmounts() { ret = getfsent_r ( &entry, &fsFile, &passNo ); if ( ret == 0 ) { - char* l = strrchr(entry.fs_spec,'/'); + char* l = SDL_strrchr(entry.fs_spec,'/'); if ( l != NULL ) { - if ( !strncmp("cd",++l,2) ) { + if ( !SDL_strncmp("cd",++l,2) ) { #ifdef DEBUG_CDROM fprintf(stderr, "Found unmounted CD ROM drive with device name %s\n", @@ -266,9 +266,9 @@ static int CheckNonmounts() { entry = getfsent(); if ( entry != NULL ) { - char* l = strrchr(entry->fs_spec,'/'); + char* l = SDL_strrchr(entry->fs_spec,'/'); if ( l != NULL ) { - if ( !strncmp("cd",++l,2) ) { + if ( !SDL_strncmp("cd",++l,2) ) { #ifdef DEBUG_CDROM fprintf(stderr,"Found unmounted CD ROM drive with device name %s", entry->fs_spec); #endif @@ -303,15 +303,15 @@ int SDL_SYS_CDInit(void) SDL_CDcaps.Close = SDL_SYS_CDClose; /* 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 ) { char *cdpath, *delim; - cdpath = malloc(strlen(SDLcdrom)+1); + cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); if ( cdpath != NULL ) { - strcpy(cdpath, SDLcdrom); + SDL_strcpy(cdpath, SDLcdrom); SDLcdrom = cdpath; do { - delim = strchr(SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } @@ -327,7 +327,7 @@ int SDL_SYS_CDInit(void) SDLcdrom = NULL; } } while ( SDLcdrom ); - free(cdpath); + SDL_free(cdpath); } /* 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 * open only the /dev/rcd? versions of those devices for Audio CD. */ - cdromname = (char*)malloc( strlen(SDL_cdlist[drive]+2) ); - strcpy(cdromname,SDL_cdlist[drive]); - lastsl = strrchr(cdromname,'/'); + cdromname = (char*)SDL_malloc( SDL_strlen(SDL_cdlist[drive]+2) ); + SDL_strcpy(cdromname,SDL_cdlist[drive]); + lastsl = SDL_strrchr(cdromname,'/'); if (lastsl) { *lastsl = 0; strcat(cdromname,"/r"); - lastsl = strrchr(SDL_cdlist[drive],'/'); + lastsl = SDL_strrchr(SDL_cdlist[drive],'/'); if (lastsl) { lastsl++; strcat(cdromname,lastsl); @@ -459,7 +459,7 @@ static int SDL_SYS_CDOpen(int drive) #endif } } - free(cdromname); + SDL_free(cdromname); return fd; } @@ -650,7 +650,7 @@ void SDL_SYS_CDQuit(void) if ( SDL_numcds > 0 ) { for ( i=0; i= 0) @@ -233,7 +233,7 @@ int try_dir(const char *directory) int devfd; device_geometry g; - if(strcmp(e.name, "raw") != 0) + if(SDL_strcmp(e.name, "raw") != 0) continue; /* ignore partitions */ devfd = open(name, O_RDONLY); @@ -401,7 +401,7 @@ void SDL_SYS_CDQuit(void) if ( SDL_numcds > 0 ) { for ( i=0; ist_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM @@ -267,15 +267,15 @@ int SDL_SYS_CDInit(void) SDL_CDcaps.Close = SDL_SYS_CDClose; /* 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 ) { char *cdpath, *delim; - cdpath = malloc(strlen(SDLcdrom)+1); + cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); if ( cdpath != NULL ) { - strcpy(cdpath, SDLcdrom); + SDL_strcpy(cdpath, SDLcdrom); SDLcdrom = cdpath; do { - delim = strchr(SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } @@ -288,7 +288,7 @@ int SDL_SYS_CDInit(void) SDLcdrom = NULL; } } while ( SDLcdrom ); - free(cdpath); + SDL_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -304,7 +304,7 @@ int SDL_SYS_CDInit(void) exists = 1; for ( j=checklist[i][1]; exists; ++j ) { sprintf(drive, "/dev/%sc", &checklist[i][3]); - insert = strchr(drive, '?'); + insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; } @@ -360,7 +360,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) ntracks = last_track - first_track + 1; cdrom->numtracks = ntracks; toc_size = 4 + (ntracks + 1) * 8; - toc = (u_char *)malloc(toc_size); + toc = (u_char *)SDL_malloc(toc_size); if (toc == NULL) return(-1); bzero(cdb, sizeof (cdb)); @@ -373,7 +373,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) &sus); if (sts < 0) { - free(toc); + SDL_free(toc); 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].offset; } - free(toc); + SDL_free(toc); return(0); } @@ -535,7 +535,7 @@ void SDL_SYS_CDQuit(void) if ( SDL_numcds > 0 ) { for ( i=0; ist_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM @@ -153,15 +153,15 @@ int SDL_SYS_CDInit(void) SDL_CDcaps.Close = SDL_SYS_CDClose; /* 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 ) { char *cdpath, *delim; - cdpath = malloc(strlen(SDLcdrom)+1); + cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); if ( cdpath != NULL ) { - strcpy(cdpath, SDLcdrom); + SDL_strcpy(cdpath, SDLcdrom); SDLcdrom = cdpath; do { - delim = strchr(SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } @@ -174,7 +174,7 @@ int SDL_SYS_CDInit(void) SDLcdrom = NULL; } } while ( SDLcdrom ); - free(cdpath); + SDL_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -190,7 +190,7 @@ int SDL_SYS_CDInit(void) exists = 1; for ( j=checklist[i][1]; exists; ++j ) { sprintf(drive, "/dev/%sc", &checklist[i][3]); - insert = strchr(drive, '?'); + insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; } @@ -398,7 +398,7 @@ void SDL_SYS_CDQuit(void) if ( SDL_numcds > 0 ) { for ( i=0; ist_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM @@ -198,45 +198,45 @@ static void CheckMounts(const char *mtab) char *mnt_dev; 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) 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) { - free(mnt_type); + SDL_free(mnt_type); continue; } - strcpy(mnt_type, mntent->mnt_type); - strcpy(mnt_dev, mntent->mnt_fsname); + SDL_strcpy(mnt_type, mntent->mnt_type); + SDL_strcpy(mnt_dev, mntent->mnt_fsname); /* Handle "supermount" filesystem mounts */ - if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) { - tmp = strstr(mntent->mnt_opts, "fs="); + if ( SDL_strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) { + tmp = SDL_strstr(mntent->mnt_opts, "fs="); if ( tmp ) { - free(mnt_type); - mnt_type = strdup(tmp + strlen("fs=")); + SDL_free(mnt_type); + mnt_type = strdup(tmp + SDL_strlen("fs=")); if ( mnt_type ) { - tmp = strchr(mnt_type, ','); + tmp = SDL_strchr(mnt_type, ','); if ( tmp ) { *tmp = '\0'; } } } - tmp = strstr(mntent->mnt_opts, "dev="); + tmp = SDL_strstr(mntent->mnt_opts, "dev="); if ( tmp ) { - free(mnt_dev); - mnt_dev = strdup(tmp + strlen("dev=")); + SDL_free(mnt_dev); + mnt_dev = strdup(tmp + SDL_strlen("dev=")); if ( mnt_dev ) { - tmp = strchr(mnt_dev, ','); + tmp = SDL_strchr(mnt_dev, ','); if ( tmp ) { *tmp = '\0'; } } } } - if ( strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) { + if ( SDL_strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) { #ifdef DEBUG_CDROM fprintf(stderr, "Checking mount path from %s: %s mounted on %s of %s\n", mtab, mnt_dev, mntent->mnt_dir, mnt_type); @@ -245,8 +245,8 @@ static void CheckMounts(const char *mtab) AddDrive(mnt_dev, &stbuf); } } - free(mnt_dev); - free(mnt_type); + SDL_free(mnt_dev); + SDL_free(mnt_type); } endmntent(mntfp); } @@ -277,15 +277,15 @@ int SDL_SYS_CDInit(void) SDL_CDcaps.Close = SDL_SYS_CDClose; /* 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 ) { char *cdpath, *delim; - cdpath = malloc(strlen(SDLcdrom)+1); + cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); if ( cdpath != NULL ) { - strcpy(cdpath, SDLcdrom); + SDL_strcpy(cdpath, SDLcdrom); SDLcdrom = cdpath; do { - delim = strchr(SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } @@ -301,7 +301,7 @@ int SDL_SYS_CDInit(void) SDLcdrom = NULL; } } while ( SDLcdrom ); - free(cdpath); + SDL_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -337,7 +337,7 @@ int SDL_SYS_CDInit(void) exists = 1; for ( j=checklist[i][1]; exists; ++j ) { sprintf(drive, "/dev/%s", &checklist[i][3]); - insert = strchr(drive, '?'); + insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; } @@ -551,7 +551,7 @@ void SDL_SYS_CDQuit(void) if ( SDL_numcds > 0 ) { for ( i=0; iid].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 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 */ - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kReadTOC; @@ -197,8 +197,8 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) SDL_SYS_BCDToShort(cdpb.csParam.bytes[2])); /* Get an array of track locations by examining the TOC */ - memset(tracks, 0, sizeof(tracks)); - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(tracks, 0, sizeof(tracks)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kReadTOC; @@ -255,7 +255,7 @@ static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) if ( ! get_drivenum(cdrom->id) ) { return(CD_TRAYEMPTY); } - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kReadTOC; @@ -276,7 +276,7 @@ static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) if (1 || SDL_cdlist[cdrom->id].hasAudio) { /* Get the current playback status */ - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStatus; @@ -335,7 +335,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) } /* Specify the AudioCD playback mode */ - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kSetPlayMode; @@ -346,7 +346,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) #if 1 /* 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.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 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 */ - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; @@ -373,7 +373,7 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) #else /* Specify the end of audio playback */ 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.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; 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 */ 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.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; @@ -411,7 +411,7 @@ static int SDL_SYS_CDPause(SDL_CD *cdrom) { CDCntrlParam cdpb; - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPause; @@ -429,7 +429,7 @@ static int SDL_SYS_CDResume(SDL_CD *cdrom) { CDCntrlParam cdpb; - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPause; @@ -447,7 +447,7 @@ static int SDL_SYS_CDStop(SDL_CD *cdrom) { CDCntrlParam cdpb; - memset(&cdpb, 0, sizeof(cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; @@ -481,7 +481,7 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom) } /* Does drive contain mounted volume? If not, skip */ - memset(&hpb, 0, sizeof(hpb)); + SDL_memset(&hpb, 0, sizeof(hpb)); hpb.volumeParam.ioVRefNum = driveElem->dQDrive; if ( PBHGetVInfoSync(&hpb) != noErr ) { continue; @@ -495,7 +495,7 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom) /* If no disk is present, just eject the tray */ if (! disk) { - memset(&cpb, 0, sizeof(cpb)); + SDL_memset(&cpb, 0, sizeof(cpb)); cpb.cntrlParam.ioVRefNum = 0; /* No Drive */ cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cpb.cntrlParam.csCode = kEjectTheDisc; @@ -516,6 +516,6 @@ static void SDL_SYS_CDClose(SDL_CD *cdrom) void SDL_SYS_CDQuit(void) { while(SDL_numcds--) - memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0])); + SDL_memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0])); } diff --git a/src/cdrom/macosx/AudioFilePlayer.c b/src/cdrom/macosx/AudioFilePlayer.c index 8e3b895a1..4eb52e399 100644 --- a/src/cdrom/macosx/AudioFilePlayer.c +++ b/src/cdrom/macosx/AudioFilePlayer.c @@ -64,7 +64,7 @@ static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inD if (afp->mConnected) return 0 ; - memcpy(&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit)); + SDL_memcpy(&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit)); OSStatus result = noErr; @@ -155,7 +155,7 @@ void delete_AudioFilePlayer(AudioFilePlayer *afp) FSClose (afp->mForkRefNum); afp->mForkRefNum = 0; } - free(afp); + SDL_free(afp); } } @@ -304,10 +304,10 @@ AudioFilePlayer *new_AudioFilePlayer (const FSRef *inFileRef) { SInt64 fileDataSize = 0; - AudioFilePlayer *afp = (AudioFilePlayer *) malloc(sizeof (AudioFilePlayer)); + AudioFilePlayer *afp = (AudioFilePlayer *) SDL_malloc(sizeof (AudioFilePlayer)); if (afp == NULL) return NULL; - memset(afp, '\0', sizeof (*afp)); + SDL_memset(afp, '\0', sizeof (*afp)); #define SET_AUDIOFILEPLAYER_METHOD(m) afp->m = AudioFilePlayer_##m SET_AUDIOFILEPLAYER_METHOD(SetDestination); @@ -326,7 +326,7 @@ AudioFilePlayer *new_AudioFilePlayer (const FSRef *inFileRef) if (!afp->OpenFile (afp, inFileRef, &fileDataSize)) { - free(afp); + SDL_free(afp); return NULL; } diff --git a/src/cdrom/macosx/AudioFileReaderThread.c b/src/cdrom/macosx/AudioFileReaderThread.c index 5e7d98a6e..ef56b5ed0 100644 --- a/src/cdrom/macosx/AudioFileReaderThread.c +++ b/src/cdrom/macosx/AudioFileReaderThread.c @@ -86,7 +86,7 @@ static int FileReaderThread_TryNextRead (FileReaderThread *frt, AudioFileManager FileData *i = frt->mFileData; FileData *prev = NULL; - FileData *newfd = (FileData *) malloc(sizeof (FileData)); + FileData *newfd = (FileData *) SDL_malloc(sizeof (FileData)); newfd->obj = inItem; newfd->next = NULL; @@ -136,7 +136,7 @@ static void FileReaderThread_RemoveReader (FileReaderThread *frt, AudioFileMa frt->mFileData = next; else prev->next = next; - free(i); + SDL_free(i); } i = next; } @@ -279,7 +279,7 @@ static void FileReaderThread_ReadNextChunk (FileReaderThread *frt) { FileData *next = frt->mFileData->next; theItem = frt->mFileData->obj; - free(frt->mFileData); + SDL_free(frt->mFileData); frt->mFileData = next; } @@ -330,21 +330,21 @@ void delete_FileReaderThread(FileReaderThread *frt) if (frt != NULL) { delete_SDLOSXCAGuard(frt->mGuard); - free(frt); + SDL_free(frt); } } FileReaderThread *new_FileReaderThread () { - FileReaderThread *frt = (FileReaderThread *) malloc(sizeof (FileReaderThread)); + FileReaderThread *frt = (FileReaderThread *) SDL_malloc(sizeof (FileReaderThread)); if (frt == NULL) return NULL; - memset(frt, '\0', sizeof (*frt)); + SDL_memset(frt, '\0', sizeof (*frt)); frt->mGuard = new_SDLOSXCAGuard(); if (frt->mGuard == NULL) { - free(frt); + SDL_free(frt); return NULL; } @@ -549,7 +549,7 @@ void delete_AudioFileManager (AudioFileManager *afm) free (afm->mFileBuffer); } - free(afm); + SDL_free(afm); } } @@ -568,10 +568,10 @@ AudioFileManager *new_AudioFileManager(AudioFilePlayer *inParent, return NULL; } - afm = (AudioFileManager *) malloc(sizeof (AudioFileManager)); + afm = (AudioFileManager *) SDL_malloc(sizeof (AudioFileManager)); if (afm == NULL) return NULL; - memset(afm, '\0', sizeof (*afm)); + SDL_memset(afm, '\0', sizeof (*afm)); #define SET_AUDIOFILEMANAGER_METHOD(m) afm->m = AudioFileManager_##m SET_AUDIOFILEMANAGER_METHOD(Disconnect); diff --git a/src/cdrom/macosx/SDLOSXCAGuard.c b/src/cdrom/macosx/SDLOSXCAGuard.c index fff923e1f..7a8105c9a 100644 --- a/src/cdrom/macosx/SDLOSXCAGuard.c +++ b/src/cdrom/macosx/SDLOSXCAGuard.c @@ -147,10 +147,10 @@ static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag) SDLOSXCAGuard *new_SDLOSXCAGuard(void) { - SDLOSXCAGuard *cag = (SDLOSXCAGuard *) malloc(sizeof (SDLOSXCAGuard)); + SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard)); if (cag == NULL) return NULL; - memset(cag, '\0', sizeof (*cag)); + SDL_memset(cag, '\0', sizeof (*cag)); #define SET_SDLOSXCAGUARD_METHOD(m) cag->m = SDLOSXCAGuard_##m SET_SDLOSXCAGUARD_METHOD(Lock); @@ -176,7 +176,7 @@ void delete_SDLOSXCAGuard(SDLOSXCAGuard *cag) { pthread_mutex_destroy(&cag->mMutex); pthread_cond_destroy(&cag->mCondVar); - free(cag); + SDL_free(cag); } } diff --git a/src/cdrom/openbsd/SDL_syscdrom.c b/src/cdrom/openbsd/SDL_syscdrom.c index 0d28d1b78..76c50c84f 100644 --- a/src/cdrom/openbsd/SDL_syscdrom.c +++ b/src/cdrom/openbsd/SDL_syscdrom.c @@ -119,12 +119,12 @@ static void AddDrive(char *drive, struct stat *stbuf) /* Add this drive to our list */ 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 ) { SDL_OutOfMemory(); return; } - strcpy(SDL_cdlist[i], drive); + SDL_strcpy(SDL_cdlist[i], drive); SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM @@ -162,15 +162,15 @@ int SDL_SYS_CDInit(void) SDL_CDcaps.Close = SDL_SYS_CDClose; /* 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 ) { char *cdpath, *delim; - cdpath = malloc(strlen(SDLcdrom)+1); + cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); if ( cdpath != NULL ) { - strcpy(cdpath, SDLcdrom); + SDL_strcpy(cdpath, SDLcdrom); SDLcdrom = cdpath; do { - delim = strchr(SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } @@ -183,7 +183,7 @@ int SDL_SYS_CDInit(void) SDLcdrom = NULL; } } while ( SDLcdrom ); - free(cdpath); + SDL_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -199,7 +199,7 @@ int SDL_SYS_CDInit(void) exists = 1; for ( j=checklist[i][1]; exists; ++j ) { sprintf(drive, "/dev/%s", &checklist[i][3]); - insert = strchr(drive, '?'); + insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; } @@ -407,7 +407,7 @@ void SDL_SYS_CDQuit(void) if ( SDL_numcds > 0 ) { for ( i=0; inumtracks > SDL_MAX_TRACKS ) cdrom->numtracks = SDL_MAX_TRACKS; } /* 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 ) { 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) { SDL_OutOfMemory(); - free(mtr); + SDL_free(mtr); return(CD_ERROR); } /* Fill SDL Tracks Structure */ @@ -193,7 +193,7 @@ for (i=0; inumtracks; i++) 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) { - free(mtr); + SDL_free(mtr); return (CD_ERROR); } if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK; @@ -203,7 +203,7 @@ for (i=0; inumtracks; i++) /* Set Track Offset */ cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr); } -free(mtr); +SDL_free(mtr); return(0); } @@ -386,7 +386,7 @@ if ( SDL_numcds > 0 ) { for ( i=0; ist_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM @@ -177,15 +177,15 @@ int SDL_SYS_CDInit(void) /* 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 ) { char *cdpath, *delim; - cdpath = malloc(strlen(SDLcdrom)+1); + cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); if ( cdpath != NULL ) { - strcpy(cdpath, SDLcdrom); + SDL_strcpy(cdpath, SDLcdrom); SDLcdrom = cdpath; do { - delim = strchr(SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } @@ -198,7 +198,7 @@ int SDL_SYS_CDInit(void) SDLcdrom = NULL; } } while ( SDLcdrom ); - free(cdpath); + SDL_free(cdpath); } /* 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); if (devdir) { - name_len = strlen(checklist[i].name); + name_len = SDL_strlen(checklist[i].name); 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') { sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name); #ifdef DEBUG_CDROM @@ -234,8 +234,8 @@ int SDL_SYS_CDInit(void) } /* - SDLcdrom=malloc(sizeof(char) * 32); - strcpy(SDLcdrom,"/dev/rdisk/cdrom0c"); + SDLcdrom=SDL_malloc(sizeof(char) * 32); + SDL_strcpy(SDLcdrom,"/dev/rdisk/cdrom0c"); SDL_cdlist[0] = SDLcdrom; stat(SDLcdrom, &stbuf); SDL_cdmode[0] = stbuf.st_rdev; @@ -449,7 +449,7 @@ void SDL_SYS_CDQuit(void) if ( SDL_numcds > 0 ) { for ( i=0; ist_rdev; ++SDL_numcds; } @@ -169,18 +169,18 @@ int SDL_SYS_CDInit(void) } /* 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 ) { char *cdpath, *delim; - cdpath = malloc(strlen(SDLcdrom)+1); + cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1); if (cdpath != NULL) { - strcpy(cdpath, SDLcdrom); + SDL_strcpy(cdpath, SDLcdrom); SDLcdrom = cdpath; do { - delim = strchr(SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; @@ -198,7 +198,7 @@ int SDL_SYS_CDInit(void) SDLcdrom = NULL; } } while (SDLcdrom); - free(cdpath); + SDL_free(cdpath); } /* 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 ) { sprintf(drive, "/dev/%s", &checklist[i][3]); - insert = strchr(drive, '?'); + insert = SDL_strchr(drive, '?'); if (insert != NULL) { *insert = j; @@ -346,7 +346,7 @@ static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) /* 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; do { @@ -544,7 +544,7 @@ void SDL_SYS_CDQuit(void) { for (i=0; i 0 ) { for ( i=0; iInitOSKeymap(this); SDL_EnableKeyRepeat(0, 0); @@ -319,7 +319,7 @@ void SDL_ResetKeyboard(void) SDL_keysym keysym; SDLKey key; - memset(&keysym, 0, (sizeof keysym)); + SDL_memset(&keysym, 0, (sizeof keysym)); for ( key=SDLK_FIRST; keysym), diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index bd903e89f..636baf9fb 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -182,7 +182,7 @@ printf("Mouse event didn't change state - dropped!\n"); posted = 0; if ( SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE ) { SDL_Event event; - memset(&event, 0, sizeof(event)); + SDL_memset(&event, 0, sizeof(event)); event.type = SDL_MOUSEMOTION; event.motion.state = buttonstate; event.motion.x = X; @@ -204,7 +204,7 @@ int SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y) int move_mouse; Uint8 buttonstate; - memset(&event, 0, sizeof(event)); + SDL_memset(&event, 0, sizeof(event)); /* Check parameters */ if ( x || y ) { diff --git a/src/events/SDL_sysevents.h b/src/events/SDL_sysevents.h index a6cbc12c6..4cc4deed2 100644 --- a/src/events/SDL_sysevents.h +++ b/src/events/SDL_sysevents.h @@ -2,7 +2,7 @@ SDL - Simple DirectMedia Layer 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 License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index bbbcd6ad6..9f9f73a4e 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -120,7 +120,7 @@ static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum) 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; 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 ) { 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; return(num); } @@ -162,8 +162,8 @@ static int in_sdl = 0; */ static char *unix_to_mac(const char *file) { - int flen = strlen(file); - char *path = malloc(flen + 2); + int flen = SDL_strlen(file); + char *path = SDL_malloc(flen + 2); const char *src = file; char *dst = path; if(*src == '/') { @@ -175,7 +175,7 @@ static char *unix_to_mac(const char *file) *dst++ = ':'; /* relative paths begin with ':' */ } while(src < file + flen) { - const char *end = strchr(src, '/'); + const char *end = SDL_strchr(src, '/'); int len; if(!end) end = file + flen; /* last component */ @@ -186,7 +186,7 @@ static char *unix_to_mac(const char *file) if(len == 2 && src[0] == '.' && src[1] == '.') { /* replace .. with the empty string */ } else { - memcpy(dst, src, len); + SDL_memcpy(dst, src, len); dst += len; } if(end < file + flen) @@ -209,7 +209,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) { char *mpath = unix_to_mac(file); fp = fopen(mpath, mode); - free(mpath); + SDL_free(mpath); } #else fp = fopen(file, mode); @@ -292,7 +292,7 @@ SDL_RWops *SDL_AllocRW(void) { SDL_RWops *area; - area = (SDL_RWops *)malloc(sizeof *area); + area = (SDL_RWops *)SDL_malloc(sizeof *area); if ( area == NULL ) { SDL_OutOfMemory(); } @@ -301,5 +301,5 @@ SDL_RWops *SDL_AllocRW(void) void SDL_FreeRW(SDL_RWops *area) { - free(area); + SDL_free(area); } diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 08b446f11..952c5ddcc 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -51,11 +51,11 @@ int SDL_JoystickInit(void) status = SDL_SYS_JoystickInit(); if ( status >= 0 ) { arraylen = (status+1)*sizeof(*SDL_joysticks); - SDL_joysticks = (SDL_Joystick **)malloc(arraylen); + SDL_joysticks = (SDL_Joystick **)SDL_malloc(arraylen); if ( SDL_joysticks == NULL ) { SDL_numjoysticks = 0; } else { - memset(SDL_joysticks, 0, arraylen); + SDL_memset(SDL_joysticks, 0, arraylen); SDL_numjoysticks = status; } status = 0; @@ -113,28 +113,28 @@ SDL_Joystick *SDL_JoystickOpen(int device_index) } /* Create and initialize the joystick */ - joystick = (SDL_Joystick *)malloc((sizeof *joystick)); + joystick = (SDL_Joystick *)SDL_malloc((sizeof *joystick)); if ( joystick != NULL ) { - memset(joystick, 0, (sizeof *joystick)); + SDL_memset(joystick, 0, (sizeof *joystick)); joystick->index = device_index; if ( SDL_SYS_JoystickOpen(joystick) < 0 ) { - free(joystick); + SDL_free(joystick); joystick = NULL; } else { if ( joystick->naxes > 0 ) { - joystick->axes = (Sint16 *)malloc + joystick->axes = (Sint16 *)SDL_malloc (joystick->naxes*sizeof(Sint16)); } if ( joystick->nhats > 0 ) { - joystick->hats = (Uint8 *)malloc + joystick->hats = (Uint8 *)SDL_malloc (joystick->nhats*sizeof(Uint8)); } if ( joystick->nballs > 0 ) { - joystick->balls = (struct balldelta *)malloc + joystick->balls = (struct balldelta *)SDL_malloc (joystick->nballs*sizeof(*joystick->balls)); } if ( joystick->nbuttons > 0 ) { - joystick->buttons = (Uint8 *)malloc + joystick->buttons = (Uint8 *)SDL_malloc (joystick->nbuttons*sizeof(Uint8)); } if ( ((joystick->naxes > 0) && !joystick->axes) @@ -146,19 +146,19 @@ SDL_Joystick *SDL_JoystickOpen(int device_index) joystick = NULL; } if ( joystick->axes ) { - memset(joystick->axes, 0, + SDL_memset(joystick->axes, 0, joystick->naxes*sizeof(Sint16)); } if ( joystick->hats ) { - memset(joystick->hats, 0, + SDL_memset(joystick->hats, 0, joystick->nhats*sizeof(Uint8)); } if ( joystick->balls ) { - memset(joystick->balls, 0, + SDL_memset(joystick->balls, 0, joystick->nballs*sizeof(*joystick->balls)); } if ( joystick->buttons ) { - memset(joystick->buttons, 0, + SDL_memset(joystick->buttons, 0, joystick->nbuttons*sizeof(Uint8)); } } @@ -375,7 +375,7 @@ void SDL_JoystickClose(SDL_Joystick *joystick) /* Remove joystick from list */ for ( i=0; SDL_joysticks[i]; ++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)); break; } @@ -386,18 +386,18 @@ void SDL_JoystickClose(SDL_Joystick *joystick) /* Free the data associated with this joystick */ if ( joystick->axes ) { - free(joystick->axes); + SDL_free(joystick->axes); } if ( joystick->hats ) { - free(joystick->hats); + SDL_free(joystick->hats); } if ( joystick->balls ) { - free(joystick->balls); + SDL_free(joystick->balls); } if ( joystick->buttons ) { - free(joystick->buttons); + SDL_free(joystick->buttons); } - free(joystick); + SDL_free(joystick); } void SDL_JoystickQuit(void) @@ -410,7 +410,7 @@ void SDL_JoystickQuit(void) /* Quit the joystick setup */ SDL_SYS_JoystickQuit(); if ( SDL_joysticks ) { - free(SDL_joysticks); + SDL_free(SDL_joysticks); SDL_joysticks = NULL; } } diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index f773d2f36..06bd5b19f 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -2,7 +2,7 @@ SDL - Simple DirectMedia Layer 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 License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. diff --git a/src/joystick/amigaos/SDL_sysjoystick.c b/src/joystick/amigaos/SDL_sysjoystick.c index 7307a318d..ad59d7857 100644 --- a/src/joystick/amigaos/SDL_sysjoystick.c +++ b/src/joystick/amigaos/SDL_sysjoystick.c @@ -116,7 +116,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) ULONG temp,i; 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; /* 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) { if(joystick->hwdata) - free(joystick->hwdata); + SDL_free(joystick->hwdata); return; } diff --git a/src/joystick/beos/SDL_bejoystick.cc b/src/joystick/beos/SDL_bejoystick.cc index 89e6441a3..13a6fe7e5 100644 --- a/src/joystick/beos/SDL_bejoystick.cc +++ b/src/joystick/beos/SDL_bejoystick.cc @@ -67,8 +67,8 @@ int SDL_SYS_JoystickInit(void) /* Search for attached joysticks */ nports = joystick.CountDevices(); numjoysticks = 0; - memset(SDL_joyport, 0, (sizeof SDL_joyport)); - memset(SDL_joyname, 0, (sizeof SDL_joyname)); + SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport)); + SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname)); for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) { if ( joystick.GetDeviceName(i, name) == B_OK ) { if ( joystick.Open(name) != B_ERROR ) { @@ -102,12 +102,12 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) /* Create the joystick data structure */ joystick->hwdata = (struct joystick_hwdata *) - malloc(sizeof(*joystick->hwdata)); + SDL_malloc(sizeof(*joystick->hwdata)); if ( joystick->hwdata == NULL ) { SDL_OutOfMemory(); return(-1); } - memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); stick = new BJoystick; joystick->hwdata->stick = stick; @@ -127,9 +127,9 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) joystick->nhats = stick->CountHats(); joystick->hwdata->new_axes = (int16 *) - malloc(joystick->naxes*sizeof(int16)); + SDL_malloc(joystick->naxes*sizeof(int16)); 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 ) { SDL_OutOfMemory(); SDL_SYS_JoystickClose(joystick); @@ -208,12 +208,12 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick) joystick->hwdata->stick->Close(); delete joystick->hwdata->stick; if ( joystick->hwdata->new_hats ) { - free(joystick->hwdata->new_hats); + SDL_free(joystick->hwdata->new_hats); } 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; } } @@ -224,12 +224,12 @@ void SDL_SYS_JoystickQuit(void) int i; for ( i=0; SDL_joyport[i]; ++i ) { - free(SDL_joyport[i]); + SDL_free(SDL_joyport[i]); } SDL_joyport[0] = NULL; for ( i=0; SDL_joyname[i]; ++i ) { - free(SDL_joyname[i]); + SDL_free(SDL_joyname[i]); } SDL_joyname[0] = NULL; } diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index 39fa29c85..d224a21fa 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -139,8 +139,8 @@ SDL_SYS_JoystickInit(void) SDL_numjoysticks = 0; - memset(joynames, 0, sizeof(joynames)); - memset(joydevnames, 0, sizeof(joydevnames)); + SDL_memset(joynames, 0, sizeof(joynames)); + SDL_memset(joydevnames, 0, sizeof(joydevnames)); for (i = 0; i < MAX_UHID_JOYS; i++) { SDL_Joystick nj; @@ -154,7 +154,7 @@ SDL_SYS_JoystickInit(void) SDL_SYS_JoystickClose(&nj); SDL_numjoysticks++; } else { - free(joynames[nj.index]); + SDL_free(joynames[nj.index]); joynames[nj.index] = NULL; } } @@ -241,7 +241,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy) return (-1); } - hw = (struct joystick_hwdata *)malloc(sizeof(struct joystick_hwdata)); + hw = (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata)); if (hw == NULL) { SDL_OutOfMemory(); close(fd); @@ -250,7 +250,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy) joy->hwdata = hw; hw->fd = fd; hw->path = strdup(path); - if (! strncmp(path, "/dev/joy", 8)) { + if (! SDL_strncmp(path, "/dev/joy", 8)) { hw->type = BSDJOY_JOY; joy->naxes = 2; joy->nbuttons = 2; @@ -311,7 +311,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy) case HUG_JOYSTICK: case HUG_GAME_PAD: s = hid_usage_in_page(hitem.usage); - sp = malloc(strlen(s) + 5); + sp = SDL_malloc(SDL_strlen(s) + 5); sprintf(sp, "%s (%d)", s, joy->index); joydevnames[joy->index] = sp; @@ -351,8 +351,8 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy) return (0); usberr: close(hw->fd); - free(hw->path); - free(hw); + SDL_free(hw->path); + SDL_free(hw); return (-1); } @@ -482,13 +482,13 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy) void 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); hid_dispose_report_desc(joy->hwdata->repdesc); } close(joy->hwdata->fd); - free(joy->hwdata->path); - free(joy->hwdata); + SDL_free(joy->hwdata->path); + SDL_free(joy->hwdata); return; } @@ -500,9 +500,9 @@ SDL_SYS_JoystickQuit(void) for (i = 0; i < MAX_JOYS; i++) { if (joynames[i] != NULL) - free(joynames[i]); + SDL_free(joynames[i]); if (joydevnames[i] != NULL) - free(joydevnames[i]); + SDL_free(joydevnames[i]); } return; @@ -538,7 +538,7 @@ report_alloc(struct report *r, struct report_desc *rd, int repind) r->size = len; 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); if (r->buf == NULL) { SDL_OutOfMemory(); @@ -556,7 +556,7 @@ static void report_free(struct report *r) { if (r->buf != NULL) { - free(r->buf); + SDL_free(r->buf); } r->status = SREPORT_UNINIT; } diff --git a/src/joystick/dc/SDL_sysjoystick.c b/src/joystick/dc/SDL_sysjoystick.c index 3958c592f..3b3f70eff 100644 --- a/src/joystick/dc/SDL_sysjoystick.c +++ b/src/joystick/dc/SDL_sysjoystick.c @@ -90,13 +90,13 @@ const char *SDL_SYS_JoystickName(int index) int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) { /* 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) { SDL_OutOfMemory(); return(-1); } - memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); /* fill nbuttons, naxes, and nhats fields */ joystick->nbuttons = MAX_BUTTONS; @@ -182,7 +182,7 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata != NULL) { /* free system specific hardware data */ - free(joystick->hwdata); + SDL_free(joystick->hwdata); } } diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index ed998a2d1..fcb9a0b47 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -23,7 +23,7 @@ /* This is the system specific header for the SDL joystick API */ #include /* For the definition of NULL */ -#include /* For getenv() prototype */ +#include /* For SDL_getenv() prototype */ #include #include #include @@ -187,9 +187,9 @@ static char *mystrdup(const char *string) { char *newstring; - newstring = (char *)malloc(strlen(string)+1); + newstring = (char *)SDL_malloc(SDL_strlen(string)+1); if ( newstring ) { - strcpy(newstring, string); + SDL_strcpy(newstring, string); } return(newstring); } @@ -209,7 +209,7 @@ static int CountLogicalJoysticks(int max) if (name) { 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; SDL_joylist[prev].map = joystick_logicalmap+j; @@ -243,7 +243,7 @@ static void LogicalSuffix(int logicalno, char* namebuf, int len) "20212223242526272829303132"; const char* suffix; - slen = strlen(namebuf); + slen = SDL_strlen(namebuf); suffix = NULL; @@ -306,8 +306,8 @@ int SDL_SYS_JoystickInit(void) numjoysticks = 0; /* First see if the user specified a joystick to use */ - if ( getenv("SDL_JOYSTICK_DEVICE") != NULL ) { - strncpy(path, getenv("SDL_JOYSTICK_DEVICE"), sizeof(path)); + if ( SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL ) { + SDL_strncpy(path, SDL_getenv("SDL_JOYSTICK_DEVICE"), sizeof(path)); path[sizeof(path)-1] = '\0'; if ( stat(path, &sb) == 0 ) { fd = open(path, O_RDONLY, 0); @@ -426,7 +426,7 @@ static int allocate_hatdata(SDL_Joystick *joystick) { int i; - joystick->hwdata->hats = (struct hwdata_hat *)malloc( + joystick->hwdata->hats = (struct hwdata_hat *)SDL_malloc( joystick->nhats * sizeof(struct hwdata_hat)); if ( joystick->hwdata->hats == NULL ) { return(-1); @@ -442,7 +442,7 @@ static int allocate_balldata(SDL_Joystick *joystick) { int i; - joystick->hwdata->balls = (struct hwdata_ball *)malloc( + joystick->hwdata->balls = (struct hwdata_ball *)SDL_malloc( joystick->nballs * sizeof(struct hwdata_ball)); if ( joystick->hwdata->balls == NULL ) { return(-1); @@ -481,8 +481,8 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd) old_axes = joystick->naxes; /* Generic analog joystick support */ - if ( strstr(name, "Analog") == name && strstr(name, "-hat") ) { - if ( sscanf(name,"Analog %d-axis %*d-button %d-hat", + if ( SDL_strstr(name, "Analog") == name && SDL_strstr(name, "-hat") ) { + if ( SDL_sscanf(name,"Analog %d-axis %*d-button %d-hat", &tmp_naxes, &tmp_nhats) == 2 ) { joystick->naxes = tmp_naxes; @@ -494,7 +494,7 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd) /* Special joystick support */ 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->nhats = special_joysticks[i].nhats; @@ -506,16 +506,16 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd) } /* User environment joystick support */ - if ( (env = getenv("SDL_LINUX_JOYSTICK")) ) { - strcpy(env_name, ""); - if ( *env == '\'' && sscanf(env, "'%[^']s'", env_name) == 1 ) - env += strlen(env_name)+2; - else if ( sscanf(env, "%s", env_name) == 1 ) - env += strlen(env_name); + if ( (env = SDL_getenv("SDL_LINUX_JOYSTICK")) ) { + SDL_strcpy(env_name, ""); + if ( *env == '\'' && SDL_sscanf(env, "'%[^']s'", env_name) == 1 ) + env += SDL_strlen(env_name)+2; + else if ( SDL_sscanf(env, "%s", env_name) == 1 ) + 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 ) { joystick->naxes = tmp_naxes; @@ -697,13 +697,13 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) return(-1); } joystick->hwdata = (struct joystick_hwdata *) - malloc(sizeof(*joystick->hwdata)); + SDL_malloc(sizeof(*joystick->hwdata)); if ( joystick->hwdata == NULL ) { SDL_OutOfMemory(); close(fd); return(-1); } - memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); joystick->hwdata->fd = fd; /* Set the joystick to non-blocking read mode */ @@ -1064,12 +1064,12 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick) #endif close(joystick->hwdata->fd); if ( joystick->hwdata->hats ) { - free(joystick->hwdata->hats); + SDL_free(joystick->hwdata->hats); } if ( joystick->hwdata->balls ) { - free(joystick->hwdata->balls); + SDL_free(joystick->hwdata->balls); } - free(joystick->hwdata); + SDL_free(joystick->hwdata); joystick->hwdata = NULL; } } @@ -1080,7 +1080,7 @@ void SDL_SYS_JoystickQuit(void) int 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; } diff --git a/src/joystick/macos/SDL_sysjoystick.c b/src/joystick/macos/SDL_sysjoystick.c index 83fe48664..0e40e85fe 100644 --- a/src/joystick/macos/SDL_sysjoystick.c +++ b/src/joystick/macos/SDL_sysjoystick.c @@ -137,7 +137,7 @@ const char *SDL_SYS_JoystickName(int index) if ( len >= sizeof(name) ) { len = (sizeof(name) - 1); } - memcpy(name, &SYS_DevDef[index].deviceName[1], len); + SDL_memcpy(name, &SYS_DevDef[index].deviceName[1], len); name[len] = '\0'; return name; @@ -161,14 +161,14 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) index = joystick->index; /* 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) { SDL_OutOfMemory(); return(-1); } - memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); - strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); + SDL_strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index)); joystick->name = joystick->hwdata->name; ISpElementList_ExtractByKind( diff --git a/src/joystick/mint/SDL_sysjoystick.c b/src/joystick/mint/SDL_sysjoystick.c index 783b907a2..705f82c0e 100644 --- a/src/joystick/mint/SDL_sysjoystick.c +++ b/src/joystick/mint/SDL_sysjoystick.c @@ -162,13 +162,13 @@ int SDL_SYS_JoystickInit(void) { int i; 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) \ - if (strstr(env,idstring"-off")) { \ + if (SDL_strstr(env,idstring"-off")) { \ atarijoysticks[num].enabled=SDL_FALSE; \ } \ - if (strstr(env,idstring"-on")) { \ + if (SDL_strstr(env,idstring"-on")) { \ atarijoysticks[num].enabled=SDL_TRUE; \ } diff --git a/src/joystick/os2/SDL_sysjoystick.c b/src/joystick/os2/SDL_sysjoystick.c index 7571db983..11181fd2f 100644 --- a/src/joystick/os2/SDL_sysjoystick.c +++ b/src/joystick/os2/SDL_sysjoystick.c @@ -326,14 +326,14 @@ int index; /* Index shortcut for index in joystick structure */ int i; /* Generic Counter */ /* 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) { SDL_OutOfMemory(); return(-1); } /* Reset Hardware Data */ -memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); +SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); /* ShortCut Pointer */ index = joystick->index; @@ -517,7 +517,7 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick) if (joystick->hwdata != NULL) { /* 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 tempnumber[5]; /* Temporary place to put numeric texts */ -joyenv = getenv("SDL_OS2_JOYSTICK"); +joyenv = SDL_getenv("SDL_OS2_JOYSTICK"); if (joyenv == NULL) return 0; /* Joystick Environment is defined! */ while (*joyenv==' ' && *joyenv!=0) joyenv++; /* jump spaces... */ diff --git a/src/joystick/riscos/SDL_sysjoystick.c b/src/joystick/riscos/SDL_sysjoystick.c index 5132ee8a3..d4ca80e55 100644 --- a/src/joystick/riscos/SDL_sysjoystick.c +++ b/src/joystick/riscos/SDL_sysjoystick.c @@ -89,7 +89,7 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) { _kernel_swi_regs regs; - if(!(joystick->hwdata=malloc(sizeof(struct joystick_hwdata)))) + if(!(joystick->hwdata=SDL_malloc(sizeof(struct joystick_hwdata)))) return -1; regs.r[0] = joystick->index; @@ -161,7 +161,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) void SDL_SYS_JoystickClose(SDL_Joystick *joystick) { if(joystick->hwdata) - free(joystick->hwdata); + SDL_free(joystick->hwdata); return; } diff --git a/src/joystick/win32/SDL_mmjoystick.c b/src/joystick/win32/SDL_mmjoystick.c index 60980075a..e4b5b4af3 100644 --- a/src/joystick/win32/SDL_mmjoystick.c +++ b/src/joystick/win32/SDL_mmjoystick.c @@ -82,7 +82,7 @@ static char *GetJoystickName(int index, const char *szRegKey) unsigned char regvalue[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, szRegKey, REGSTR_KEY_JOYCURR); @@ -95,7 +95,7 @@ static char *GetJoystickName(int index, const char *szRegKey) joystick's properties */ regsize = sizeof(regname); - snprintf((char *) regvalue, SDL_arraysize(regvalue), + SDL_snprintf((char *) regvalue, SDL_arraysize(regvalue), "Joystick%d%s", index+1, REGSTR_VAL_JOYOEMNAME); regresult = RegQueryValueExA(hKey, @@ -105,7 +105,7 @@ static char *GetJoystickName(int index, const char *szRegKey) if (regresult == ERROR_SUCCESS) { /* 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); regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, (char *) regkey, 0, KEY_READ, &hKey); @@ -124,7 +124,7 @@ static char *GetJoystickName(int index, const char *szRegKey) allocate enough memory for the OEM name text ... */ - name = (char *) malloc(regsize); + name = (char *) SDL_malloc(regsize); /* ... and read it from the registry */ regresult = RegQueryValueExA(hKey, @@ -227,13 +227,13 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) axis_max[5] = SYS_Joystick[index].wVmax; /* 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) { SDL_OutOfMemory(); return(-1); } - memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); /* set hardware data */ joystick->hwdata->id = SYS_JoystickID[index]; @@ -359,7 +359,7 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joystick) { if (joystick->hwdata != NULL) { /* free system specific hardware data */ - free(joystick->hwdata); + SDL_free(joystick->hwdata); } } @@ -369,7 +369,7 @@ void SDL_SYS_JoystickQuit(void) int i; for (i = 0; i < MAX_JOYSTICKS; i++) { 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; default: - snprintf(errbuf, SDL_arraysize(errbuf), + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: Unknown Multimedia system error: 0x%x", function, code); break; } 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); } diff --git a/src/loadso/macos/SDL_loadso.c b/src/loadso/macos/SDL_loadso.c index 7ffb63a06..26de2dd43 100644 --- a/src/loadso/macos/SDL_loadso.c +++ b/src/loadso/macos/SDL_loadso.c @@ -52,7 +52,7 @@ void *SDL_LoadObject(const char *sofile) OSErr error; char psofile[512]; - strncpy(psofile, sofile, SDL_TABLESIZE(psofile)); + SDL_strncpy(psofile, sofile, SDL_TABLESIZE(psofile)); psofile[SDL_TABLESIZE(psofile)-1] = '\0'; error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch, kLoadCFrag, &library_id, &mainAddr, errName); @@ -90,7 +90,7 @@ void *SDL_LoadFunction(void *handle, const char *name) CFragConnectionID library_id = (CFragConnectionID)handle; char pname[512]; - strncpy(pname, name, SDL_TABLESIZE(pname)); + SDL_strncpy(pname, name, SDL_TABLESIZE(pname)); pname[SDL_TABLESIZE(pname)-1] = '\0'; if ( FindSymbol(library_id, C2PStr(pname), (char **)&symbol, &class) != noErr ) { diff --git a/src/loadso/macosx/SDL_loadso.c b/src/loadso/macosx/SDL_loadso.c index 022175f9e..776c7f233 100644 --- a/src/loadso/macosx/SDL_loadso.c +++ b/src/loadso/macosx/SDL_loadso.c @@ -282,7 +282,7 @@ static void error(const char *str, ...) va_start(arg, str); tss = pthread_getspecific(dlerror_key); 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); va_end(arg); debug("ERROR: %s\n", err_str); @@ -298,7 +298,7 @@ static void warning(const char *str) static const char *safegetenv(const char *s) { - const char *ss = getenv(s); + const char *ss = SDL_getenv(s); 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); 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); break; @@ -362,14 +362,14 @@ static const char *searchList() static char *buf=NULL; const char *ldlp = safegetenv("LD_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) stdpath = "/usr/local/lib:/lib:/usr/lib"; if (!buf) { - buf_size = strlen(ldlp) + strlen(dyldlp) + strlen(stdpath) + 4; - buf = malloc(buf_size); - snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), + buf_size = SDL_strlen(ldlp) + SDL_strlen(dyldlp) + SDL_strlen(stdpath) + 4; + buf = SDL_malloc(buf_size); + SDL_snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), stdpath, '\0'); } return buf; @@ -383,7 +383,7 @@ static const char *getSearchPath(int i) static int end = 0; static int numsize = MAX_SEARCH_PATHS; 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) { return (const char*)path; @@ -400,8 +400,8 @@ static const char *getSearchPath(int i) tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **)); if (tmp) { - memcpy(tmp, path, sizeof(char **) * numsize); - free(path); + SDL_memcpy(tmp, path, sizeof(char **) * numsize); + SDL_free(path); path = tmp; numsize += MAX_SEARCH_PATHS; } @@ -428,7 +428,7 @@ static const char *getFullPath(int i, const char *file) const char *path = getSearchPath(i); if (path) { - snprintf(buf, PATH_MAX, "%s/%s", path, file); + SDL_snprintf(buf, PATH_MAX, "%s/%s", path, file); } return path ? buf : 0; } @@ -446,7 +446,7 @@ static const struct stat *findFile(const char *file, const char **fullPath) *fullPath = file; if (0 == stat(file, &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 */ fileName = NULL; if (!fileName) @@ -567,7 +567,7 @@ static const struct mach_header *my_find_image(const char *name) for (j = 0; j < i; j++) { id = _dyld_get_image_name(j); - if (!strcmp(id, name)) + if (!SDL_strcmp(id, name)) { mh = _dyld_get_image_header(j); break; @@ -620,7 +620,7 @@ static NSSymbol *search_linked_libs(const struct mach_header * mh, const char *s 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() { NSLinkEditErrors dylder; @@ -629,10 +629,10 @@ static inline const char *dyld_error_str() const char *dyldfile; const char* retStr = NULL; NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); - if (dylderrstr && strlen(dylderrstr)) + if (dylderrstr && SDL_strlen(dylderrstr)) { - retStr = malloc(strlen(dylderrstr) +1); - strcpy((char*)retStr,dylderrstr); + retStr = SDL_malloc(SDL_strlen(dylderrstr) +1); + SDL_strcpy((char*)retStr,dylderrstr); } return retStr; } @@ -735,21 +735,21 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr else { if (savedErrorStr) - free((char*)savedErrorStr); - savedErrorStr = malloc(256); - snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol); + SDL_free((char*)savedErrorStr); + savedErrorStr = SDL_malloc(256); + SDL_snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol); } } } /* Error reporting */ if (!nssym) { - if (!savedErrorStr || !strlen(savedErrorStr)) + if (!savedErrorStr || !SDL_strlen(savedErrorStr)) { if (savedErrorStr) - free((char*)savedErrorStr); - savedErrorStr = malloc(256); - snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol); + SDL_free((char*)savedErrorStr); + savedErrorStr = SDL_malloc(256); + SDL_snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol); } if (canSetError) { @@ -760,7 +760,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr debug(savedErrorStr); } if (savedErrorStr) - free((char*)savedErrorStr); + SDL_free((char*)savedErrorStr); return NULL; } return NSAddressOfSymbol(nssym); @@ -839,13 +839,13 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in if (!(dls->module)) { NSLinkEditError(&ler, &lerno, &file, &errstr); - if (!errstr || (!strlen(errstr))) + if (!errstr || (!SDL_strlen(errstr))) error("Can't open this file type"); else error(errstr); if ((dls->flags & DL_IN_LIST) == 0) { - free(dls); + SDL_free(dls); } return NULL; } @@ -867,7 +867,7 @@ static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, in NSLinkEditError(&ler, &lerno, &file, &errstr); if ((dls->flags & DL_IN_LIST) == 0) { - free(dls); + SDL_free(dls); } error(errstr); return NULL; @@ -917,7 +917,7 @@ static void resetdlerror() static void dlerrorfree(void *data) { - free(data); + SDL_free(data); } /* 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); if (!tss) { - tss = malloc(sizeof(struct dlthread)); + tss = SDL_malloc(sizeof(struct dlthread)); tss->lockcnt = 0; tss->errset = 0; if (pthread_setspecific(dlerror_key, tss)) @@ -1010,16 +1010,16 @@ static void *SDL_OSX_dlopen(const char *path, int mode) #if !FINK_BUILD 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; char *malloc_sym = NULL; dolock(); - malloc_sym = malloc(sym_len + 2); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + SDL_free(malloc_sym); } 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 * for opendarwin. */ - int sym_len = strlen(symbol); + int sym_len = SDL_strlen(symbol); void *value = NULL; char *malloc_sym = NULL; - malloc_sym = malloc(sym_len + 2); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + SDL_free(malloc_sym); } 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 (!strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT")) + if (!SDL_strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT")) break; } } @@ -1341,15 +1341,15 @@ static dlfunc_t SDL_OSX_dlfunc(void * dl_restrict handle, const char * dl_restri void *d; dlfunc_t f; } rv; - int sym_len = strlen(symbol); + int sym_len = SDL_strlen(symbol); char *malloc_sym = NULL; dolock(); - malloc_sym = malloc(sym_len + 2); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); rv.d = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + SDL_free(malloc_sym); } else { diff --git a/src/loadso/windows/SDL_loadso.c b/src/loadso/windows/SDL_loadso.c index 847808492..2b6152264 100644 --- a/src/loadso/windows/SDL_loadso.c +++ b/src/loadso/windows/SDL_loadso.c @@ -45,8 +45,8 @@ void *SDL_LoadObject(const char *sofile) #if defined(_WIN32_WCE) char errbuf[512]; - wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t)); - wchar_t *sofile_t = malloc((MAX_PATH+1) * sizeof(wchar_t)); + wchar_t *errbuf_t = SDL_malloc(512 * 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); handle = (void *)LoadLibrary(sofile_t); @@ -62,8 +62,8 @@ void *SDL_LoadObject(const char *sofile) loaderror = errbuf; } - free(sofile_t); - free(errbuf_t); + SDL_free(sofile_t); + SDL_free(errbuf_t); #else /*if defined(WIN32)*/ char errbuf[512]; @@ -94,10 +94,10 @@ void *SDL_LoadFunction(void *handle, const char *name) #if defined(_WIN32_WCE) char errbuf[512]; - int length = strlen(name); + int length = SDL_strlen(name); - wchar_t *name_t = malloc((length + 1) * sizeof(wchar_t)); - wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t)); + wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t)); + wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); @@ -112,8 +112,8 @@ void *SDL_LoadFunction(void *handle, const char *name) loaderror = errbuf; } - free(name_t); - free(errbuf_t); + SDL_free(name_t); + SDL_free(errbuf_t); #else /*if defined(WIN32)*/ char errbuf[512]; diff --git a/src/main/macos/SDL_main.c b/src/main/macos/SDL_main.c index 2e745a6a4..a2ce3b4fc 100644 --- a/src/main/macos/SDL_main.c +++ b/src/main/macos/SDL_main.c @@ -589,7 +589,7 @@ int main(int argc, char *argv[]) /* Parse C-string into argv and argc */ nargs = ParseCommandLine (commandLine, NULL); - args = (char **)malloc((nargs+1)*(sizeof *args)); + args = (char **)SDL_malloc((nargs+1)*(sizeof *args)); if ( args == NULL ) { exit(-1); } diff --git a/src/main/win32/SDL_win32_main.c b/src/main/win32/SDL_win32_main.c index 5249377b8..1561605b8 100644 --- a/src/main/win32/SDL_win32_main.c +++ b/src/main/win32/SDL_win32_main.c @@ -5,12 +5,12 @@ */ #include -#include -#include #include -#include -#include /* For _alloca() */ +#include "SDL_windows.h" + +#include "SDL_stdlib.h" +#include "SDL_string.h" #ifdef _WIN32_WCE # define DIR_SEPERATOR TEXT("\\") @@ -56,7 +56,7 @@ #define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t')) /* 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; @@ -195,15 +195,15 @@ int console_main(int argc, char *argv[]) /* Get the class name from argv[0] */ appname = argv[0]; - if ( (bufp=strrchr(argv[0], '\\')) != NULL ) { + if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) { appname = bufp+1; } else - if ( (bufp=strrchr(argv[0], '/')) != NULL ) { + if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) { appname = bufp+1; } - if ( (bufp=strrchr(appname, '.')) == NULL ) - n = strlen(appname); + if ( (bufp=SDL_strrchr(appname, '.')) == NULL ) + n = SDL_strlen(appname); else n = (bufp-appname); @@ -211,7 +211,7 @@ int console_main(int argc, char *argv[]) if ( bufp == NULL ) { return OutOfMemory(); } - strncpy(bufp, appname, n); + SDL_strncpy(bufp, appname, n); bufp[n] = '\0'; appname = bufp; @@ -298,8 +298,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) } path[pathlen] = '\0'; - strcpy( stdoutPath, path ); - strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE ); + SDL_strcpy( stdoutPath, path ); + SDL_strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE ); /* Redirect standard input and standard output */ newfp = freopen(stdoutPath, TEXT("w"), stdout); @@ -317,8 +317,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) } #endif /* _WIN32_WCE */ - strcpy( stderrPath, path ); - strcat( stderrPath, DIR_SEPERATOR STDERR_FILE ); + SDL_strcpy( stderrPath, path ); + SDL_strcat( stderrPath, DIR_SEPERATOR STDERR_FILE ); newfp = freopen(stderrPath, TEXT("w"), stderr); #ifndef _WIN32_WCE @@ -354,11 +354,11 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) #else /* Grab the command line (use alloca() on Windows) */ bufp = GetCommandLine(); - cmdline = (char *)alloca(strlen(bufp)+1); + cmdline = (char *)alloca(SDL_strlen(bufp)+1); if ( cmdline == NULL ) { return OutOfMemory(); } - strcpy(cmdline, bufp); + SDL_strcpy(cmdline, bufp); #endif /* Parse it into argv and argc */ diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 74f789175..78f31a857 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -42,20 +42,20 @@ int SDL_putenv(const char *variable) char *value; const char *sep; - sep = strchr(variable, '='); + sep = SDL_strchr(variable, '='); if ( sep == NULL ) { return -1; } - bufferlen = strlen(variable)+1; + bufferlen = SDL_strlen(variable)+1; if ( bufferlen > SDL_envmemlen ) { - char *newmem = (char *)realloc(SDL_envmem, bufferlen); + char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); if ( newmem == NULL ) { return -1; } SDL_envmem = newmem; SDL_envmemlen = bufferlen; } - strcpy(SDL_envmem, variable); + SDL_strcpy(SDL_envmem, variable); value = SDL_envmem + (sep - variable); *value++ = '\0'; if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) { @@ -74,7 +74,7 @@ char *SDL_getenv(const char *name) return NULL; } if ( bufferlen > SDL_envmemlen ) { - char *newmem = (char *)realloc(SDL_envmem, bufferlen); + char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); if ( newmem == NULL ) { return NULL; } @@ -140,7 +140,7 @@ int SDL_putenv(const char *variable) /* Didn't find it in the environment, expand and add */ if ( ! added ) { - new_env = realloc(SDL_env, (i+2)*sizeof(char *)); + new_env = SDL_realloc(SDL_env, (i+2)*sizeof(char *)); if ( new_env ) { SDL_env = new_env; SDL_env[i++] = new_variable; diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index d12526032..d33807f3c 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -39,6 +39,11 @@ #define LACKS_ERRNO_H #define LACKS_STDLIB_H #define ABORT +#define memset SDL_memset +#define memcpy SDL_memcpy +#define malloc SDL_malloc +#define realloc SDL_realloc +#define free SDL_free /* This is a version (aka dlmalloc) of malloc/free/realloc written by diff --git a/src/stdlib/SDL_qsort.c b/src/stdlib/SDL_qsort.c index ffc0b9ca0..47261bdac 100644 --- a/src/stdlib/SDL_qsort.c +++ b/src/stdlib/SDL_qsort.c @@ -233,9 +233,9 @@ typedef struct { char * first; char * last; } stack_entry; /* Shift everything in [test,first) \ * up by one, and place |first| \ * where |test| is. */ \ - memcpy(pivot,first,size); \ - memmove(test+size,test,first-test); \ - memcpy(test,pivot,size); \ + SDL_memcpy(pivot,first,size); \ + SDL_memmove(test+size,test,first-test); \ + SDL_memcpy(test,pivot,size); \ } \ } @@ -298,7 +298,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, stack_entry stack[STACK_SIZE]; int stacktop=0; char *first,*last; - char *pivot=malloc(size); + char *pivot=SDL_malloc(size); size_t trunc=TRUNC_nonaligned*size; assert(pivot!=0); @@ -310,7 +310,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, /* Select pivot */ { char * mid=first+size*((last-first)/size >> 1); Pivot(SWAP_nonaligned,size); - memcpy(pivot,mid,size); + SDL_memcpy(pivot,mid,size); } /* Partition. */ Partition(SWAP_nonaligned,size); @@ -320,7 +320,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, } PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size); Insertion(SWAP_nonaligned); - free(pivot); + SDL_free(pivot); } static void qsort_aligned(void *base, size_t nmemb, size_t size, @@ -329,7 +329,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size, stack_entry stack[STACK_SIZE]; int stacktop=0; char *first,*last; - char *pivot=malloc(size); + char *pivot=SDL_malloc(size); size_t trunc=TRUNC_aligned*size; assert(pivot!=0); @@ -341,7 +341,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size, /* Select pivot */ { char * mid=first+size*((last-first)/size >> 1); Pivot(SWAP_aligned,size); - memcpy(pivot,mid,size); + SDL_memcpy(pivot,mid,size); } /* Partition. */ Partition(SWAP_aligned,size); @@ -351,7 +351,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size, } PreInsertion(SWAP_aligned,TRUNC_aligned,size); Insertion(SWAP_aligned); - free(pivot); + SDL_free(pivot); } static void qsort_words(void *base, size_t nmemb, @@ -360,7 +360,7 @@ static void qsort_words(void *base, size_t nmemb, stack_entry stack[STACK_SIZE]; int stacktop=0; char *first,*last; - char *pivot=malloc(WORD_BYTES); + char *pivot=SDL_malloc(WORD_BYTES); assert(pivot!=0); first=(char*)base; last=first+(nmemb-1)*WORD_BYTES; @@ -398,7 +398,7 @@ fprintf(stderr,"pivot=%d\n",*(int*)pivot); *pr=*pl; } if (pr!=(int*)first) *pr=*(int*)pivot; } - free(pivot); + SDL_free(pivot); } /* ---------------------------------------------------------------------- */ diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 600b1d510..e15718e97 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -375,7 +375,7 @@ char *SDL_strchr(const char *string, int c) #ifndef HAVE_STRRCHR char *SDL_strrchr(const char *string, int c) { - const char *bufp = string + strlen(string) - 1; + const char *bufp = string + SDL_strlen(string) - 1; while ( bufp >= string ) { if ( *bufp == c ) { return (char *)bufp; @@ -388,9 +388,9 @@ char *SDL_strrchr(const char *string, int c) #ifndef HAVE_STRSTR char *SDL_strstr(const char *haystack, const char *needle) { - size_t length = strlen(needle); + size_t length = SDL_strlen(needle); while ( *haystack ) { - if ( strncmp(haystack, needle, length) == 0 ) { + if ( SDL_strncmp(haystack, needle, length) == 0 ) { return (char *)haystack; } } @@ -429,9 +429,9 @@ char *SDL_ltoa(long value, char *string, int radix) /* The numbers went into the string backwards. :) */ if ( *string == '-' ) { - _strrev(string+1); + SDL_strrev(string+1); } else { - _strrev(string); + SDL_strrev(string); } return string; @@ -454,7 +454,7 @@ char *SDL_ultoa(unsigned long value, char *string, int radix) *bufp = '\0'; /* The numbers went into the string backwards. :) */ - _strrev(string); + SDL_strrev(string); return string; } @@ -497,9 +497,9 @@ char *SDL_lltoa(Sint64 value, char *string, int radix) /* The numbers went into the string backwards. :) */ if ( *string == '-' ) { - _strrev(string+1); + SDL_strrev(string+1); } else { - _strrev(string); + SDL_strrev(string); } return string; @@ -522,7 +522,7 @@ char *SDL_ulltoa(Uint64 value, char *string, int radix) *bufp = '\0'; /* The numbers went into the string backwards. :) */ - _strrev(string); + SDL_strrev(string); return string; } @@ -878,12 +878,12 @@ static size_t SDL_PrintLong(char *text, long value, int radix, size_t maxlen) char num[130]; size_t size; - _ltoa(value, num, radix); + SDL_ltoa(value, num, radix); size = SDL_strlen(num); if ( size > maxlen ) { size = maxlen; } - strncpy(text, num, size); + SDL_strncpy(text, num, size); return size; } @@ -892,12 +892,12 @@ static size_t SDL_PrintUnsignedLong(char *text, unsigned long value, int radix, char num[130]; size_t size; - _ultoa(value, num, radix); + SDL_ultoa(value, num, radix); size = SDL_strlen(num); if ( size > maxlen ) { size = maxlen; } - strncpy(text, num, size); + SDL_strncpy(text, num, size); return size; } @@ -907,12 +907,12 @@ static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxl char num[130]; size_t size; - _i64toa(value, num, radix); + SDL_lltoa(value, num, radix); size = SDL_strlen(num); if ( size > maxlen ) { size = maxlen; } - strncpy(text, num, size); + SDL_strncpy(text, num, size); return size; } @@ -921,12 +921,12 @@ static size_t SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, siz char num[130]; size_t size; - _ui64toa(value, num, radix); + SDL_ulltoa(value, num, radix); size = SDL_strlen(num); if ( size > maxlen ) { size = maxlen; } - strncpy(text, num, size); + SDL_strncpy(text, num, size); return size; } @@ -1076,7 +1076,7 @@ int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) break; } if ( do_lowercase ) { - _strlwr(text); + SDL_strlwr(text); } done = SDL_TRUE; break; diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index c05e18ab6..a8982b4ca 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -99,16 +99,16 @@ static void SDL_AddThread(SDL_Thread *thread) SDL_numthreads, SDL_maxthreads); #endif if ( SDL_numthreads == SDL_maxthreads ) { - threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* + threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* (sizeof *threads)); if ( threads == NULL ) { SDL_OutOfMemory(); goto done; } - memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); + SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); SDL_maxthreads += ARRAY_CHUNKSIZE; if ( SDL_Threads ) { - free(SDL_Threads); + SDL_free(SDL_Threads); } SDL_Threads = threads; } @@ -136,7 +136,7 @@ static void SDL_DelThread(SDL_Thread *thread) } } else { SDL_maxthreads = 0; - free(SDL_Threads); + SDL_free(SDL_Threads); SDL_Threads = NULL; } #ifdef DEBUG_THREADS @@ -223,19 +223,19 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data) int ret; /* Allocate memory for the thread info structure */ - thread = (SDL_Thread *)malloc(sizeof(*thread)); + thread = (SDL_Thread *)SDL_malloc(sizeof(*thread)); if ( thread == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(thread, 0, (sizeof *thread)); + SDL_memset(thread, 0, (sizeof *thread)); thread->status = -1; /* Set up the arguments for the thread */ - args = (thread_args *)malloc(sizeof(*args)); + args = (thread_args *)SDL_malloc(sizeof(*args)); if ( args == NULL ) { SDL_OutOfMemory(); - free(thread); + SDL_free(thread); return(NULL); } args->func = fn; @@ -243,8 +243,8 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data) args->info = thread; args->wait = SDL_CreateSemaphore(0); if ( args->wait == NULL ) { - free(thread); - free(args); + SDL_free(thread); + SDL_free(args); return(NULL); } @@ -263,11 +263,11 @@ DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data) } else { /* Oops, failed. Gotta free everything */ SDL_DelThread(thread); - free(thread); + SDL_free(thread); thread = NULL; } SDL_DestroySemaphore(args->wait); - free(args); + SDL_free(args); /* Everything is running now */ return(thread); @@ -281,7 +281,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status) *status = thread->status; } SDL_DelThread(thread); - free(thread); + SDL_free(thread); } } diff --git a/src/thread/amigaos/SDL_syssem.c b/src/thread/amigaos/SDL_syssem.c index ae1f79281..43d9b071c 100644 --- a/src/thread/amigaos/SDL_syssem.c +++ b/src/thread/amigaos/SDL_syssem.c @@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *)malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if ( ! sem ) { SDL_OutOfMemory(); @@ -53,7 +53,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) D(bug("Creating semaphore %lx...\n",sem)); - memset(sem,0,sizeof(*sem)); + SDL_memset(sem,0,sizeof(*sem)); InitSemaphore(&sem->Sem); @@ -66,7 +66,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) if ( sem ) { // Condizioni per liberare i task in attesa? - free(sem); + SDL_free(sem); } } diff --git a/src/thread/amigaos/SDL_thread.c b/src/thread/amigaos/SDL_thread.c index fb1ea5685..ba8a4c0bd 100644 --- a/src/thread/amigaos/SDL_thread.c +++ b/src/thread/amigaos/SDL_thread.c @@ -84,16 +84,16 @@ static void SDL_AddThread(SDL_Thread *thread) SDL_numthreads, SDL_maxthreads); #endif if ( SDL_numthreads == SDL_maxthreads ) { - threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* + threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)* (sizeof *threads)); if ( threads == NULL ) { SDL_OutOfMemory(); goto done; } - memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); + SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads)); SDL_maxthreads += ARRAY_CHUNKSIZE; if ( SDL_Threads ) { - free(SDL_Threads); + SDL_free(SDL_Threads); } SDL_Threads = threads; } @@ -198,19 +198,19 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) int ret; /* Allocate memory for the thread info structure */ - thread = (SDL_Thread *)malloc(sizeof(*thread)); + thread = (SDL_Thread *)SDL_malloc(sizeof(*thread)); if ( thread == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(thread, 0, (sizeof *thread)); + SDL_memset(thread, 0, (sizeof *thread)); thread->status = -1; /* Set up the arguments for the thread */ - args = (thread_args *)malloc(sizeof(*args)); + args = (thread_args *)SDL_malloc(sizeof(*args)); if ( args == NULL ) { SDL_OutOfMemory(); - free(thread); + SDL_free(thread); return(NULL); } args->func = fn; @@ -218,8 +218,8 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) args->info = thread; args->wait = FindTask(NULL); if ( args->wait == NULL ) { - free(thread); - free(args); + SDL_free(thread); + SDL_free(args); SDL_OutOfMemory(); return(NULL); } @@ -239,10 +239,10 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) } else { /* Oops, failed. Gotta free everything */ SDL_DelThread(thread); - free(thread); + SDL_free(thread); thread = NULL; } - free(args); + SDL_free(args); /* Everything is running now */ return(thread); @@ -256,7 +256,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status) *status = thread->status; } SDL_DelThread(thread); - free(thread); + SDL_free(thread); } } diff --git a/src/thread/beos/SDL_syssem.c b/src/thread/beos/SDL_syssem.c index 4cbe046e1..ca159056b 100644 --- a/src/thread/beos/SDL_syssem.c +++ b/src/thread/beos/SDL_syssem.c @@ -37,12 +37,12 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *)malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if ( sem ) { sem->id = create_sem(initial_value, "SDL semaphore"); if ( sem->id < B_NO_ERROR ) { SDL_SetError("create_sem() failed"); - free(sem); + SDL_free(sem); sem = NULL; } } else { @@ -58,7 +58,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) if ( sem->id >= B_NO_ERROR ) { delete_sem(sem->id); } - free(sem); + SDL_free(sem); } } diff --git a/src/thread/bsdi/SDL_syssem.c b/src/thread/bsdi/SDL_syssem.c index 06c2a0fcd..02a18e363 100644 --- a/src/thread/bsdi/SDL_syssem.c +++ b/src/thread/bsdi/SDL_syssem.c @@ -113,11 +113,11 @@ struct SDL_semaphore { /* Create a semaphore, initialized with 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_init(&sem->sem_data, 0, initial_value) < 0 ) { SDL_SetError("sem_init() failed"); - free(sem); + SDL_free(sem); sem = NULL; } else { sem->sem = &sem->sem_data; @@ -132,7 +132,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) { if ( 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; } - *sem = (sem_t)malloc(sizeof(struct sem)); + *sem = (sem_t)SDL_malloc(sizeof(struct sem)); if (*sem == NULL) { errno = ENOSPC; retval = -1; @@ -333,7 +333,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value) * Initialize the semaphore. */ if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) { - free(*sem); + SDL_free(*sem); errno = ENOSPC; retval = -1; goto RETURN; @@ -341,7 +341,7 @@ sem_init(sem_t *sem, int pshared, unsigned int value) if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) { pthread_mutex_destroy(&(*sem)->lock); - free(*sem); + SDL_free(*sem); errno = ENOSPC; retval = -1; goto RETURN; @@ -377,7 +377,7 @@ sem_destroy(sem_t *sem) pthread_cond_destroy(&(*sem)->gtzero); (*sem)->magic = 0; - free(*sem); + SDL_free(*sem); retval = 0; RETURN: diff --git a/src/thread/dc/SDL_syscond.c b/src/thread/dc/SDL_syscond.c index dc11e2806..c188acfc1 100644 --- a/src/thread/dc/SDL_syscond.c +++ b/src/thread/dc/SDL_syscond.c @@ -46,7 +46,7 @@ SDL_cond * SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) malloc(sizeof(SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if ( cond ) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); @@ -75,7 +75,7 @@ void SDL_DestroyCond(SDL_cond *cond) if ( cond->lock ) { SDL_DestroyMutex(cond->lock); } - free(cond); + SDL_free(cond); } } diff --git a/src/thread/dc/SDL_sysmutex.c b/src/thread/dc/SDL_sysmutex.c index a9f127216..2b7af1c5a 100644 --- a/src/thread/dc/SDL_sysmutex.c +++ b/src/thread/dc/SDL_sysmutex.c @@ -43,7 +43,7 @@ SDL_mutex *SDL_CreateMutex(void) SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *)malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if ( mutex ) { spinlock_init(&mutex->mutex); mutex->recursive = 0; @@ -58,7 +58,7 @@ SDL_mutex *SDL_CreateMutex(void) void SDL_DestroyMutex(SDL_mutex *mutex) { if ( mutex ) { - free(mutex); + SDL_free(mutex); } } diff --git a/src/thread/generic/SDL_syscond.c b/src/thread/generic/SDL_syscond.c index a717b3609..ffd5c5650 100644 --- a/src/thread/generic/SDL_syscond.c +++ b/src/thread/generic/SDL_syscond.c @@ -44,7 +44,7 @@ SDL_cond * SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) malloc(sizeof(SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if ( cond ) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); @@ -73,7 +73,7 @@ void SDL_DestroyCond(SDL_cond *cond) if ( cond->lock ) { SDL_DestroyMutex(cond->lock); } - free(cond); + SDL_free(cond); } } diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index 4828fa317..b46c5a2c5 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -40,14 +40,14 @@ SDL_mutex *SDL_CreateMutex(void) SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *)malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if ( mutex ) { /* Create the mutex semaphore, with initial value 1 */ mutex->sem = SDL_CreateSemaphore(1); mutex->recursive = 0; mutex->owner = 0; if ( ! mutex->sem ) { - free(mutex); + SDL_free(mutex); mutex = NULL; } } else { @@ -63,7 +63,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) if ( mutex->sem ) { SDL_DestroySemaphore(mutex->sem); } - free(mutex); + SDL_free(mutex); } } diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index f55f7a5bc..6312d034d 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -85,7 +85,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *)malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if ( ! sem ) { SDL_OutOfMemory(); return(0); @@ -118,7 +118,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) SDL_mutexP(sem->count_lock); SDL_mutexV(sem->count_lock); SDL_DestroyMutex(sem->count_lock); - free(sem); + SDL_free(sem); } } diff --git a/src/thread/linux/SDL_syscond.c b/src/thread/linux/SDL_syscond.c index b4e080a9e..9aaa21ce8 100644 --- a/src/thread/linux/SDL_syscond.c +++ b/src/thread/linux/SDL_syscond.c @@ -62,11 +62,11 @@ SDL_cond * SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) malloc(sizeof(SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if ( cond ) { if ( pthread_cond_init(&cond->cond, NULL) < 0 ) { SDL_SetError("pthread_cond_init() failed"); - free(cond); + SDL_free(cond); cond = NULL; } } @@ -78,7 +78,7 @@ void SDL_DestroyCond(SDL_cond *cond) { if ( cond ) { pthread_cond_destroy(&cond->cond); - free(cond); + SDL_free(cond); } } diff --git a/src/thread/linux/SDL_sysmutex.c b/src/thread/linux/SDL_sysmutex.c index 3a4ef7387..d41f20639 100644 --- a/src/thread/linux/SDL_sysmutex.c +++ b/src/thread/linux/SDL_sysmutex.c @@ -71,7 +71,7 @@ SDL_mutex *SDL_CreateMutex (void) #endif /* PTHREAD_RECURSIVE_MUTEX */ if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) { SDL_SetError("pthread_mutex_init() failed"); - free(mutex); + SDL_free(mutex); mutex = NULL; } } else { @@ -84,7 +84,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) { if ( mutex ) { pthread_mutex_destroy(&mutex->id); - free(mutex); + SDL_free(mutex); } } diff --git a/src/thread/linux/SDL_syssem.c b/src/thread/linux/SDL_syssem.c index df74ef9f7..0e4896bfa 100644 --- a/src/thread/linux/SDL_syssem.c +++ b/src/thread/linux/SDL_syssem.c @@ -68,7 +68,7 @@ struct SDL_semaphore { /* Create a semaphore, initialized with 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 ) { #ifdef USE_NAMED_SEMAPHORES 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); if ( sem->sem == (sem_t *)SEM_FAILED ) { SDL_SetError("sem_open(%s) failed", name); - free(sem); + SDL_free(sem); sem = NULL; } else { sem_unlink(name); @@ -86,7 +86,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) #else if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) { SDL_SetError("sem_init() failed"); - free(sem); + SDL_free(sem); sem = NULL; } else { sem->sem = &sem->sem_data; @@ -106,7 +106,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) #else sem_destroy(sem->sem); #endif - free(sem); + SDL_free(sem); } } @@ -245,7 +245,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) union semun init; key_t key; - sem = (SDL_sem *)malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if ( sem == NULL ) { SDL_OutOfMemory(); return(NULL); @@ -269,7 +269,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Report the error if we eventually failed */ if ( sem->id < 0 ) { SDL_SetError("Couldn't create semaphore"); - free(sem); + SDL_free(sem); return(NULL); } init.val = initial_value; /* Initialize semaphore */ @@ -287,7 +287,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) dummy.val = 0; semctl(sem->id, 0, IPC_RMID, dummy); #endif - free(sem); + SDL_free(sem); } } diff --git a/src/thread/linux/SDL_systhread.c b/src/thread/linux/SDL_systhread.c index 05c1a320e..7ed5833fe 100644 --- a/src/thread/linux/SDL_systhread.c +++ b/src/thread/linux/SDL_systhread.c @@ -172,7 +172,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) void *stack; /* Allocate memory for thread stack */ - stack = malloc(STACKSIZE); + stack = SDL_malloc(STACKSIZE); if ( stack == (void *)0 ) { SDL_OutOfMemory(); return(-1); @@ -186,7 +186,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) thread->handle = clone(RunThread, stack, (CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND), args); if ( thread->handle < 0 ) { - free(thread->data); + SDL_free(thread->data); SDL_SetError("Not enough resources to create thread"); return(-1); } @@ -233,7 +233,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread) while ( system(command) == 0 ) sleep(1); #endif - free(thread->data); + SDL_free(thread->data); } void SDL_SYS_KillThread(SDL_Thread *thread) diff --git a/src/thread/os2/SDL_syscond.c b/src/thread/os2/SDL_syscond.c index 0874b45cb..e4d5b697b 100644 --- a/src/thread/os2/SDL_syscond.c +++ b/src/thread/os2/SDL_syscond.c @@ -46,7 +46,7 @@ DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) malloc(sizeof(SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if ( cond ) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); @@ -75,7 +75,7 @@ DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond) if ( cond->lock ) { SDL_DestroyMutex(cond->lock); } - free(cond); + SDL_free(cond); } } diff --git a/src/thread/os2/SDL_sysmutex.c b/src/thread/os2/SDL_sysmutex.c index 642ceae20..aa53461ae 100644 --- a/src/thread/os2/SDL_sysmutex.c +++ b/src/thread/os2/SDL_sysmutex.c @@ -43,7 +43,7 @@ DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void) APIRET ulrc; /* Allocate mutex memory */ - mutex = (SDL_mutex *)malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if (mutex) { /* Create the mutex, with initial value signaled */ @@ -54,7 +54,7 @@ DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void) if (ulrc!=NO_ERROR) { SDL_SetError("Couldn't create mutex"); - free(mutex); + SDL_free(mutex); mutex = NULL; } } else { @@ -73,7 +73,7 @@ DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex) DosCloseMutexSem(mutex->hmtxID); mutex->hmtxID = 0; } - free(mutex); + SDL_free(mutex); } } diff --git a/src/thread/os2/SDL_syssem.c b/src/thread/os2/SDL_syssem.c index 2996296a8..8122dd7b3 100644 --- a/src/thread/os2/SDL_syssem.c +++ b/src/thread/os2/SDL_syssem.c @@ -48,13 +48,13 @@ DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value) ULONG ulrc; /* Allocate sem memory */ - sem = (SDL_sem *)malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if ( sem ) { /* Create the mutex semaphore */ ulrc = DosCreateMutexSem(NULL,&(sem->id),0,TRUE); if ( ulrc ) { SDL_SetError("Couldn't create semaphore"); - free(sem); + SDL_free(sem); sem = NULL; } else { @@ -77,7 +77,7 @@ DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem) DosCloseMutexSem(sem->id); sem->id = 0; } - free(sem); + SDL_free(sem); } } diff --git a/src/thread/os2/SDL_systhread.c b/src/thread/os2/SDL_systhread.c index 70b2429c7..4da82f1b5 100644 --- a/src/thread/os2/SDL_systhread.c +++ b/src/thread/os2/SDL_systhread.c @@ -51,7 +51,7 @@ static void threadfunc(void *pparm) if (pThreadParms) { pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; - free(pThreadParms); + SDL_free(pThreadParms); } // Call endthread! if (pfnCurrentEndThread) @@ -60,7 +60,7 @@ static void threadfunc(void *pparm) int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) { - pThreadStartParms pThreadParms = malloc(sizeof(tThreadStartParms)); + pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms)); if (!pThreadParms) { SDL_SetError("Not enough memory to create thread"); diff --git a/src/thread/pth/SDL_syscond.c b/src/thread/pth/SDL_syscond.c index a45ca0206..bb1d62b95 100644 --- a/src/thread/pth/SDL_syscond.c +++ b/src/thread/pth/SDL_syscond.c @@ -18,11 +18,11 @@ SDL_cond * SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) malloc(sizeof(SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if ( cond ) { if ( pth_cond_init(&(cond->condpth_p)) < 0 ) { SDL_SetError("pthread_cond_init() failed"); - free(cond); + SDL_free(cond); cond = NULL; } } else { @@ -35,7 +35,7 @@ SDL_cond * SDL_CreateCond(void) void SDL_DestroyCond(SDL_cond *cond) { if ( cond ) { - free(cond); + SDL_free(cond); } } diff --git a/src/thread/pth/SDL_sysmutex.c b/src/thread/pth/SDL_sysmutex.c index 7a56da4cd..d21e0926a 100644 --- a/src/thread/pth/SDL_sysmutex.c +++ b/src/thread/pth/SDL_sysmutex.c @@ -18,12 +18,12 @@ SDL_mutex *SDL_CreateMutex(void) SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *)malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if ( mutex ) { /* Create the mutex, with initial value signaled */ if (!pth_mutex_init(&(mutex->mutexpth_p))) { SDL_SetError("Couldn't create mutex"); - free(mutex); + SDL_free(mutex); mutex = NULL; } } else { @@ -36,7 +36,7 @@ SDL_mutex *SDL_CreateMutex(void) void SDL_DestroyMutex(SDL_mutex *mutex) { if ( mutex ) { - free(mutex); + SDL_free(mutex); } } diff --git a/src/thread/riscos/SDL_syscond.c b/src/thread/riscos/SDL_syscond.c index a465a72c0..bc39dd18d 100644 --- a/src/thread/riscos/SDL_syscond.c +++ b/src/thread/riscos/SDL_syscond.c @@ -45,11 +45,11 @@ SDL_cond * SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) malloc(sizeof(SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if ( cond ) { if ( pthread_cond_init(&cond->cond, NULL) < 0 ) { SDL_SetError("pthread_cond_init() failed"); - free(cond); + SDL_free(cond); cond = NULL; } } @@ -61,7 +61,7 @@ void SDL_DestroyCond(SDL_cond *cond) { if ( cond ) { pthread_cond_destroy(&cond->cond); - free(cond); + SDL_free(cond); } } diff --git a/src/thread/riscos/SDL_sysmutex.c b/src/thread/riscos/SDL_sysmutex.c index 2b2e33f5d..00589efe2 100644 --- a/src/thread/riscos/SDL_sysmutex.c +++ b/src/thread/riscos/SDL_sysmutex.c @@ -57,7 +57,7 @@ SDL_mutex *SDL_CreateMutex (void) #endif /* PTHREAD_NO_RECURSIVE_MUTEX */ if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) { SDL_SetError("pthread_mutex_init() failed"); - free(mutex); + SDL_free(mutex); mutex = NULL; } } else { @@ -70,7 +70,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) { if ( mutex ) { pthread_mutex_destroy(&mutex->id); - free(mutex); + SDL_free(mutex); } } diff --git a/src/thread/riscos/SDL_syssem.c b/src/thread/riscos/SDL_syssem.c index b93134386..7c8bd01d0 100644 --- a/src/thread/riscos/SDL_syssem.c +++ b/src/thread/riscos/SDL_syssem.c @@ -90,11 +90,11 @@ struct SDL_semaphore { /* Create a semaphore, initialized with 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_init(&sem->sem_data, 0, initial_value) < 0 ) { SDL_SetError("sem_init() failed"); - free(sem); + SDL_free(sem); sem = NULL; } else { sem->sem = &sem->sem_data; @@ -109,7 +109,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) { if ( sem ) { sem_destroy(sem->sem); - free(sem); + SDL_free(sem); } } diff --git a/src/thread/win32/SDL_sysmutex.c b/src/thread/win32/SDL_sysmutex.c index ec5929c37..13c357e23 100644 --- a/src/thread/win32/SDL_sysmutex.c +++ b/src/thread/win32/SDL_sysmutex.c @@ -39,13 +39,13 @@ SDL_mutex *SDL_CreateMutex(void) SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *)malloc(sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); if ( mutex ) { /* Create the mutex, with initial value signaled */ mutex->id = CreateMutex(NULL, FALSE, NULL); if ( ! mutex->id ) { SDL_SetError("Couldn't create mutex"); - free(mutex); + SDL_free(mutex); mutex = NULL; } } else { @@ -62,7 +62,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) CloseHandle(mutex->id); mutex->id = 0; } - free(mutex); + SDL_free(mutex); } } diff --git a/src/thread/win32/SDL_syssem.c b/src/thread/win32/SDL_syssem.c index 78e71fb53..ef42fae45 100644 --- a/src/thread/win32/SDL_syssem.c +++ b/src/thread/win32/SDL_syssem.c @@ -48,7 +48,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; /* Allocate sem memory */ - sem = (SDL_sem *)malloc(sizeof(*sem)); + sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); if ( sem ) { /* Create the semaphore, with max value 32K */ #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) @@ -59,7 +59,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) sem->count = initial_value; if ( ! sem->id ) { SDL_SetError("Couldn't create semaphore"); - free(sem); + SDL_free(sem); sem = NULL; } } else { @@ -80,7 +80,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) #endif sem->id = 0; } - free(sem); + SDL_free(sem); } } diff --git a/src/thread/win32/SDL_systhread.c b/src/thread/win32/SDL_systhread.c index b3e759d30..cb9bb478a 100644 --- a/src/thread/win32/SDL_systhread.c +++ b/src/thread/win32/SDL_systhread.c @@ -47,7 +47,7 @@ static unsigned __stdcall RunThread(void *data) if (pThreadParms) { pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; - free(pThreadParms); + SDL_free(pThreadParms); } // Call endthread! if (pfnCurrentEndThread) @@ -58,7 +58,7 @@ static unsigned __stdcall RunThread(void *data) int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) { unsigned threadid; - pThreadStartParms pThreadParms = (pThreadStartParms)malloc(sizeof(tThreadStartParms)); + pThreadStartParms pThreadParms = (pThreadStartParms)SDL_malloc(sizeof(tThreadStartParms)); if (!pThreadParms) { SDL_OutOfMemory(); return(-1); diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index de851ca11..debb028ef 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -148,7 +148,7 @@ void SDL_ThreadedTimerCheck(void) } else { SDL_timers = next; } - free(t); + SDL_free(t); --SDL_timer_running; removed = SDL_TRUE; } @@ -165,7 +165,7 @@ void SDL_ThreadedTimerCheck(void) static SDL_TimerID SDL_AddTimerInternal(Uint32 interval, SDL_NewTimerCallback callback, void *param) { SDL_TimerID t; - t = (SDL_TimerID) malloc(sizeof(struct _SDL_TimerID)); + t = (SDL_TimerID) SDL_malloc(sizeof(struct _SDL_TimerID)); if ( t ) { t->interval = ROUND_RESOLUTION(interval); t->cb = callback; @@ -218,7 +218,7 @@ SDL_bool SDL_RemoveTimer(SDL_TimerID id) } else { SDL_timers = t->next; } - free(t); + SDL_free(t); --SDL_timer_running; removed = SDL_TRUE; list_changed = SDL_TRUE; @@ -256,7 +256,7 @@ int SDL_SetTimer(Uint32 ms, SDL_TimerCallback callback) while ( SDL_timers ) { SDL_TimerID freeme = SDL_timers; SDL_timers = SDL_timers->next; - free(freeme); + SDL_free(freeme); } SDL_timer_running = 0; list_changed = SDL_TRUE; diff --git a/src/timer/linux/SDL_systimer.c b/src/timer/linux/SDL_systimer.c index d59937fab..8e0e258bc 100644 --- a/src/timer/linux/SDL_systimer.c +++ b/src/timer/linux/SDL_systimer.c @@ -256,7 +256,7 @@ int SDL_SYS_TimerInit(void) struct sigaction action; /* Set the alarm handler (Linux specific) */ - memset(&action, 0, sizeof(action)); + SDL_memset(&action, 0, sizeof(action)); action.sa_handler = HandleAlarm; action.sa_flags = SA_RESTART; sigemptyset(&action.sa_mask); @@ -285,7 +285,7 @@ void SDL_SYS_StopTimer(void) { struct itimerval timer; - memset(&timer, 0, (sizeof timer)); + SDL_memset(&timer, 0, (sizeof timer)); setitimer(ITIMER_REAL, &timer, NULL); } diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 1c336b526..91f70674e 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1467,7 +1467,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) } maxsize += sizeof(RLEDestFormat); - rlebuf = (Uint8 *)malloc(maxsize); + rlebuf = (Uint8 *)SDL_malloc(maxsize); if(!rlebuf) { SDL_OutOfMemory(); return -1; @@ -1597,13 +1597,13 @@ static int RLEAlphaSurface(SDL_Surface *surface) /* Now that we have it encoded, release the original pixels */ if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) { - free( surface->pixels ); + SDL_free( surface->pixels ); surface->pixels = NULL; } /* realloc the buffer to release unused memory */ { - Uint8 *p = realloc(rlebuf, dst - rlebuf); + Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); if(!p) p = rlebuf; surface->map->sw_data->aux_data = p; @@ -1675,7 +1675,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) break; } - rlebuf = (Uint8 *)malloc(maxsize); + rlebuf = (Uint8 *)SDL_malloc(maxsize); if ( rlebuf == NULL ) { SDL_OutOfMemory(); return(-1); @@ -1731,14 +1731,14 @@ static int RLEColorkeySurface(SDL_Surface *surface) } len = MIN(run, maxn); ADD_COUNTS(skip, len); - memcpy(dst, srcbuf + runstart * bpp, len * bpp); + SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp); dst += len * bpp; run -= len; runstart += len; while(run) { len = MIN(run, maxn); ADD_COUNTS(0, len); - memcpy(dst, srcbuf + runstart * bpp, len * bpp); + SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp); dst += len * bpp; runstart += len; run -= len; @@ -1757,14 +1757,14 @@ static int RLEColorkeySurface(SDL_Surface *surface) /* Now that we have it encoded, release the original pixels */ if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) { - free( surface->pixels ); + SDL_free( surface->pixels ); surface->pixels = NULL; } /* realloc the buffer to release unused memory */ { /* If realloc returns NULL, the original block is left intact */ - Uint8 *p = realloc(rlebuf, dst - rlebuf); + Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); if(!p) p = rlebuf; surface->map->sw_data->aux_data = p; @@ -1845,12 +1845,12 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) uncopy_opaque = uncopy_transl = uncopy_32; } - surface->pixels = malloc(surface->h * surface->pitch); + surface->pixels = SDL_malloc(surface->h * surface->pitch); if ( !surface->pixels ) { return(SDL_FALSE); } /* fill background with transparent pixels */ - memset(surface->pixels, 0, surface->h * surface->pitch); + SDL_memset(surface->pixels, 0, surface->h * surface->pitch); dst = surface->pixels; srcbuf = (Uint8 *)(df + 1); @@ -1909,7 +1909,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) unsigned alpha_flag; /* re-create the original surface */ - surface->pixels = malloc(surface->h * surface->pitch); + surface->pixels = SDL_malloc(surface->h * surface->pitch); if ( !surface->pixels ) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; @@ -1937,7 +1937,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) } if ( surface->map && surface->map->sw_data->aux_data ) { - free(surface->map->sw_data->aux_data); + SDL_free(surface->map->sw_data->aux_data); surface->map->sw_data->aux_data = NULL; } } diff --git a/src/video/SDL_blit_0.c b/src/video/SDL_blit_0.c index 5ea706ed1..fd2a0cdf2 100644 --- a/src/video/SDL_blit_0.c +++ b/src/video/SDL_blit_0.c @@ -297,7 +297,7 @@ static void BlitBto3Key(SDL_BlitInfo *info) } bit = (byte&0x80)>>7; if ( bit != ckey ) { - memcpy(dst, &palmap[bit*4], 3); + SDL_memcpy(dst, &palmap[bit*4], 3); } byte <<= 1; dst += 3; diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index ab1be008a..9903a7d58 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -817,10 +817,10 @@ static Uint32 GetBlitFeatures( void ) static Uint32 features = 0xffffffff; if (features == 0xffffffff) { /* Provide an override for testing .. */ - char *override = getenv("SDL_ALTIVEC_BLIT_FEATURES"); + char *override = SDL_getenv("SDL_ALTIVEC_BLIT_FEATURES"); if (override) { features = 0; - sscanf(override, "%u", &features); + SDL_sscanf(override, "%u", &features); } else { features = ( 0 /* Feature 1 is has-MMX */ diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index e5f87d090..89abb3111 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -98,7 +98,7 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc) was_error = 1; goto done; } - if ( strncmp(magic, "BM", 2) != 0 ) { + if ( SDL_strncmp(magic, "BM", 2) != 0 ) { SDL_SetError("File is not a Windows BMP file"); was_error = 1; goto done; @@ -135,7 +135,7 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc) } /* Check for read error */ - if ( strcmp(SDL_GetError(), "") != 0 ) { + if ( SDL_strcmp(SDL_GetError(), "") != 0 ) { was_error = 1; goto done; } @@ -519,7 +519,7 @@ int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst) if ( freedst && dst ) { SDL_RWclose(dst); } - return((strcmp(SDL_GetError(), "") == 0) ? 0 : -1); + return((SDL_strcmp(SDL_GetError(), "") == 0) ? 0 : -1); } #endif /* ENABLE_FILE */ diff --git a/src/video/SDL_cursor.c b/src/video/SDL_cursor.c index d4adea2f8..906e9a90d 100644 --- a/src/video/SDL_cursor.c +++ b/src/video/SDL_cursor.c @@ -125,7 +125,7 @@ SDL_Cursor * SDL_CreateCursor (Uint8 *data, Uint8 *mask, } /* Allocate memory for the cursor */ - cursor = (SDL_Cursor *)malloc(sizeof *cursor); + cursor = (SDL_Cursor *)SDL_malloc(sizeof *cursor); if ( cursor == NULL ) { SDL_OutOfMemory(); return(NULL); @@ -137,9 +137,9 @@ SDL_Cursor * SDL_CreateCursor (Uint8 *data, Uint8 *mask, cursor->area.h = h; cursor->hot_x = hot_x; cursor->hot_y = hot_y; - cursor->data = (Uint8 *)malloc((w/8)*h*2); + cursor->data = (Uint8 *)SDL_malloc((w/8)*h*2); cursor->mask = cursor->data+((w/8)*h); - cursor->save[0] = (Uint8 *)malloc(savelen*2); + cursor->save[0] = (Uint8 *)SDL_malloc(savelen*2); cursor->save[1] = cursor->save[0] + savelen; cursor->wm_cursor = NULL; if ( ! cursor->data || ! cursor->save[0] ) { @@ -151,7 +151,7 @@ SDL_Cursor * SDL_CreateCursor (Uint8 *data, Uint8 *mask, cursor->data[i] = data[i]; cursor->mask[i] = mask[i] | data[i]; } - memset(cursor->save[0], 0, savelen*2); + SDL_memset(cursor->save[0], 0, savelen*2); /* If the window manager gives us a good cursor, we're done! */ if ( video->CreateWMCursor ) { @@ -244,15 +244,15 @@ void SDL_FreeCursor (SDL_Cursor *cursor) SDL_VideoDevice *this = current_video; if ( cursor->data ) { - free(cursor->data); + SDL_free(cursor->data); } if ( cursor->save[0] ) { - free(cursor->save[0]); + SDL_free(cursor->save[0]); } if ( video && cursor->wm_cursor ) { video->FreeWMCursor(this, cursor->wm_cursor); } - free(cursor); + SDL_free(cursor); } } } @@ -448,7 +448,7 @@ static void SDL_DrawCursorFast(SDL_Surface *screen, SDL_Rect *area) datab = *data++; for ( i=0; i<8; ++i ) { if ( maskb & 0x80 ) { - memset(dst,pixels[datab>>7],3); + SDL_memset(dst,pixels[datab>>7],3); } maskb <<= 1; datab <<= 1; @@ -523,7 +523,7 @@ static void SDL_DrawCursorSlow(SDL_Surface *screen, SDL_Rect *area) } if ( (x >= minx) && (x < maxx) ) { if ( maskb & 0x80 ) { - memset(dst, pixels8[datab>>7], dstbpp); + SDL_memset(dst, pixels8[datab>>7], dstbpp); } } maskb <<= 1; @@ -541,7 +541,7 @@ static void SDL_DrawCursorSlow(SDL_Surface *screen, SDL_Rect *area) } if ( (x >= minx) && (x < maxx) ) { if ( maskb & 0x80 ) { - memset(dst, pixels[datab>>7], dstbpp); + SDL_memset(dst, pixels[datab>>7], dstbpp); } } maskb <<= 1; @@ -616,7 +616,7 @@ void SDL_DrawCursorNoLock(SDL_Surface *screen) w = area.w*screenbpp; h = area.h; while ( h-- ) { - memcpy(dst, src, w); + SDL_memcpy(dst, src, w); dst += w; src += screen->pitch; } @@ -694,7 +694,7 @@ void SDL_EraseCursorNoLock(SDL_Surface *screen) w = area.w*screenbpp; h = area.h; while ( h-- ) { - memcpy(dst, src, w); + SDL_memcpy(dst, src, w); src += w; dst += screen->pitch; } @@ -748,6 +748,6 @@ void SDL_ResetCursor(void) savelen = SDL_cursor->area.w*4*SDL_cursor->area.h; SDL_cursor->area.x = 0; SDL_cursor->area.y = 0; - memset(SDL_cursor->save[0], 0, savelen); + SDL_memset(SDL_cursor->save[0], 0, savelen); } } diff --git a/src/video/SDL_gamma.c b/src/video/SDL_gamma.c index 14c4d8b93..6e794b105 100644 --- a/src/video/SDL_gamma.c +++ b/src/video/SDL_gamma.c @@ -165,13 +165,13 @@ int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue) /* Fill the gamma table with the new values */ if ( red ) { - memcpy(&video->gamma[0*256], red, 256*sizeof(*video->gamma)); + SDL_memcpy(&video->gamma[0*256], red, 256*sizeof(*video->gamma)); } if ( green ) { - memcpy(&video->gamma[1*256], green, 256*sizeof(*video->gamma)); + SDL_memcpy(&video->gamma[1*256], green, 256*sizeof(*video->gamma)); } if ( blue ) { - memcpy(&video->gamma[2*256], blue, 256*sizeof(*video->gamma)); + SDL_memcpy(&video->gamma[2*256], blue, 256*sizeof(*video->gamma)); } /* Gamma correction always possible on split palettes */ @@ -204,7 +204,7 @@ int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue) /* Lazily allocate the gamma table */ if ( ! video->gamma ) { - video->gamma = malloc(3*256*sizeof(*video->gamma)); + video->gamma = SDL_malloc(3*256*sizeof(*video->gamma)); if ( ! video->gamma ) { SDL_OutOfMemory(); return -1; @@ -225,13 +225,13 @@ int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue) /* Just copy from our internal table */ if ( red ) { - memcpy(red, &video->gamma[0*256], 256*sizeof(*red)); + SDL_memcpy(red, &video->gamma[0*256], 256*sizeof(*red)); } if ( green ) { - memcpy(green, &video->gamma[1*256], 256*sizeof(*green)); + SDL_memcpy(green, &video->gamma[1*256], 256*sizeof(*green)); } if ( blue ) { - memcpy(blue, &video->gamma[2*256], 256*sizeof(*blue)); + SDL_memcpy(blue, &video->gamma[2*256], 256*sizeof(*blue)); } return 0; } diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 1423a290d..81256dcbd 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -43,12 +43,12 @@ SDL_PixelFormat *SDL_AllocFormat(int bpp, Uint32 mask; /* Allocate an empty pixel format structure */ - format = malloc(sizeof(*format)); + format = SDL_malloc(sizeof(*format)); if ( format == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(format, 0, sizeof(*format)); + SDL_memset(format, 0, sizeof(*format)); format->alpha = SDL_ALPHA_OPAQUE; /* Set up the format */ @@ -125,14 +125,14 @@ SDL_PixelFormat *SDL_AllocFormat(int bpp, #ifdef DEBUG_PALETTE fprintf(stderr,"bpp=%d ncolors=%d\n",bpp,ncolors); #endif - format->palette = (SDL_Palette *)malloc(sizeof(SDL_Palette)); + format->palette = (SDL_Palette *)SDL_malloc(sizeof(SDL_Palette)); if ( format->palette == NULL ) { SDL_FreeFormat(format); SDL_OutOfMemory(); return(NULL); } (format->palette)->ncolors = ncolors; - (format->palette)->colors = (SDL_Color *)malloc( + (format->palette)->colors = (SDL_Color *)SDL_malloc( (format->palette)->ncolors*sizeof(SDL_Color)); if ( (format->palette)->colors == NULL ) { SDL_FreeFormat(format); @@ -217,7 +217,7 @@ SDL_PixelFormat *SDL_AllocFormat(int bpp, format->palette->colors[1].b = 0x00; } else { /* Create an empty palette */ - memset((format->palette)->colors, 0, + SDL_memset((format->palette)->colors, 0, (format->palette)->ncolors*sizeof(SDL_Color)); } } @@ -255,11 +255,11 @@ void SDL_FreeFormat(SDL_PixelFormat *format) if ( format ) { if ( format->palette ) { if ( format->palette->colors ) { - free(format->palette->colors); + SDL_free(format->palette->colors); } - free(format->palette); + SDL_free(format->palette); } - free(format); + SDL_free(format); } } /* @@ -438,7 +438,7 @@ static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical) if ( identical ) { if ( src->ncolors <= dst->ncolors ) { /* If an identical palette, no need to map */ - if ( memcmp(src->colors, dst->colors, src->ncolors* + if ( SDL_memcmp(src->colors, dst->colors, src->ncolors* sizeof(SDL_Color)) == 0 ) { *identical = 1; return(NULL); @@ -446,7 +446,7 @@ static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical) } *identical = 0; } - map = (Uint8 *)malloc(src->ncolors); + map = (Uint8 *)SDL_malloc(src->ncolors); if ( map == NULL ) { SDL_OutOfMemory(); return(NULL); @@ -466,7 +466,7 @@ static Uint8 *Map1toN(SDL_Palette *src, SDL_PixelFormat *dst) unsigned alpha; bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); - map = (Uint8 *)malloc(src->ncolors*bpp); + map = (Uint8 *)SDL_malloc(src->ncolors*bpp); if ( map == NULL ) { SDL_OutOfMemory(); return(NULL); @@ -490,7 +490,7 @@ static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_Palette *dst, int *identical) /* SDL_DitherColors does not initialize the 'unused' component of colors, but Map1to1 compares it against dst, so we should initialize it. */ - memset(colors, 0, sizeof(colors)); + SDL_memset(colors, 0, sizeof(colors)); dithered.ncolors = 256; SDL_DitherColors(colors, 8); @@ -503,21 +503,21 @@ SDL_BlitMap *SDL_AllocBlitMap(void) SDL_BlitMap *map; /* Allocate the empty map */ - map = (SDL_BlitMap *)malloc(sizeof(*map)); + map = (SDL_BlitMap *)SDL_malloc(sizeof(*map)); if ( map == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(map, 0, sizeof(*map)); + SDL_memset(map, 0, sizeof(*map)); /* Allocate the software blit data */ - map->sw_data = (struct private_swaccel *)malloc(sizeof(*map->sw_data)); + map->sw_data = (struct private_swaccel *)SDL_malloc(sizeof(*map->sw_data)); if ( map->sw_data == NULL ) { SDL_FreeBlitMap(map); SDL_OutOfMemory(); return(NULL); } - memset(map->sw_data, 0, sizeof(*map->sw_data)); + SDL_memset(map->sw_data, 0, sizeof(*map->sw_data)); /* It's ready to go */ return(map); @@ -530,7 +530,7 @@ void SDL_InvalidateMap(SDL_BlitMap *map) map->dst = NULL; map->format_version = (unsigned int)-1; if ( map->table ) { - free(map->table); + SDL_free(map->table); map->table = NULL; } } @@ -615,8 +615,8 @@ void SDL_FreeBlitMap(SDL_BlitMap *map) if ( map ) { SDL_InvalidateMap(map); if ( map->sw_data != NULL ) { - free(map->sw_data); + SDL_free(map->sw_data); } - free(map); + SDL_free(map); } } diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index dc103228e..bf900ca30 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -77,7 +77,7 @@ SDL_Surface * SDL_CreateRGBSurface (Uint32 flags, } /* Allocate the surface */ - surface = (SDL_Surface *)malloc(sizeof(*surface)); + surface = (SDL_Surface *)SDL_malloc(sizeof(*surface)); if ( surface == NULL ) { SDL_OutOfMemory(); return(NULL); @@ -103,7 +103,7 @@ SDL_Surface * SDL_CreateRGBSurface (Uint32 flags, } surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); if ( surface->format == NULL ) { - free(surface); + SDL_free(surface); return(NULL); } if ( Amask ) { @@ -125,14 +125,14 @@ SDL_Surface * SDL_CreateRGBSurface (Uint32 flags, if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) || (video->AllocHWSurface(this, surface) < 0) ) { if ( surface->w && surface->h ) { - surface->pixels = malloc(surface->h*surface->pitch); + surface->pixels = SDL_malloc(surface->h*surface->pitch); if ( surface->pixels == NULL ) { SDL_FreeSurface(surface); SDL_OutOfMemory(); return(NULL); } /* This is important for bitmaps */ - memset(surface->pixels, 0, surface->h*surface->pitch); + SDL_memset(surface->pixels, 0, surface->h*surface->pitch); } } @@ -615,7 +615,7 @@ int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) } else { #ifdef __powerpc__ /* - * memset() on PPC (both glibc and codewarrior) uses + * SDL_memset() on PPC (both glibc and codewarrior) uses * the dcbz (Data Cache Block Zero) instruction, which * causes an alignment exception if the destination is * uncachable, so only use it on software surfaces @@ -627,7 +627,7 @@ int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) * efficient to uncached video memory */ double fill; - memset(&fill, color, (sizeof fill)); + SDL_memset(&fill, color, (sizeof fill)); for(y = dstrect->h; y; y--) { Uint8 *d = row; unsigned n = x; @@ -679,7 +679,7 @@ int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) #endif /* __powerpc__ */ { for(y = dstrect->h; y; y--) { - memset(row, color, x); + SDL_memset(row, color, x); row += dst->pitch; } } @@ -711,7 +711,7 @@ int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) for ( y=dstrect->h; y; --y ) { Uint8 *pixels = row; for ( x=dstrect->w; x; --x ) { - memcpy(pixels, &color, 3); + SDL_memcpy(pixels, &color, 3); pixels += 3; } row += dst->pitch; @@ -832,7 +832,7 @@ SDL_Surface * SDL_ConvertSurface (SDL_Surface *surface, /* Copy the palette if any */ if ( format->palette && convert->format->palette ) { - memcpy(convert->format->palette->colors, + SDL_memcpy(convert->format->palette->colors, format->palette->colors, format->palette->ncolors*sizeof(SDL_Color)); convert->format->palette->ncolors = format->palette->ncolors; @@ -934,9 +934,9 @@ void SDL_FreeSurface (SDL_Surface *surface) } if ( surface->pixels && ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) { - free(surface->pixels); + SDL_free(surface->pixels); } - free(surface); + SDL_free(surface); #ifdef CHECK_LEAKS --surfaces_allocated; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index ad328eefb..8aaf8fbd8 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -175,13 +175,13 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) video = NULL; if ( driver_name != NULL ) { #if 0 /* This will be replaced with a better driver selection API */ - if ( strrchr(driver_name, ':') != NULL ) { - index = atoi(strrchr(driver_name, ':')+1); + if ( SDL_strrchr(driver_name, ':') != NULL ) { + index = atoi(SDL_strrchr(driver_name, ':')+1); } #endif for ( i=0; bootstrap[i]; ++i ) { - if ( strncmp(bootstrap[i]->name, driver_name, - strlen(bootstrap[i]->name)) == 0 ) { + if ( SDL_strncmp(bootstrap[i]->name, driver_name, + SDL_strlen(bootstrap[i]->name)) == 0 ) { if ( bootstrap[i]->available() ) { video = bootstrap[i]->create(index); break; @@ -216,7 +216,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) video->wm_icon = NULL; video->offset_x = 0; video->offset_y = 0; - memset(&video->info, 0, (sizeof video->info)); + SDL_memset(&video->info, 0, (sizeof video->info)); video->displayformatalphapixel = NULL; @@ -244,7 +244,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) video->gl_config.multisamplesamples = 0; /* Initialize the video subsystem */ - memset(&vformat, 0, sizeof(vformat)); + SDL_memset(&vformat, 0, sizeof(vformat)); if ( video->VideoInit(video, &vformat) < 0 ) { SDL_VideoQuit(); return(-1); @@ -289,7 +289,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) char *SDL_VideoDriverName(char *namebuf, int maxlen) { if ( current_video != NULL ) { - strncpy(namebuf, current_video->name, maxlen-1); + SDL_strncpy(namebuf, current_video->name, maxlen-1); namebuf[maxlen-1] = '\0'; return(namebuf); } @@ -389,7 +389,7 @@ int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) } /* Search through the list valid of modes */ - memset(&format, 0, sizeof(format)); + SDL_memset(&format, 0, sizeof(format)); supported = 0; table = ((bpp+7)/8)-1; SDL_closest_depths[table][0] = bpp; @@ -461,7 +461,7 @@ static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags) } /* No exact size match at any depth, look for closest match */ - memset(&format, 0, sizeof(format)); + SDL_memset(&format, 0, sizeof(format)); supported = 0; table = ((*BitsPerPixel+7)/8)-1; SDL_closest_depths[table][0] = *BitsPerPixel; @@ -541,7 +541,7 @@ static void SDL_CreateShadowSurface(int depth) if ( SDL_ShadowSurface->format->palette ) { SDL_ShadowSurface->flags |= SDL_HWPALETTE; if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) { - memcpy(SDL_ShadowSurface->format->palette->colors, + SDL_memcpy(SDL_ShadowSurface->format->palette->colors, SDL_VideoSurface->format->palette->colors, SDL_VideoSurface->format->palette->ncolors* sizeof(SDL_Color)); @@ -649,12 +649,12 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) SDL_FreeSurface(ready_to_go); } if ( video->physpal ) { - free(video->physpal->colors); - free(video->physpal); + SDL_free(video->physpal->colors); + SDL_free(video->physpal); video->physpal = NULL; } if( video->gammacols) { - free(video->gammacols); + SDL_free(video->gammacols); video->gammacols = NULL; } @@ -797,7 +797,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) support the GL_UNSIGNED_SHORT_5_6_5 texture format. */ if ( (bpp == 16) && - (strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") || + (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") || (atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f)) ) { video->is_32bit = 0; @@ -843,7 +843,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) SDL_FreeSurface(mode); /* Set the surface completely opaque & white by default */ - memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch ); + SDL_memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch ); video->glGenTextures( 1, &video->texture ); video->glBindTexture( GL_TEXTURE_2D, video->texture ); video->glTexImage2D( @@ -1134,7 +1134,7 @@ static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, SDL_Palette *vidpal; if ( colors != (pal->colors + firstcolor) ) { - memcpy(pal->colors + firstcolor, colors, + SDL_memcpy(pal->colors + firstcolor, colors, ncolors * sizeof(*colors)); } @@ -1146,7 +1146,7 @@ static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, * changes to its logical palette so that * updates are always identity blits */ - memcpy(vidpal->colors + firstcolor, colors, + SDL_memcpy(vidpal->colors + firstcolor, colors, ncolors * sizeof(*colors)); } SDL_FormatChanged(screen); @@ -1162,7 +1162,7 @@ static int SetPalette_physical(SDL_Surface *screen, /* We need to copy the new colors, since we haven't * already done the copy in the logical set above. */ - memcpy(video->physpal->colors + firstcolor, + SDL_memcpy(video->physpal->colors + firstcolor, colors, ncolors * sizeof(*colors)); } if ( screen == SDL_ShadowSurface ) { @@ -1187,7 +1187,7 @@ static int SetPalette_physical(SDL_Surface *screen, SDL_Palette *pp = video->physpal; if(!pp) pp = screen->format->palette; - video->gammacols = malloc(pp->ncolors + video->gammacols = SDL_malloc(pp->ncolors * sizeof(SDL_Color)); SDL_ApplyGamma(video->gamma, pp->colors, @@ -1284,18 +1284,18 @@ int SDL_SetPalette(SDL_Surface *screen, int which, if(!video->physpal && !(which & SDL_LOGPAL) ) { /* Lazy physical palette allocation */ int size; - SDL_Palette *pp = malloc(sizeof(*pp)); + SDL_Palette *pp = SDL_malloc(sizeof(*pp)); if ( !pp ) { return 0; } current_video->physpal = pp; pp->ncolors = pal->ncolors; size = pp->ncolors * sizeof(SDL_Color); - pp->colors = malloc(size); + pp->colors = SDL_malloc(size); if ( !pp->colors ) { return 0; } - memcpy(pp->colors, pal->colors, size); + SDL_memcpy(pp->colors, pal->colors, size); } if ( ! SetPalette_physical(screen, colors, firstcolor, ncolors) ) { @@ -1351,24 +1351,24 @@ void SDL_VideoQuit (void) /* Clean up miscellaneous memory */ if ( video->physpal ) { - free(video->physpal->colors); - free(video->physpal); + SDL_free(video->physpal->colors); + SDL_free(video->physpal); video->physpal = NULL; } if ( video->gammacols ) { - free(video->gammacols); + SDL_free(video->gammacols); video->gammacols = NULL; } if ( video->gamma ) { - free(video->gamma); + SDL_free(video->gamma); video->gamma = NULL; } if ( video->wm_title != NULL ) { - free(video->wm_title); + SDL_free(video->wm_title); video->wm_title = NULL; } if ( video->wm_icon != NULL ) { - free(video->wm_icon); + SDL_free(video->wm_icon); video->wm_icon = NULL; } @@ -1668,20 +1668,20 @@ void SDL_WM_SetCaption (const char *title, const char *icon) if ( video ) { if ( title ) { if ( video->wm_title ) { - free(video->wm_title); + SDL_free(video->wm_title); } - video->wm_title = (char *)malloc(strlen(title)+1); + video->wm_title = (char *)SDL_malloc(SDL_strlen(title)+1); if ( video->wm_title != NULL ) { - strcpy(video->wm_title, title); + SDL_strcpy(video->wm_title, title); } } if ( icon ) { if ( video->wm_icon ) { - free(video->wm_icon); + SDL_free(video->wm_icon); } - video->wm_icon = (char *)malloc(strlen(icon)+1); + video->wm_icon = (char *)SDL_malloc(SDL_strlen(icon)+1); if ( video->wm_icon != NULL ) { - strcpy(video->wm_icon, icon); + SDL_strcpy(video->wm_icon, icon); } } if ( (title || icon) && (video->SetCaption != NULL) ) { @@ -1773,18 +1773,18 @@ void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask) if ( mask == NULL ) { int mask_len = icon->h*(icon->w+7)/8; int flags = 0; - mask = (Uint8 *)malloc(mask_len); + mask = (Uint8 *)SDL_malloc(mask_len); if ( mask == NULL ) { return; } - memset(mask, ~0, mask_len); + SDL_memset(mask, ~0, mask_len); if ( icon->flags & SDL_SRCCOLORKEY ) flags |= 1; if ( icon->flags & SDL_SRCALPHA ) flags |= 2; if( flags ) { CreateMaskFromColorKeyOrAlpha(icon, mask, flags); } video->SetIcon(video, icon, mask); - free(mask); + SDL_free(mask); } else { video->SetIcon(this, icon, mask); } diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index da961f788..804f155c3 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -44,7 +44,7 @@ SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format, } /* Display directly on video surface, if possible */ - if ( getenv("SDL_VIDEO_YUV_DIRECT") ) { + if ( SDL_getenv("SDL_VIDEO_YUV_DIRECT") ) { if ( (display == SDL_PublicSurface) && ((SDL_VideoSurface->format->BytesPerPixel == 2) || (SDL_VideoSurface->format->BytesPerPixel == 4)) ) { @@ -52,7 +52,7 @@ SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format, } } overlay = NULL; - yuv_hwaccel = getenv("SDL_VIDEO_YUV_HWACCEL"); + yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL"); if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) && (!yuv_hwaccel || (*yuv_hwaccel != '0')) ) { overlay = video->CreateYUVOverlay(this, w, h, format, display); @@ -85,6 +85,6 @@ void SDL_FreeYUVOverlay(SDL_Overlay *overlay) if ( overlay->hwfuncs ) { overlay->hwfuncs->FreeHW(current_video, overlay); } - free(overlay); + SDL_free(overlay); } } diff --git a/src/video/SDL_yuv_sw.c b/src/video/SDL_yuv_sw.c index d59edc88e..a61c98cd0 100644 --- a/src/video/SDL_yuv_sw.c +++ b/src/video/SDL_yuv_sw.c @@ -960,12 +960,12 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S } /* Create the overlay structure */ - overlay = (SDL_Overlay *)malloc(sizeof *overlay); + overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); if ( overlay == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -976,7 +976,7 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S overlay->hwfuncs = &sw_yuvfuncs; /* Create the pixel data and lookup tables */ - swdata = (struct private_yuvhwdata *)malloc(sizeof *swdata); + swdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *swdata); overlay->hwdata = swdata; if ( swdata == NULL ) { SDL_OutOfMemory(); @@ -985,13 +985,13 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S } swdata->stretch = NULL; swdata->display = display; - swdata->pixels = (Uint8 *) malloc(width*height*2); - swdata->colortab = (int *)malloc(4*256*sizeof(int)); + swdata->pixels = (Uint8 *) SDL_malloc(width*height*2); + swdata->colortab = (int *)SDL_malloc(4*256*sizeof(int)); Cr_r_tab = &swdata->colortab[0*256]; Cr_g_tab = &swdata->colortab[1*256]; Cb_g_tab = &swdata->colortab[2*256]; Cb_b_tab = &swdata->colortab[3*256]; - swdata->rgb_2_pix = (Uint32 *)malloc(3*768*sizeof(Uint32)); + swdata->rgb_2_pix = (Uint32 *)SDL_malloc(3*768*sizeof(Uint32)); r_2_pix_alloc = &swdata->rgb_2_pix[0*768]; g_2_pix_alloc = &swdata->rgb_2_pix[1*768]; b_2_pix_alloc = &swdata->rgb_2_pix[2*768]; @@ -1279,14 +1279,14 @@ void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay) SDL_FreeSurface(swdata->stretch); } if ( swdata->pixels ) { - free(swdata->pixels); + SDL_free(swdata->pixels); } if ( swdata->colortab ) { - free(swdata->colortab); + SDL_free(swdata->colortab); } if ( swdata->rgb_2_pix ) { - free(swdata->rgb_2_pix); + SDL_free(swdata->rgb_2_pix); } - free(swdata); + SDL_free(swdata); } } diff --git a/src/video/Xext/Xv/Xv.c b/src/video/Xext/Xv/Xv.c index 7fc6c0138..8dfb612a8 100644 --- a/src/video/Xext/Xv/Xv.c +++ b/src/video/Xext/Xv/Xv.c @@ -234,7 +234,7 @@ SDL_NAME(XvQueryAdaptors)( SyncHandle(); return(XvBadAlloc); } - (void)strncpy(name, u.string, size); + (void)SDL_strncpy(name, u.string, size); name[size] = '\0'; pa->name = name; @@ -386,7 +386,7 @@ SDL_NAME(XvQueryEncodings)( SyncHandle(); return(XvBadAlloc); } - strncpy(name, u.string, size); + SDL_strncpy(name, u.string, size); name[size] = '\0'; pe->name = name; pe++; @@ -902,7 +902,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( ret[i].id = Info.id; ret[i].type = Info.type; ret[i].byte_order = Info.byte_order; - memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); + SDL_memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); ret[i].bits_per_pixel = Info.bpp; ret[i].format = Info.format; ret[i].num_planes = Info.num_planes; @@ -919,7 +919,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( ret[i].vert_y_period = Info.vert_y_period; ret[i].vert_u_period = Info.vert_u_period; ret[i].vert_v_period = Info.vert_v_period; - memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32); + SDL_memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32); ret[i].scanline_order = Info.scanline_order; (*num)++; } diff --git a/src/video/Xext/Xxf86dga/XF86DGA.c b/src/video/Xext/Xxf86dga/XF86DGA.c index 926ddf6b9..33d746814 100644 --- a/src/video/Xext/Xxf86dga/XF86DGA.c +++ b/src/video/Xext/Xxf86dga/XF86DGA.c @@ -407,12 +407,12 @@ AddMap(void) MapPtr *old; old = mapList; - mapList = realloc(mapList, sizeof(MapPtr) * (numMaps + 1)); + mapList = SDL_realloc(mapList, sizeof(MapPtr) * (numMaps + 1)); if (!mapList) { mapList = old; return NULL; } - mapList[numMaps] = malloc(sizeof(MapRec)); + mapList[numMaps] = SDL_malloc(sizeof(MapRec)); if (!mapList[numMaps]) return NULL; return mapList[numMaps++]; @@ -424,12 +424,12 @@ AddScr(void) ScrPtr *old; old = scrList; - scrList = realloc(scrList, sizeof(ScrPtr) * (numScrs + 1)); + scrList = SDL_realloc(scrList, sizeof(ScrPtr) * (numScrs + 1)); if (!scrList) { scrList = old; return NULL; } - scrList[numScrs] = malloc(sizeof(ScrRec)); + scrList[numScrs] = SDL_malloc(sizeof(ScrRec)); if (!scrList[numScrs]) return NULL; return scrList[numScrs++]; diff --git a/src/video/aalib/SDL_aavideo.c b/src/video/aalib/SDL_aavideo.c index b2cd24e69..98c760ea0 100644 --- a/src/video/aalib/SDL_aavideo.c +++ b/src/video/aalib/SDL_aavideo.c @@ -70,8 +70,8 @@ static int AA_Available(void) static void AA_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *AA_CreateDevice(int devindex) @@ -79,20 +79,20 @@ static SDL_VideoDevice *AA_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = AA_VideoInit; @@ -138,7 +138,7 @@ int AA_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Initialize all variables that we clean on shutdown */ for ( i=0; ix = SDL_modelist[i]->y = 0; } /* Modes sorted largest to smallest */ @@ -179,7 +179,7 @@ int AA_VideoInit(_THIS, SDL_PixelFormat *vformat) fprintf(stderr,"Using AAlib driver: %s (%s)\n", AA_context->driver->name, AA_context->driver->shortname); - AA_in_x11 = (strcmp(AA_context->driver->shortname,"X11") == 0); + AA_in_x11 = (SDL_strcmp(AA_context->driver->shortname,"X11") == 0); /* Determine the screen depth (use default 8-bit depth) */ vformat->BitsPerPixel = 8; vformat->BytesPerPixel = 1; @@ -252,10 +252,10 @@ SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, int mode; if ( AA_buffer ) { - free( AA_buffer ); + SDL_free( AA_buffer ); } - AA_buffer = malloc(width * height); + AA_buffer = SDL_malloc(width * height); if ( ! AA_buffer ) { SDL_SetError("Couldn't allocate buffer for requested mode"); return(NULL); @@ -263,8 +263,8 @@ SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, /* printf("Setting mode %dx%d\n", width, height); */ - memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context)); - memset(AA_buffer, 0, width * height); + SDL_memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context)); + SDL_memset(AA_buffer, 0, width * height); /* Allocate the new pixel format for the screen */ if ( ! SDL_ReallocFormat(current, 8, 0, 0, 0, 0) ) { @@ -379,7 +379,7 @@ void AA_VideoQuit(_THIS) /* Free video mode lists */ for ( i=0; iInitOSKeymap=AtariIkbd_InitOSKeymap; this->PumpEvents=AtariIkbd_PumpEvents; Atari_ShutdownEvents=AtariIkbd_ShutdownEvents; } - if (strcmp(envr, "gemdos") == 0) { + if (SDL_strcmp(envr, "gemdos") == 0) { this->InitOSKeymap=AtariGemdos_InitOSKeymap; this->PumpEvents=AtariGemdos_PumpEvents; Atari_ShutdownEvents=AtariGemdos_ShutdownEvents; } - if (strcmp(envr, "bios") == 0) { + if (SDL_strcmp(envr, "bios") == 0) { this->InitOSKeymap=AtariBios_InitOSKeymap; this->PumpEvents=AtariBios_PumpEvents; Atari_ShutdownEvents=AtariBios_ShutdownEvents; diff --git a/src/video/ataricommon/SDL_atarigl.c b/src/video/ataricommon/SDL_atarigl.c index fb8b56885..7025960a7 100644 --- a/src/video/ataricommon/SDL_atarigl.c +++ b/src/video/ataricommon/SDL_atarigl.c @@ -141,7 +141,7 @@ int SDL_AtariGL_LoadLibrary(_THIS, const char *path) handle = SDL_LoadObject(path); if (handle == NULL) { /* Try to load another one */ - path = getenv("SDL_VIDEO_GL_DRIVER"); + path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); if ( path != NULL ) { handle = SDL_LoadObject(path); } @@ -223,10 +223,10 @@ int SDL_AtariGL_LoadLibrary(_THIS, const char *path) this->gl_config.dll_handle = handle; if ( path ) { - strncpy(this->gl_config.driver_path, path, + SDL_strncpy(this->gl_config.driver_path, path, sizeof(this->gl_config.driver_path)-1); } else { - strcpy(this->gl_config.driver_path, ""); + SDL_strcpy(this->gl_config.driver_path, ""); } #endif @@ -697,7 +697,7 @@ static void CopyShadowDirect(_THIS, SDL_Surface *surface) } for (y=0; yh; y++) { - memcpy(dstline, srcline, srcpitch); + SDL_memcpy(dstline, srcline, srcpitch); srcline += srcpitch; dstline += dstpitch; diff --git a/src/video/ataricommon/SDL_biosevents.c b/src/video/ataricommon/SDL_biosevents.c index 14ee653a7..7557dcee8 100644 --- a/src/video/ataricommon/SDL_biosevents.c +++ b/src/video/ataricommon/SDL_biosevents.c @@ -70,8 +70,8 @@ void AtariBios_InitOSKeymap(_THIS) int i, vectors_mask; unsigned long dummy; - memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard)); - memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard)); + SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard)); + SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard)); /* Initialize keymap */ for ( i=0; i 127) { state = 0; - srclen = strlen(buf); + srclen = SDL_strlen(buf); dstlen = sizeof(destbuf); convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, (char *)destbuf, &dstlen, &state); unicode = destbuf[0]; diff --git a/src/video/bwindow/SDL_sysmouse.cc b/src/video/bwindow/SDL_sysmouse.cc index 07fcbc3ed..56540c4a2 100644 --- a/src/video/bwindow/SDL_sysmouse.cc +++ b/src/video/bwindow/SDL_sysmouse.cc @@ -60,14 +60,14 @@ WMcursor *BE_CreateWMCursor(_THIS, } /* Allocate the cursor */ - cursor = (WMcursor *)malloc(sizeof(WMcursor)); + cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); if ( cursor == NULL ) { SDL_OutOfMemory(); return(NULL); } - cursor->bits = (char *)malloc(4+2*((allowed_x/8)*allowed_y)); + cursor->bits = (char *)SDL_malloc(4+2*((allowed_x/8)*allowed_y)); if ( cursor->bits == NULL ) { - free(cursor); + SDL_free(cursor); SDL_OutOfMemory(); return(NULL); } @@ -81,13 +81,13 @@ WMcursor *BE_CreateWMCursor(_THIS, run = PADDED_BITS(w); pad = PADDED_BITS(allowed_x)-run; for ( i=0; ibits); - free(cursor); + SDL_free(cursor->bits); + SDL_free(cursor); } /* Implementation by Christian Bauer */ diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc index 90c4aeae5..77e5e3c4c 100644 --- a/src/video/bwindow/SDL_sysvideo.cc +++ b/src/video/bwindow/SDL_sysvideo.cc @@ -82,8 +82,8 @@ static int BE_Available(void) static void BE_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *BE_CreateDevice(int devindex) @@ -91,20 +91,20 @@ static SDL_VideoDevice *BE_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ /* Initialization/Query functions */ @@ -233,7 +233,7 @@ static int BE_AddMode(_THIS, int index, unsigned int w, unsigned int h) } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *)malloc(sizeof *mode); + mode = (SDL_Rect *)SDL_malloc(sizeof *mode); if ( mode == NULL ) { SDL_OutOfMemory(); return(-1); @@ -249,11 +249,11 @@ static int BE_AddMode(_THIS, int index, unsigned int w, unsigned int h) /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if ( SDL_modelist[index] == NULL ) { SDL_OutOfMemory(); SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return(-1); } SDL_modelist[index][next_mode] = mode; @@ -642,7 +642,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path) if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { _this->gl_config.dll_handle = (void*)cookie; _this->gl_config.driver_loaded = 1; - strncpy(_this->gl_config.driver_path, "libGL.so", sizeof(_this->gl_config.driver_path)-1); + SDL_strncpy(_this->gl_config.driver_path, "libGL.so", sizeof(_this->gl_config.driver_path)-1); } } } @@ -670,7 +670,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path) if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) { _this->gl_config.driver_loaded = 1; - strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path)-1); + SDL_strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path)-1); }*/ } @@ -679,7 +679,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path) } else { _this->gl_config.dll_handle = NULL; _this->gl_config.driver_loaded = 0; - strcpy(_this->gl_config.driver_path, ""); + SDL_strcpy(_this->gl_config.driver_path, ""); return -1; } } @@ -805,9 +805,9 @@ void BE_VideoQuit(_THIS) for ( i=0; ihwdata->bbitmap; - free(overlay->hwdata); + SDL_free(overlay->hwdata); } }; // extern "C" diff --git a/src/video/cybergfx/SDL_amigamouse.c b/src/video/cybergfx/SDL_amigamouse.c index ed38ab29f..548789d97 100644 --- a/src/video/cybergfx/SDL_amigamouse.c +++ b/src/video/cybergfx/SDL_amigamouse.c @@ -90,7 +90,7 @@ void amiga_CheckMouseMode(_THIS) &mouse_accel.numerator, &mouse_accel.denominator, &mouse_accel.threshold); - use_mouse_accel = getenv("SDL_VIDEO_X11_MOUSEACCEL"); + use_mouse_accel = SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL"); if ( use_mouse_accel ) { SetMouseAccel(this, use_mouse_accel); } diff --git a/src/video/cybergfx/SDL_cgxaccel.c b/src/video/cybergfx/SDL_cgxaccel.c index b38a44b4c..15be8ce8a 100644 --- a/src/video/cybergfx/SDL_cgxaccel.c +++ b/src/video/cybergfx/SDL_cgxaccel.c @@ -52,14 +52,14 @@ int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key) if(surface->hwdata) { if(surface->hwdata->mask) - free(surface->hwdata->mask); + SDL_free(surface->hwdata->mask); - if(surface->hwdata->mask=malloc(RASSIZE(surface->w,surface->h))) + if(surface->hwdata->mask=SDL_malloc(RASSIZE(surface->w,surface->h))) { Uint32 pitch,ok=0; APTR lock; - memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h)); + SDL_memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h)); D(bug("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel)); @@ -155,7 +155,7 @@ int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key) break; default: D(bug("Pixel mode non supported for color key...")); - free(surface->hwdata->mask); + SDL_free(surface->hwdata->mask); surface->hwdata->mask=NULL; ok=-1; } diff --git a/src/video/cybergfx/SDL_cgximage.c b/src/video/cybergfx/SDL_cgximage.c index 4ca2b6dfb..a8760fbfe 100644 --- a/src/video/cybergfx/SDL_cgximage.c +++ b/src/video/cybergfx/SDL_cgximage.c @@ -57,7 +57,7 @@ int CGX_SetupImage(_THIS, SDL_Surface *screen) ULONG pitch; if(!screen->hwdata) { - if(!(screen->hwdata=malloc(sizeof(struct private_hwdata)))) + if(!(screen->hwdata=SDL_malloc(sizeof(struct private_hwdata)))) return -1; D(bug("Creating system accel struct\n")); @@ -71,7 +71,7 @@ int CGX_SetupImage(_THIS, SDL_Surface *screen) if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap, LBMI_BASEADDRESS,(ULONG)&screen->pixels, LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) { - free(screen->hwdata); + SDL_free(screen->hwdata); screen->hwdata=NULL; return -1; } @@ -88,7 +88,7 @@ int CGX_SetupImage(_THIS, SDL_Surface *screen) return 0; } - screen->pixels = malloc(screen->h*screen->pitch); + screen->pixels = SDL_malloc(screen->h*screen->pitch); if ( screen->pixels == NULL ) { SDL_OutOfMemory(); @@ -110,14 +110,14 @@ int CGX_SetupImage(_THIS, SDL_Surface *screen) void CGX_DestroyImage(_THIS, SDL_Surface *screen) { if ( SDL_Ximage ) { - free(SDL_Ximage); + SDL_free(SDL_Ximage); SDL_Ximage = NULL; } if ( screen ) { screen->pixels = NULL; if(screen->hwdata) { - free(screen->hwdata); + SDL_free(screen->hwdata); screen->hwdata=NULL; } } @@ -163,7 +163,7 @@ int CGX_AllocHWSurface(_THIS, SDL_Surface *surface) if(!surface->hwdata) { - if(!(surface->hwdata=malloc(sizeof(struct private_hwdata)))) + if(!(surface->hwdata=SDL_malloc(sizeof(struct private_hwdata)))) return -1; } @@ -181,7 +181,7 @@ int CGX_AllocHWSurface(_THIS, SDL_Surface *surface) } else { - free(surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata=NULL; } @@ -194,12 +194,12 @@ void CGX_FreeHWSurface(_THIS, SDL_Surface *surface) D(bug("Free hw surface.\n")); if(surface->hwdata->mask) - free(surface->hwdata->mask); + SDL_free(surface->hwdata->mask); if(surface->hwdata->bmap&&surface->hwdata->allocated) FreeBitMap(surface->hwdata->bmap); - free(surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata=NULL; surface->pixels=NULL; D(bug("end of free hw surface\n")); @@ -654,7 +654,7 @@ static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) for(j=rects[i].h;j;--j) { - memcpy(dest,src,srcwidth); + SDL_memcpy(dest,src,srcwidth); src+=this->screen->pitch; dest+=destpitch; } @@ -883,13 +883,13 @@ void CGX_RefreshDisplay(_THIS) if(this->screen->pitch==destpitch) { - memcpy(dest,src,this->screen->pitch*this->screen->h); + SDL_memcpy(dest,src,this->screen->pitch*this->screen->h); } else { for(j=this->screen->h;j;--j) { - memcpy(dest,src,this->screen->pitch); + SDL_memcpy(dest,src,this->screen->pitch); src+=this->screen->pitch; dest+=destpitch; } diff --git a/src/video/cybergfx/SDL_cgxmodes.c b/src/video/cybergfx/SDL_cgxmodes.c index d1a1243a4..2f114e609 100644 --- a/src/video/cybergfx/SDL_cgxmodes.c +++ b/src/video/cybergfx/SDL_cgxmodes.c @@ -137,12 +137,12 @@ int CGX_GetVideoModes(_THIS) { nmodes++; - SDL_modelist = (SDL_Rect **)realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *)); + SDL_modelist = (SDL_Rect **)SDL_realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *)); SDL_modelist[nmodes]=NULL; if ( SDL_modelist ) { - SDL_modelist[nmodes-1] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + SDL_modelist[nmodes-1] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[nmodes-1] == NULL ) break; @@ -175,10 +175,10 @@ int CGX_GetVideoModes(_THIS) } if ( SDL_modelist == NULL ) { - SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); + SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); i = 0; if ( SDL_modelist ) { - SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[i] ) { SDL_modelist[i]->x = 0; SDL_modelist[i]->y = 0; @@ -238,9 +238,9 @@ void CGX_FreeVideoModes(_THIS) if ( SDL_modelist ) { for ( i=0; SDL_modelist[i]; ++i ) { - free(SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - free(SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } } diff --git a/src/video/cybergfx/SDL_cgxvideo.c b/src/video/cybergfx/SDL_cgxvideo.c index 41cd5fdab..3a1aa6e59 100644 --- a/src/video/cybergfx/SDL_cgxvideo.c +++ b/src/video/cybergfx/SDL_cgxvideo.c @@ -149,7 +149,7 @@ static void DestroyScreen(_THIS) this->hidden->SB[0]=this->hidden->SB[1]=NULL; if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) - free(SDL_RastPort); + SDL_free(SDL_RastPort); SDL_RastPort=NULL; } @@ -181,12 +181,12 @@ static void CGX_DeleteDevice(SDL_VideoDevice *device) { if ( device ) { if ( device->hidden ) { - free(device->hidden); + SDL_free(device->hidden); } if ( device->gl_data ) { - free(device->gl_data); + SDL_free(device->gl_data); } - free(device); + SDL_free(device); } } @@ -195,13 +195,13 @@ static SDL_VideoDevice *CGX_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - malloc((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ( (device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL) ) { @@ -210,8 +210,8 @@ static SDL_VideoDevice *CGX_CreateDevice(int devindex) CGX_DeleteDevice(device); return(0); } - memset(device->hidden, 0, sizeof(*device->hidden)); - memset(device->gl_data, 0, sizeof(*device->gl_data)); + SDL_memset(device->hidden, 0, sizeof(*device->hidden)); + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); /* Set the driver flags */ device->handles_any_size = 1; @@ -581,7 +581,7 @@ static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) } /* See if we have been passed a window to use */ -/* SDL_windowid = getenv("SDL_WINDOWID"); */ +/* SDL_windowid = SDL_getenv("SDL_WINDOWID"); */ SDL_windowid=NULL; /* Create the blank cursor */ @@ -649,7 +649,7 @@ void CGX_DestroyWindow(_THIS, SDL_Surface *screen) } } } - free(SDL_XPixels); + SDL_free(SDL_XPixels); SDL_XPixels = NULL; } } @@ -664,7 +664,7 @@ static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) } if ( flags & SDL_FULLSCREEN ) { flags&=~SDL_RESIZABLE; - } else if ( getenv("SDL_VIDEO_CENTERED") ) { + } else if ( SDL_getenv("SDL_VIDEO_CENTERED") ) { int display_w, display_h; display_w = SDL_Display->Width; @@ -777,7 +777,7 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen, else ncolors = 1 << screen->format->BitsPerPixel; - SDL_XPixels = (Sint32 *)malloc(ncolors * sizeof(Sint32)); + SDL_XPixels = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32)); if(SDL_XPixels == NULL) { SDL_OutOfMemory(); @@ -836,7 +836,7 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen, if(screen->flags & SDL_DOUBLEBUF) { - if(SDL_RastPort=malloc(sizeof(struct RastPort))) + if(SDL_RastPort=SDL_malloc(sizeof(struct RastPort))) { InitRastPort(SDL_RastPort); SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap; diff --git a/src/video/cybergfx/SDL_cgxwm.c b/src/video/cybergfx/SDL_cgxwm.c index 402b6b4b0..ddac3df99 100644 --- a/src/video/cybergfx/SDL_cgxwm.c +++ b/src/video/cybergfx/SDL_cgxwm.c @@ -78,7 +78,7 @@ void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) copy them */ if(SDL_Visual == dvis && SDL_XColorMap == SDL_DisplayColormap && this->screen->format->palette && sicon->format->palette) { - memcpy(sicon->format->palette->colors, + SDL_memcpy(sicon->format->palette->colors, this->screen->format->palette->colors, this->screen->format->palette->ncolors * sizeof(SDL_Color)); } @@ -98,21 +98,21 @@ void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) XColor wanted; palette = sicon->format->palette; - color_tried = malloc(palette->ncolors); + color_tried = SDL_malloc(palette->ncolors); if ( color_tried == NULL ) { goto done; } if ( SDL_iconcolors != NULL ) { - free(SDL_iconcolors); + SDL_free(SDL_iconcolors); } - SDL_iconcolors = malloc(palette->ncolors + SDL_iconcolors = SDL_malloc(palette->ncolors * sizeof(*SDL_iconcolors)); if ( SDL_iconcolors == NULL ) { - free(color_tried); + SDL_free(color_tried); goto done; } - memset(color_tried, 0, palette->ncolors); - memset(SDL_iconcolors, 0, + SDL_memset(color_tried, 0, palette->ncolors); + SDL_memset(SDL_iconcolors, 0, palette->ncolors * sizeof(*SDL_iconcolors)); p = (Uint8 *)sicon->pixels; @@ -132,16 +132,16 @@ void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) } } if ( color_tried != NULL ) { - free(color_tried); + SDL_free(color_tried); } /* Translate mask data to LSB order and set the icon mask */ i = (sicon->w/8)*sicon->h; - LSBmask = (Uint8 *)malloc(i); + LSBmask = (Uint8 *)SDL_malloc(i); if ( LSBmask == NULL ) { goto done; } - memset(LSBmask, 0, i); + SDL_memset(LSBmask, 0, i); while ( --i >= 0 ) { for ( b=0; b<8; ++b ) LSBmask[i] |= (((mask[i]>>b)&0x01)<<(7-b)); @@ -163,7 +163,7 @@ void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) 0, 0, 0, 0, sicon->w, sicon->h); XFreeGC(SDL_Display, GC); XDestroyImage(icon_image); - free(LSBmask); + SDL_free(LSBmask); sicon->pixels = NULL; #ifdef USE_ICON_WINDOW diff --git a/src/video/cybergfx/SDL_cgxyuv.c b/src/video/cybergfx/SDL_cgxyuv.c index 256163e70..36da414a1 100644 --- a/src/video/cybergfx/SDL_cgxyuv.c +++ b/src/video/cybergfx/SDL_cgxyuv.c @@ -89,12 +89,12 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S } /* Create the overlay structure */ - overlay = (SDL_Overlay *)malloc(sizeof *overlay); + overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); if ( overlay == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -105,7 +105,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S overlay->hwfuncs = &x11_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata); + hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); overlay->hwdata = hwdata; if ( hwdata == NULL ) { SDL_OutOfMemory(); @@ -113,7 +113,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S return(NULL); } yuvshm = &hwdata->yuvshm; - memset(yuvshm, 0, sizeof(*yuvshm)); + SDL_memset(yuvshm, 0, sizeof(*yuvshm)); hwdata->port = xv_port; hwdata->image = XvShmCreateImage(GFX_Display, xv_port, format, 0, width, height, yuvshm); @@ -179,7 +179,7 @@ void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) if ( hwdata->image ) { XFree(hwdata->image); } - free(hwdata); + SDL_free(hwdata); } } diff --git a/src/video/dc/SDL_dcevents.c b/src/video/dc/SDL_dcevents.c index 1f2b0cbac..83e021356 100644 --- a/src/video/dc/SDL_dcevents.c +++ b/src/video/dc/SDL_dcevents.c @@ -107,7 +107,7 @@ static void keyboard_update(void) if (addr!=old_addr) { old_addr = addr; - memset(&old_state,0,sizeof(old_state)); + SDL_memset(&old_state,0,sizeof(old_state)); } maple_raddr(addr,&port,&unit); diff --git a/src/video/dc/SDL_dcvideo.c b/src/video/dc/SDL_dcvideo.c index 92c3ea6f1..98f098386 100644 --- a/src/video/dc/SDL_dcvideo.c +++ b/src/video/dc/SDL_dcvideo.c @@ -76,8 +76,8 @@ static int DC_Available(void) static void DC_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *DC_CreateDevice(int devindex) @@ -85,20 +85,20 @@ static SDL_VideoDevice *DC_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DC_VideoInit; @@ -386,7 +386,7 @@ static void *DC_GL_GetProcAddress(_THIS, const char *proc) if (ret) return ret; for(i=0;ihidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); SDL_X11_UnloadSymbols(); } } @@ -118,21 +118,21 @@ static SDL_VideoDevice *DGA_CreateDevice(int devindex) /* Initialize all variables that we clean on shutdown */ if (SDL_X11_LoadSymbols()) { - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } SDL_X11_UnloadSymbols(); return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DGA_VideoInit; @@ -190,7 +190,7 @@ static int DGA_AddMode(_THIS, int bpp, int w, int h) } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *)malloc(sizeof *mode); + mode = (SDL_Rect *)SDL_malloc(sizeof *mode); if ( mode == NULL ) { SDL_OutOfMemory(); return(-1); @@ -203,11 +203,11 @@ static int DGA_AddMode(_THIS, int bpp, int w, int h) /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if ( SDL_modelist[index] == NULL ) { SDL_OutOfMemory(); SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return(-1); } SDL_modelist[index][next_mode] = mode; @@ -233,7 +233,7 @@ static Uint32 get_video_size(_THIS) proc = fopen("/proc/self/maps", "r"); if ( proc ) { while ( fgets(line, sizeof(line)-1, proc) ) { - sscanf(line, "%x-%x", &start, &stop); + SDL_sscanf(line, "%x-%x", &start, &stop); if ( start == mem ) { size = (Uint32)((stop-start)/1024); break; @@ -605,7 +605,7 @@ static int DGA_InitHWSurfaces(_THIS, SDL_Surface *screen, Uint8 *base, int size) surfaces_memleft = size; if ( surfaces_memleft > 0 ) { - bucket = (vidmem_bucket *)malloc(sizeof(*bucket)); + bucket = (vidmem_bucket *)SDL_malloc(sizeof(*bucket)); if ( bucket == NULL ) { SDL_OutOfMemory(); return(-1); @@ -637,7 +637,7 @@ static void DGA_FreeHWSurfaces(_THIS) while ( bucket ) { freeable = bucket; bucket = bucket->next; - free(freeable); + SDL_free(freeable); } surfaces.next = NULL; } @@ -714,7 +714,7 @@ surface->pitch = SDL_VideoSurface->pitch; #ifdef DGA_DEBUG fprintf(stderr, "Adding new free bucket of %d bytes\n", extra); #endif - newbucket = (vidmem_bucket *)malloc(sizeof(*newbucket)); + newbucket = (vidmem_bucket *)SDL_malloc(sizeof(*newbucket)); if ( newbucket == NULL ) { SDL_OutOfMemory(); retval = -1; @@ -775,7 +775,7 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface) if ( bucket->next ) { bucket->next->prev = bucket; } - free(freeable); + SDL_free(freeable); } if ( bucket->prev && ! bucket->prev->used ) { #ifdef DGA_DEBUG @@ -787,7 +787,7 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface) if ( bucket->next ) { bucket->next->prev = bucket->prev; } - free(freeable); + SDL_free(freeable); } } surface->pixels = NULL; @@ -1053,9 +1053,9 @@ void DGA_VideoQuit(_THIS) for ( i=0; ihidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *DirectFB_CreateDevice(int devindex) @@ -107,7 +107,7 @@ static SDL_VideoDevice *DirectFB_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { memset (device, 0, (sizeof *device)); @@ -467,7 +467,7 @@ int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat) HIDDEN->layer = layer; HIDDEN->eventbuffer = events; - if (getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL) + if (SDL_getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL) HIDDEN->enable_mga_crtc2 = 1; if (HIDDEN->enable_mga_crtc2) @@ -541,10 +541,10 @@ int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat) HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0xFF ); /* Check if overscan is possibly set */ - if (getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL) + if (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL) { float overscan = 0; - if (sscanf(getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f", &overscan) == 1) + if (SDL_sscanf(SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f", &overscan) == 1) if (overscan > 0 && overscan < 2) HIDDEN->mga_crtc2_stretch_overscan = overscan; } @@ -714,7 +714,7 @@ static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width HIDDEN->mga_crtc2_stretch = 0; - if (getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL) + if (SDL_getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL) { /* Normally assume a picture aspect ratio of 4:3 */ int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j; diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index ef34b4d7d..63e677ba9 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -73,8 +73,8 @@ static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects); static int DUMMY_Available(void) { - const char *envr = getenv("SDL_VIDEODRIVER"); - if ((envr) && (strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) { + const char *envr = SDL_getenv("SDL_VIDEODRIVER"); + if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) { return(1); } @@ -83,8 +83,8 @@ static int DUMMY_Available(void) static void DUMMY_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *DUMMY_CreateDevice(int devindex) @@ -92,20 +92,20 @@ static SDL_VideoDevice *DUMMY_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DUMMY_VideoInit; @@ -165,10 +165,10 @@ SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { if ( this->hidden->buffer ) { - free( this->hidden->buffer ); + SDL_free( this->hidden->buffer ); } - this->hidden->buffer = malloc(width * height * (bpp / 8)); + this->hidden->buffer = SDL_malloc(width * height * (bpp / 8)); if ( ! this->hidden->buffer ) { SDL_SetError("Couldn't allocate buffer for requested mode"); return(NULL); @@ -176,11 +176,11 @@ SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, /* printf("Setting mode %dx%d\n", width, height); */ - memset(this->hidden->buffer, 0, width * height * (bpp / 8)); + SDL_memset(this->hidden->buffer, 0, width * height * (bpp / 8)); /* Allocate the new pixel format for the screen */ if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { - free(this->hidden->buffer); + SDL_free(this->hidden->buffer); this->hidden->buffer = NULL; SDL_SetError("Couldn't allocate new pixel format for requested mode"); return(NULL); @@ -236,7 +236,7 @@ void DUMMY_VideoQuit(_THIS) { if (this->screen->pixels != NULL) { - free(this->screen->pixels); + SDL_free(this->screen->pixels); this->screen->pixels = NULL; } } diff --git a/src/video/epoc/SDL_epocvideo.cpp b/src/video/epoc/SDL_epocvideo.cpp index ab95bb063..eecf288c2 100644 --- a/src/video/epoc/SDL_epocvideo.cpp +++ b/src/video/epoc/SDL_epocvideo.cpp @@ -131,8 +131,8 @@ static int EPOC_Available(void) static void EPOC_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *EPOC_CreateDevice(int devindex) @@ -140,20 +140,20 @@ static SDL_VideoDevice *EPOC_CreateDevice(int devindex) SDL_VideoDevice *device; /* Allocate all variables that we free on delete */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = EPOC_VideoInit; @@ -240,7 +240,7 @@ int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Initialize all variables that we clean on shutdown */ for ( i=0; iSDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + Private->SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); Private->SDL_modelist[i]->x = Private->SDL_modelist[i]->y = 0; } /* Modes sorted largest to smallest !!TODO:sorting order??*/ @@ -357,7 +357,7 @@ SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, } if (current && current->pixels) { - free(current->pixels); + SDL_free(current->pixels); current->pixels = NULL; } if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { @@ -373,8 +373,8 @@ SDL_Surface *EPOC_SetVideoMode(_THIS, SDL_Surface *current, current->h = height; int numBytesPerPixel = ((bpp-1)>>3) + 1; current->pitch = numBytesPerPixel * width; // Number of bytes in scanline - current->pixels = malloc(width * height * numBytesPerPixel); - memset(current->pixels, 0, width * height * numBytesPerPixel); + current->pixels = SDL_malloc(width * height * numBytesPerPixel); + SDL_memset(current->pixels, 0, width * height * numBytesPerPixel); /* Set the blit function */ _this->UpdateRects = EPOC_DirectUpdate; @@ -622,7 +622,7 @@ void EPOC_VideoQuit(_THIS) /* Free video mode lists */ for ( i=0; iSDL_modelist[i] != NULL ) { - free(Private->SDL_modelist[i]); + SDL_free(Private->SDL_modelist[i]); Private->SDL_modelist[i] = NULL; } } @@ -633,7 +633,7 @@ void EPOC_VideoQuit(_THIS) } if (_this->screen && _this->screen->pixels) { - free(_this->screen->pixels); + SDL_free(_this->screen->pixels); _this->screen->pixels = NULL; } diff --git a/src/video/fbcon/SDL_fbelo.c b/src/video/fbcon/SDL_fbelo.c index 17a6a16a6..53d85c915 100644 --- a/src/video/fbcon/SDL_fbelo.c +++ b/src/video/fbcon/SDL_fbelo.c @@ -153,7 +153,7 @@ int eloGetPacket(unsigned char* buffer, int* buffer_p, int* checksum, int fd) { while (num_bytes) { if ((*buffer_p == 0) && (buffer[0] != ELO_START_BYTE)) { - memcpy(&buffer[0], &buffer[1], num_bytes-1); + SDL_memcpy(&buffer[0], &buffer[1], num_bytes-1); } else { if (*buffer_p < ELO_PACKET_SIZE-1) { @@ -333,19 +333,19 @@ int eloInitController(int fd) { struct termios mouse_termios; /* try to read the calibration values */ - buffer = getenv("SDL_ELO_MIN_X"); + buffer = SDL_getenv("SDL_ELO_MIN_X"); if(buffer) { ELO_MIN_X = atoi(buffer); } - buffer = getenv("SDL_ELO_MAX_X"); + buffer = SDL_getenv("SDL_ELO_MAX_X"); if(buffer) { ELO_MAX_X = atoi(buffer); } - buffer = getenv("SDL_ELO_MIN_Y"); + buffer = SDL_getenv("SDL_ELO_MIN_Y"); if(buffer) { ELO_MIN_Y = atoi(buffer); } - buffer = getenv("SDL_ELO_MAX_Y"); + buffer = SDL_getenv("SDL_ELO_MAX_Y"); if(buffer) { ELO_MAX_Y = atoi(buffer); } @@ -359,7 +359,7 @@ int eloInitController(int fd) { #endif /* set comm params */ - memset(&mouse_termios, 0, sizeof(mouse_termios)); + SDL_memset(&mouse_termios, 0, sizeof(mouse_termios)); mouse_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL; mouse_termios.c_cc[VMIN] = 1; result = tcsetattr(fd, TCSANOW, &mouse_termios); @@ -371,7 +371,7 @@ int eloInitController(int fd) { return 0; } - memset(req, 0, ELO_PACKET_SIZE); + SDL_memset(req, 0, ELO_PACKET_SIZE); req[1] = tolower(ELO_PARAMETER); if (!eloSendQuery(req, reply, fd)) { #ifdef DEBUG_MOUSE @@ -379,7 +379,7 @@ int eloInitController(int fd) { #endif } - memset(req, 0, ELO_PACKET_SIZE); + SDL_memset(req, 0, ELO_PACKET_SIZE); req[1] = tolower(ELO_ID); if (eloSendQuery(req, reply, fd)) { #ifdef DEBUG_MOUSE @@ -393,7 +393,7 @@ int eloInitController(int fd) { return 0; } - memset(req, 0, ELO_PACKET_SIZE); + SDL_memset(req, 0, ELO_PACKET_SIZE); req[1] = ELO_MODE; req[3] = ELO_TOUCH_MODE | ELO_STREAM_MODE | ELO_UNTOUCH_MODE; req[4] = ELO_TRACKING_MODE; @@ -404,7 +404,7 @@ int eloInitController(int fd) { return 0; } - memset(req, 0, ELO_PACKET_SIZE); + SDL_memset(req, 0, ELO_PACKET_SIZE); req[1] = ELO_REPORT; req[2] = ELO_UNTOUCH_DELAY; req[3] = ELO_REPORT_DELAY; diff --git a/src/video/fbcon/SDL_fbevents.c b/src/video/fbcon/SDL_fbevents.c index 067b8fbf2..a042aa935 100644 --- a/src/video/fbcon/SDL_fbevents.c +++ b/src/video/fbcon/SDL_fbevents.c @@ -81,7 +81,7 @@ static void FB_vgainitkeymaps(int fd) /* Load all the keysym mappings */ for ( map=0; mapd_name); } fclose(status); @@ -385,10 +385,10 @@ static int gpm_available(void) len = read(cmdline, args, sizeof(args)); arg = args; while ( len > 0 ) { - if ( strcmp(arg, "-R") == 0 ) { + if ( SDL_strcmp(arg, "-R") == 0 ) { available = 1; } - arglen = strlen(arg)+1; + arglen = SDL_strlen(arg)+1; len -= arglen; arg += arglen; } @@ -447,7 +447,7 @@ static int detect_imps2(int fd) imps2 = 0; - if ( getenv("SDL_MOUSEDEV_IMPS2") ) { + if ( SDL_getenv("SDL_MOUSEDEV_IMPS2") ) { imps2 = 1; } if ( ! imps2 ) { @@ -499,13 +499,13 @@ int FB_OpenMouse(_THIS) const char *mousedev; const char *mousedrv; - mousedrv = getenv("SDL_MOUSEDRV"); - mousedev = getenv("SDL_MOUSEDEV"); + mousedrv = SDL_getenv("SDL_MOUSEDRV"); + mousedev = SDL_getenv("SDL_MOUSEDEV"); mouse_fd = -1; #ifdef HAVE_TSLIB - if ((mousedrv != NULL) && (strcmp(mousedrv, "TSLIB") == 0)) { - if (mousedev == NULL) mousedev = getenv("TSLIB_TSDEVICE"); + if ((mousedrv != NULL) && (SDL_strcmp(mousedrv, "TSLIB") == 0)) { + if (mousedev == NULL) mousedev = SDL_getenv("TSLIB_TSDEVICE"); if (mousedev != NULL) { ts_dev = ts_open(mousedev, 1); if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) { @@ -524,7 +524,7 @@ int FB_OpenMouse(_THIS) /* ELO TOUCHSCREEN SUPPORT */ - if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) { + if( (mousedrv != NULL) && (SDL_strcmp(mousedrv, "ELO") == 0) ) { mouse_fd = open(mousedev, O_RDWR); if ( mouse_fd >= 0 ) { if(eloInitController(mouse_fd)) { @@ -839,7 +839,7 @@ static void handle_mouse(_THIS) FB_vgamousecallback(button, relative, dx, dy); } if ( i < nread ) { - memcpy(mousebuf, &mousebuf[i], (nread-i)); + SDL_memcpy(mousebuf, &mousebuf[i], (nread-i)); start = (nread-i); } else { start = 0; @@ -874,9 +874,9 @@ static void switch_vt(_THIS, unsigned short which) wait_idle(this); screen = SDL_VideoSurface; screen_arealen = (screen->h*screen->pitch); - screen_contents = (Uint8 *)malloc(screen_arealen); + screen_contents = (Uint8 *)SDL_malloc(screen_arealen); if ( screen_contents ) { - memcpy(screen_contents, screen->pixels, screen_arealen); + SDL_memcpy(screen_contents, screen->pixels, screen_arealen); } FB_SavePaletteTo(this, 256, saved_pal); ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo); @@ -900,8 +900,8 @@ static void switch_vt(_THIS, unsigned short which) ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo); FB_RestorePaletteFrom(this, 256, saved_pal); if ( screen_contents ) { - memcpy(screen->pixels, screen_contents, screen_arealen); - free(screen_contents); + SDL_memcpy(screen->pixels, screen_contents, screen_arealen); + SDL_free(screen_contents); } SDL_mutexV(hw_lock); } diff --git a/src/video/fbcon/SDL_fbvideo.c b/src/video/fbcon/SDL_fbvideo.c index 3c8868c78..0ef5553dd 100644 --- a/src/video/fbcon/SDL_fbvideo.c +++ b/src/video/fbcon/SDL_fbvideo.c @@ -155,7 +155,7 @@ static int FB_Available(void) int console; const char *SDL_fbdev; - SDL_fbdev = getenv("SDL_FBDEV"); + SDL_fbdev = SDL_getenv("SDL_FBDEV"); if ( SDL_fbdev == NULL ) { SDL_fbdev = "/dev/fb0"; } @@ -168,8 +168,8 @@ static int FB_Available(void) static void FB_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *FB_CreateDevice(int devindex) @@ -177,20 +177,20 @@ static SDL_VideoDevice *FB_CreateDevice(int devindex) SDL_VideoDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + this = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); wait_vbl = FB_WaitVBL; wait_idle = FB_WaitIdle; mouse_fd = -1; @@ -274,17 +274,17 @@ static int read_fbmodes_mode(FILE *f, struct fb_var_screeninfo *vinfo) do { if (read_fbmodes_line(f, line, sizeof(line))==0) return 0; - if (strncmp(line,"geometry",8)==0) + if (SDL_strncmp(line,"geometry",8)==0) break; } while(1); - sscanf(line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres, + SDL_sscanf(line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres, &vinfo->xres_virtual, &vinfo->yres_virtual, &vinfo->bits_per_pixel); if (read_fbmodes_line(f, line, sizeof(line))==0) return 0; - sscanf(line, "timings %d %d %d %d %d %d %d", &vinfo->pixclock, + SDL_sscanf(line, "timings %d %d %d %d %d %d %d", &vinfo->pixclock, &vinfo->left_margin, &vinfo->right_margin, &vinfo->upper_margin, &vinfo->lower_margin, &vinfo->hsync_len, &vinfo->vsync_len); @@ -296,38 +296,38 @@ static int read_fbmodes_mode(FILE *f, struct fb_var_screeninfo *vinfo) if (read_fbmodes_line(f, line, sizeof(line))==0) return 0; - if (strncmp(line,"hsync",5)==0) { - sscanf(line,"hsync %s",option); - if (strncmp(option,"high",4)==0) + if (SDL_strncmp(line,"hsync",5)==0) { + SDL_sscanf(line,"hsync %s",option); + if (SDL_strncmp(option,"high",4)==0) vinfo->sync |= FB_SYNC_HOR_HIGH_ACT; } - else if (strncmp(line,"vsync",5)==0) { - sscanf(line,"vsync %s",option); - if (strncmp(option,"high",4)==0) + else if (SDL_strncmp(line,"vsync",5)==0) { + SDL_sscanf(line,"vsync %s",option); + if (SDL_strncmp(option,"high",4)==0) vinfo->sync |= FB_SYNC_VERT_HIGH_ACT; } - else if (strncmp(line,"csync",5)==0) { - sscanf(line,"csync %s",option); - if (strncmp(option,"high",4)==0) + else if (SDL_strncmp(line,"csync",5)==0) { + SDL_sscanf(line,"csync %s",option); + if (SDL_strncmp(option,"high",4)==0) vinfo->sync |= FB_SYNC_COMP_HIGH_ACT; } - else if (strncmp(line,"extsync",5)==0) { - sscanf(line,"extsync %s",option); - if (strncmp(option,"true",4)==0) + else if (SDL_strncmp(line,"extsync",5)==0) { + SDL_sscanf(line,"extsync %s",option); + if (SDL_strncmp(option,"true",4)==0) vinfo->sync |= FB_SYNC_EXT; } - else if (strncmp(line,"laced",5)==0) { - sscanf(line,"laced %s",option); - if (strncmp(option,"true",4)==0) + else if (SDL_strncmp(line,"laced",5)==0) { + SDL_sscanf(line,"laced %s",option); + if (SDL_strncmp(option,"true",4)==0) vinfo->vmode |= FB_VMODE_INTERLACED; } - else if (strncmp(line,"double",6)==0) { - sscanf(line,"double %s",option); - if (strncmp(option,"true",4)==0) + else if (SDL_strncmp(line,"double",6)==0) { + SDL_sscanf(line,"double %s",option); + if (SDL_strncmp(option,"true",4)==0) vinfo->vmode |= FB_VMODE_DOUBLE; } } - while(strncmp(line,"endmode",7)!=0); + while(SDL_strncmp(line,"endmode",7)!=0); return 1; } @@ -393,7 +393,7 @@ static int FB_AddMode(_THIS, int index, unsigned int w, unsigned int h, int chec } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *)malloc(sizeof *mode); + mode = (SDL_Rect *)SDL_malloc(sizeof *mode); if ( mode == NULL ) { SDL_OutOfMemory(); return(-1); @@ -409,11 +409,11 @@ static int FB_AddMode(_THIS, int index, unsigned int w, unsigned int h, int chec /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if ( SDL_modelist[index] == NULL ) { SDL_OutOfMemory(); SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return(-1); } SDL_modelist[index][next_mode] = mode; @@ -455,7 +455,7 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) FILE *modesdb; /* Initialize the library */ - SDL_fbdev = getenv("SDL_FBDEV"); + SDL_fbdev = SDL_getenv("SDL_FBDEV"); if ( SDL_fbdev == NULL ) { SDL_fbdev = "/dev/fb0"; } @@ -518,7 +518,7 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Check if the user wants to disable hardware acceleration */ { const char *fb_accel; - fb_accel = getenv("SDL_FBACCEL"); + fb_accel = SDL_getenv("SDL_FBACCEL"); if ( fb_accel ) { finfo.accel = atoi(fb_accel); } @@ -589,7 +589,7 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) SDL_nummodes[i] = 0; SDL_modelist[i] = NULL; } - if ( getenv("SDL_FB_BROKEN_MODES") != NULL ) { + if ( SDL_getenv("SDL_FB_BROKEN_MODES") != NULL ) { FB_AddMode(this, current_index, current_w, current_h, 0); } else if(modesdb) { while ( read_fbmodes_mode(modesdb, &vinfo) ) { @@ -682,7 +682,7 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) if ( FB_OpenMouse(this) < 0 ) { const char *sdl_nomouse; - sdl_nomouse = getenv("SDL_NOMOUSE"); + sdl_nomouse = SDL_getenv("SDL_NOMOUSE"); if ( ! sdl_nomouse ) { SDL_SetError("Unable to open mouse"); FB_VideoQuit(this); @@ -867,7 +867,7 @@ static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface *current, current->w = vinfo.xres; current->h = vinfo.yres; current->pitch = current->w; - current->pixels = malloc(current->h*current->pitch); + current->pixels = SDL_malloc(current->h*current->pitch); /* Set the update rectangle function */ this->UpdateRects = FB_VGA16Update; @@ -1069,7 +1069,7 @@ static int FB_InitHWSurfaces(_THIS, SDL_Surface *screen, char *base, int size) surfaces_memleft = size; if ( surfaces_memleft > 0 ) { - bucket = (vidmem_bucket *)malloc(sizeof(*bucket)); + bucket = (vidmem_bucket *)SDL_malloc(sizeof(*bucket)); if ( bucket == NULL ) { SDL_OutOfMemory(); return(-1); @@ -1101,7 +1101,7 @@ static void FB_FreeHWSurfaces(_THIS) while ( bucket ) { freeable = bucket; bucket = bucket->next; - free(freeable); + SDL_free(freeable); } surfaces.next = NULL; } @@ -1152,7 +1152,7 @@ surface->pitch = SDL_VideoSurface->pitch; #ifdef FBCON_DEBUG fprintf(stderr, "Adding new free bucket of %d bytes\n", extra); #endif - newbucket = (vidmem_bucket *)malloc(sizeof(*newbucket)); + newbucket = (vidmem_bucket *)SDL_malloc(sizeof(*newbucket)); if ( newbucket == NULL ) { SDL_OutOfMemory(); return(-1); @@ -1210,7 +1210,7 @@ static void FB_FreeHWSurface(_THIS, SDL_Surface *surface) if ( bucket->next ) { bucket->next->prev = bucket; } - free(freeable); + SDL_free(freeable); } if ( bucket->prev && ! bucket->prev->used ) { #ifdef DGA_DEBUG @@ -1222,7 +1222,7 @@ static void FB_FreeHWSurface(_THIS, SDL_Surface *surface) if ( bucket->next ) { bucket->next->prev = bucket->prev; } - free(freeable); + SDL_free(freeable); } } surface->pixels = NULL; @@ -1489,7 +1489,7 @@ static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, /* Save hardware palette, if needed */ if ( finfo->visual == FB_VISUAL_PSEUDOCOLOR ) { saved_cmaplen = 1<bits_per_pixel; - saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap)); + saved_cmap=(__u16 *)SDL_malloc(3*saved_cmaplen*sizeof(*saved_cmap)); if ( saved_cmap != NULL ) { FB_SavePaletteTo(this, saved_cmaplen, saved_cmap); } @@ -1509,7 +1509,7 @@ static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, /* Save the colormap */ saved_cmaplen = 256; - saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap)); + saved_cmap=(__u16 *)SDL_malloc(3*saved_cmaplen*sizeof(*saved_cmap)); if ( saved_cmap != NULL ) { FB_SavePaletteTo(this, saved_cmaplen, saved_cmap); } @@ -1529,7 +1529,7 @@ static void FB_RestorePalette(_THIS) /* Restore the original palette */ if ( saved_cmap ) { FB_RestorePaletteFrom(this, saved_cmaplen, saved_cmap); - free(saved_cmap); + SDL_free(saved_cmap); saved_cmap = NULL; } } @@ -1561,9 +1561,9 @@ static int FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) ncolors = this->screen->format->palette->ncolors; cmap.start = 0; cmap.len = ncolors; - memset(r, 0, sizeof(r)); - memset(g, 0, sizeof(g)); - memset(b, 0, sizeof(b)); + SDL_memset(r, 0, sizeof(r)); + SDL_memset(g, 0, sizeof(g)); + SDL_memset(b, 0, sizeof(b)); if ( ioctl(console_fd, FBIOGETCMAP, &cmap) == 0 ) { for ( i=ncolors-1; i>=0; --i ) { colors[i].r = (r[i]>>8); @@ -1586,12 +1586,12 @@ static void FB_VideoQuit(_THIS) if ( this->screen ) { /* Clear screen and tell SDL not to free the pixels */ if ( this->screen->pixels && FB_InGraphicsMode(this) ) { -#if defined(__powerpc__) || defined(__ia64__) /* SIGBUS when using memset() ?? */ +#if defined(__powerpc__) || defined(__ia64__) /* SIGBUS when using SDL_memset() ?? */ Uint8 *rowp = (Uint8 *)this->screen->pixels; int left = this->screen->pitch*this->screen->h; while ( left-- ) { *rowp++ = 0; } #else - memset(this->screen->pixels,0,this->screen->h*this->screen->pitch); + SDL_memset(this->screen->pixels,0,this->screen->h*this->screen->pitch); #endif } /* This test fails when using the VGA16 shadow memory */ @@ -1611,9 +1611,9 @@ static void FB_VideoQuit(_THIS) for ( i=0; iSDL_nummodes[index]; gapi->SDL_modelist[index] = (SDL_Rect **) - realloc(gapi->SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(gapi->SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if ( gapi->SDL_modelist[index] == NULL ) { SDL_OutOfMemory(); gapi->SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return(-1); } gapi->SDL_modelist[index][next_mode] = mode; @@ -211,8 +211,8 @@ static void GAPI_DeleteDevice(SDL_VideoDevice *device) FreeLibrary(g_hGapiLib); g_hGapiLib = 0; } - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *GAPI_CreateDevice(int devindex) @@ -229,20 +229,20 @@ static SDL_VideoDevice *GAPI_CreateDevice(int devindex) } /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = GAPI_VideoInit; @@ -661,10 +661,10 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, /* Allocate bitmap */ if(gapiBuffer) { - free(gapiBuffer); + SDL_free(gapiBuffer); gapiBuffer = NULL; } - gapiBuffer = malloc(video->h * video->pitch); + gapiBuffer = SDL_malloc(video->h * video->pitch); video->pixels = gapiBuffer; if ( ! this->hidden->buffer ) { @@ -672,7 +672,7 @@ SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current, return(NULL); } - memset(gapiBuffer, 255, video->h * video->pitch); + SDL_memset(gapiBuffer, 255, video->h * video->pitch); MoveWindow(SDL_Window, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE); ShowWindow(SDL_Window, SW_SHOW); SetForegroundWindow(SDL_Window); @@ -738,7 +738,7 @@ static int updateLine8to8(_THIS, unsigned char *srcPointer, unsigned char *destP { if( gapi->dstPixelStep == 1) /* optimized blitting on most devices */ { - memcpy(destPointer, srcPointer, width); + SDL_memcpy(destPointer, srcPointer, width); return 1; } else { @@ -761,7 +761,7 @@ static int updateLine16to16(_THIS, PIXEL *srcPointer, PIXEL *destPointer, int wi if( step == 1 ) /* optimized blitting on most devices */ { - memcpy(destPointer, srcPointer, width * sizeof(PIXEL)); + SDL_memcpy(destPointer, srcPointer, width * sizeof(PIXEL)); return 1; } else @@ -1062,7 +1062,7 @@ void GAPI_VideoQuit(_THIS) if (this->screen->pixels != NULL) { - free(this->screen->pixels); + SDL_free(this->screen->pixels); this->screen->pixels = NULL; } if ( screen_icn ) { @@ -1089,8 +1089,8 @@ void GAPI_VideoQuit(_THIS) for ( i=0; iSDL_modelist[i] != NULL ) { for ( j=0; gapi->SDL_modelist[i][j]; ++j ) - free(gapi->SDL_modelist[i][j]); - free(gapi->SDL_modelist[i]); + SDL_free(gapi->SDL_modelist[i][j]); + SDL_free(gapi->SDL_modelist[i]); gapi->SDL_modelist[i] = NULL; } } diff --git a/src/video/gem/SDL_gemevents.c b/src/video/gem/SDL_gemevents.c index c557c551a..168c3e267 100644 --- a/src/video/gem/SDL_gemevents.c +++ b/src/video/gem/SDL_gemevents.c @@ -89,9 +89,9 @@ void GEM_InitOSKeymap(_THIS) { int i; - memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); - memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard)); - memset(gem_currentascii, 0, sizeof(gem_currentascii)); + SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); + SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard)); + SDL_memset(gem_currentascii, 0, sizeof(gem_currentascii)); /* Initialize keymap */ for ( i=0; imform_p != NULL) - free(cursor->mform_p); + SDL_free(cursor->mform_p); - free(cursor); + SDL_free(cursor); } WMcursor *GEM_CreateWMCursor(_THIS, @@ -77,16 +77,16 @@ WMcursor *GEM_CreateWMCursor(_THIS, } /* Allocate the cursor memory */ - cursor = (WMcursor *)malloc(sizeof(WMcursor)); + cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); if ( cursor == NULL ) { SDL_OutOfMemory(); return(NULL); } /* Allocate mform */ - new_mform = (MFORM *)malloc(sizeof(MFORM)); + new_mform = (MFORM *)SDL_malloc(sizeof(MFORM)); if (new_mform == NULL) { - free(cursor); + SDL_free(cursor); SDL_OutOfMemory(); return(NULL); } diff --git a/src/video/gem/SDL_gemvideo.c b/src/video/gem/SDL_gemvideo.c index 90137f5fe..3ffa4068a 100644 --- a/src/video/gem/SDL_gemvideo.c +++ b/src/video/gem/SDL_gemvideo.c @@ -125,8 +125,8 @@ static int GEM_Available(void) static void GEM_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *GEM_CreateDevice(int devindex) @@ -136,23 +136,23 @@ static SDL_VideoDevice *GEM_CreateDevice(int devindex) unsigned long dummy; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - malloc((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); - memset(device->gl_data, 0, sizeof(*device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); /* Set the function pointers */ device->VideoInit = GEM_VideoInit; @@ -400,7 +400,7 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) VDI_oldpalette[i][2] = rgb[2]; } VDI_setpalette = GEM_SetNewPalette; - memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette)); + SDL_memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette)); /* Setup screen info */ GEM_title_name = empty_name; @@ -453,7 +453,7 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) GEM_menubar=Atari_SysMalloc(menubar_size,MX_PREFTTRAM); /* Fill video modes list */ - SDL_modelist[0] = malloc(sizeof(SDL_Rect)); + SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect)); SDL_modelist[0]->x = 0; SDL_modelist[0]->y = 0; SDL_modelist[0]->w = VDI_w; @@ -679,7 +679,7 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, SDL_SetError("Can not allocate %d KB for frame buffer", screensize>>10); return NULL; } - memset(GEM_buffer1, 0, screensize); + SDL_memset(GEM_buffer1, 0, screensize); #ifdef DEBUG_VIDEO_GEM printf("sdl:video:gem: setvideomode(): allocated buffer 1\n"); #endif @@ -691,7 +691,7 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, SDL_SetError("Can not allocate %d KB for shadow buffer", screensize>>10); return NULL; } - memset(GEM_buffer2, 0, screensize); + SDL_memset(GEM_buffer2, 0, screensize); #ifdef DEBUG_VIDEO_GEM printf("sdl:video:gem: setvideomode(): allocated buffer 2\n"); #endif @@ -1132,7 +1132,7 @@ void GEM_VideoQuit(_THIS) /* Free mode list */ if (SDL_modelist[0]) { - free(SDL_modelist[0]); + SDL_free(SDL_modelist[0]); SDL_modelist[0]=NULL; } diff --git a/src/video/ggi/SDL_ggivideo.c b/src/video/ggi/SDL_ggivideo.c index 5786cbdad..33b4fceb3 100644 --- a/src/video/ggi/SDL_ggivideo.c +++ b/src/video/ggi/SDL_ggivideo.c @@ -83,8 +83,8 @@ static int GGI_Available(void) static void GGI_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *GGI_CreateDevice(int devindex) @@ -92,20 +92,20 @@ static SDL_VideoDevice *GGI_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = GGI_VideoInit; @@ -162,7 +162,7 @@ int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat) int err, num_bufs; ggi_pixel white, black; - priv = malloc(sizeof(struct private_hwdata)); + priv = SDL_malloc(sizeof(struct private_hwdata)); if (priv == NULL) { SDL_SetError("Unhandled GGI mode type!\n"); diff --git a/src/video/ipod/SDL_ipodvideo.c b/src/video/ipod/SDL_ipodvideo.c index 8bf223bb4..2879bf859 100644 --- a/src/video/ipod/SDL_ipodvideo.c +++ b/src/video/ipod/SDL_ipodvideo.c @@ -65,7 +65,7 @@ static long iPod_GetGeneration() if ((file = fopen("/proc/cpuinfo", "r")) != NULL) { while (fgets(cpuinfo, sizeof(cpuinfo), file) != NULL) - if (strncmp(cpuinfo, "Revision", 8) == 0) + if (SDL_strncmp(cpuinfo, "Revision", 8) == 0) break; fclose(file); } @@ -73,7 +73,7 @@ static long iPod_GetGeneration() for (; isspace(cpuinfo[i]); i++); ptr = cpuinfo + i + 2; - return strtol(ptr, NULL, 10); + return SDL_strtol(ptr, NULL, 10); } static int iPod_Available() diff --git a/src/video/maccommon/SDL_macmouse.c b/src/video/maccommon/SDL_macmouse.c index 6ae49c082..81697113f 100644 --- a/src/video/maccommon/SDL_macmouse.c +++ b/src/video/maccommon/SDL_macmouse.c @@ -48,7 +48,7 @@ struct WMcursor { void Mac_FreeWMCursor(_THIS, WMcursor *cursor) { - free(cursor); + SDL_free(cursor); } WMcursor *Mac_CreateWMCursor(_THIS, @@ -58,12 +58,12 @@ WMcursor *Mac_CreateWMCursor(_THIS, int row, bytes; /* Allocate the cursor memory */ - cursor = (WMcursor *)malloc(sizeof(WMcursor)); + cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); if ( cursor == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(cursor, 0, sizeof(*cursor)); + SDL_memset(cursor, 0, sizeof(*cursor)); if (w > 16) w = 16; @@ -74,11 +74,11 @@ WMcursor *Mac_CreateWMCursor(_THIS, bytes = (w+7)/8; for ( row=0; rowcurs.data[row], data, bytes); + SDL_memcpy(&cursor->curs.data[row], data, bytes); data += bytes; } for ( row=0; rowcurs.mask[row], mask, bytes); + SDL_memcpy(&cursor->curs.mask[row], mask, bytes); mask += bytes; } cursor->curs.hotSpot.h = hot_x; diff --git a/src/video/maccommon/SDL_macwm.c b/src/video/maccommon/SDL_macwm.c index 2bdc32582..aab0030c9 100644 --- a/src/video/maccommon/SDL_macwm.c +++ b/src/video/maccommon/SDL_macwm.c @@ -39,7 +39,7 @@ void Mac_SetCaption(_THIS, const char *title, const char *icon) /* Don't convert C to P string in place, because it may be read-only */ Str255 ptitle; /* MJS */ ptitle[0] = strlen (title); - memcpy(ptitle+1, title, ptitle[0]); /* MJS */ + SDL_memcpy(ptitle+1, title, ptitle[0]); /* MJS */ if (SDL_Window) SetWTitle(SDL_Window, ptitle); /* MJS */ } diff --git a/src/video/macdsp/SDL_dspvideo.c b/src/video/macdsp/SDL_dspvideo.c index aca478292..bc22584ad 100644 --- a/src/video/macdsp/SDL_dspvideo.c +++ b/src/video/macdsp/SDL_dspvideo.c @@ -238,11 +238,11 @@ static void DSp_DeleteDevice(SDL_VideoDevice *device) if (device->hidden) { if (device->hidden->dspinfo) - free(device->hidden->dspinfo); + SDL_free(device->hidden->dspinfo); - free(device->hidden); + SDL_free(device->hidden); } - free(device); + SDL_free(device); } } @@ -251,13 +251,13 @@ static SDL_VideoDevice *DSp_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, sizeof (*device)); + SDL_memset(device, 0, sizeof (*device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); if (device->hidden) - memset(device->hidden, 0, sizeof ( *(device->hidden) ) ); + SDL_memset(device->hidden, 0, sizeof ( *(device->hidden) ) ); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); @@ -267,22 +267,22 @@ static SDL_VideoDevice *DSp_CreateDevice(int devindex) if (device->hidden) free (device->hidden); - free(device); + SDL_free(device); } return(NULL); } /* Allocate DrawSprocket information */ - device->hidden->dspinfo = (struct DSpInfo *)malloc( + device->hidden->dspinfo = (struct DSpInfo *)SDL_malloc( (sizeof *device->hidden->dspinfo)); if ( device->hidden->dspinfo == NULL ) { SDL_OutOfMemory(); - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); return(0); } - memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo)); + SDL_memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo)); /* Set the function pointers */ device->VideoInit = DSp_VideoInit; @@ -1384,9 +1384,9 @@ void DSp_VideoQuit(_THIS) /* Free list of video modes */ if ( SDL_modelist != NULL ) { for ( i=0; SDL_modelist[i]; i++ ) { - free(SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - free(SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } diff --git a/src/video/macrom/SDL_romvideo.c b/src/video/macrom/SDL_romvideo.c index 74335e89e..5b3cc7c2d 100644 --- a/src/video/macrom/SDL_romvideo.c +++ b/src/video/macrom/SDL_romvideo.c @@ -120,8 +120,8 @@ static int ROM_Available(void) static void ROM_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *ROM_CreateDevice(int devindex) @@ -129,20 +129,20 @@ static SDL_VideoDevice *ROM_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = ROM_VideoInit; @@ -231,9 +231,9 @@ static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat) SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit+pmTolerant, 0); /* Get a list of available fullscreen modes */ - SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); + SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); if ( SDL_modelist ) { - SDL_modelist[0] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[0] ) { SDL_modelist[0]->x = 0; SDL_modelist[0]->y = 0; @@ -723,9 +723,9 @@ void ROM_VideoQuit(_THIS) /* Free list of video modes */ if ( SDL_modelist != NULL ) { for ( i=0; SDL_modelist[i]; ++i ) { - free(SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - free(SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } } diff --git a/src/video/os2fslib/SDL_os2fslib.c b/src/video/os2fslib/SDL_os2fslib.c index e013a62bb..d81bf6fc9 100644 --- a/src/video/os2fslib/SDL_os2fslib.c +++ b/src/video/os2fslib/SDL_os2fslib.c @@ -1169,8 +1169,8 @@ void os2fslib_FreeWMCursor(_THIS, WMcursor *cursor) { GpiDeleteBitmap(cursor->hbm); WinDestroyPointer(cursor->hptr); - free(cursor->pchData); - free(cursor); + SDL_free(cursor->pchData); + SDL_free(cursor); } } @@ -1208,17 +1208,17 @@ WMcursor *os2fslib_CreateWMCursor_Win(_THIS, Uint8 *data, Uint8 *mask, if ((w>maxx) || (h>maxy)) return (WMcursor *) NULL; - pResult = (WMcursor *) malloc(sizeof(WMcursor)); + pResult = (WMcursor *) SDL_malloc(sizeof(WMcursor)); if (!pResult) return (WMcursor *) NULL; - pchTemp = (char *) malloc((maxx + 7)/8 * maxy*2); + pchTemp = (char *) SDL_malloc((maxx + 7)/8 * maxy*2); if (!pchTemp) { - free(pResult); + SDL_free(pResult); return (WMcursor *) NULL; } - memset(pchTemp, 0, (maxx + 7)/8 * maxy*2); + SDL_memset(pchTemp, 0, (maxx + 7)/8 * maxy*2); hps = WinGetPS(_this->hidden->hwndClient); @@ -1234,7 +1234,7 @@ WMcursor *os2fslib_CreateWMCursor_Win(_THIS, Uint8 *data, Uint8 *mask, bmi.argbColor[1].bGreen = 0x00; bmi.argbColor[1].bRed = 0xff; - memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); + SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); bmih.cbFix = sizeof(BITMAPINFOHEADER); bmih.cx = maxx; bmih.cy = 2*maxy; @@ -1254,9 +1254,9 @@ WMcursor *os2fslib_CreateWMCursor_Win(_THIS, Uint8 *data, Uint8 *mask, memnot(aptr, mask, run); mask += run; aptr += run; - memset(xptr, 0, pad); + SDL_memset(xptr, 0, pad); xptr += pad; - memset(aptr, ~0, pad); + SDL_memset(aptr, ~0, pad); aptr += pad; } pad += run; @@ -1265,9 +1265,9 @@ WMcursor *os2fslib_CreateWMCursor_Win(_THIS, Uint8 *data, Uint8 *mask, xptr = pchTemp + (maxx+7)/8 * (maxy-1-i); aptr = pchTemp + (maxx+7)/8 * (maxy+maxy-1-i); - memset(xptr, 0, (maxx+7)/8); + SDL_memset(xptr, 0, (maxx+7)/8); xptr += (maxx+7)/8; - memset(aptr, ~0, (maxx+7)/8); + SDL_memset(aptr, ~0, (maxx+7)/8); aptr += (maxx+7)/8; } @@ -1507,18 +1507,18 @@ void os2fslib_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) if ((w>maxx) || (h>maxy)) return; - pchTemp = (char *) malloc(w * h*2 * 4); + pchTemp = (char *) SDL_malloc(w * h*2 * 4); if (!pchTemp) return; - memset(pchTemp, 0, w * h*2 * 4); + SDL_memset(pchTemp, 0, w * h*2 * 4); // Convert surface to RGB, if it's not RGB yet! icon_rgb = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, 32, 0, 0, 0, 0); if ( icon_rgb == NULL ) { - free(pchTemp); + SDL_free(pchTemp); return; } bounds.x = 0; @@ -1528,7 +1528,7 @@ void os2fslib_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) if ( SDL_LowerBlit(icon, &bounds, icon_rgb, &bounds) < 0 ) { SDL_FreeSurface(icon_rgb); - free(pchTemp); + SDL_free(pchTemp); return; } @@ -1596,7 +1596,7 @@ void os2fslib_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) bmi.cPlanes = 1; bmi.cBitCount = 32; - memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); + SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); bmih.cbFix = sizeof(BITMAPINFOHEADER); bmih.cx = w; bmih.cy = 2*h; @@ -1609,7 +1609,7 @@ void os2fslib_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) WinReleasePS(hps); // Free pixel array - free(pchTemp); + SDL_free(pchTemp); // Change icon in frame window WinSendMsg(hwndFrame, @@ -2116,7 +2116,7 @@ static void os2fslib_VideoQuit(_THIS) // no FreeListModes() call in SDL! if (_this->hidden->pListModesResult) { - free(_this->hidden->pListModesResult); _this->hidden->pListModesResult = NULL; + SDL_free(_this->hidden->pListModesResult); _this->hidden->pListModesResult = NULL; } // Free list of available fullscreen modes @@ -2254,7 +2254,7 @@ static SDL_Surface *os2fslib_SetVideoMode(_THIS, SDL_Surface *current, // We'll possibly adjust the structure, so copy out the values // into TempModeInfo! - memcpy(&TempModeInfo, pModeInfoFound, sizeof(TempModeInfo)); + SDL_memcpy(&TempModeInfo, pModeInfoFound, sizeof(TempModeInfo)); pModeInfoFound = &TempModeInfo; if (flags & SDL_RESIZABLE) @@ -2335,7 +2335,7 @@ static SDL_Surface *os2fslib_SetVideoMode(_THIS, SDL_Surface *current, pModeInfoFound->uiScanLineSize = pResult->pitch; // Store new source buffer parameters! - memcpy(&(_this->hidden->SrcBufferDesc), pModeInfoFound, sizeof(*pModeInfoFound)); + SDL_memcpy(&(_this->hidden->SrcBufferDesc), pModeInfoFound, sizeof(*pModeInfoFound)); _this->hidden->pchSrcBuffer = pResult->pixels; #ifdef DEBUG_BUILD @@ -2446,7 +2446,7 @@ static SDL_Rect **os2fslib_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flag // Destroy result of previous call, if there is any if (_this->hidden->pListModesResult) { - free(_this->hidden->pListModesResult); _this->hidden->pListModesResult = NULL; + SDL_free(_this->hidden->pListModesResult); _this->hidden->pListModesResult = NULL; } // For resizable and windowed mode we support every resolution! @@ -2469,7 +2469,7 @@ static SDL_Rect **os2fslib_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flag { if (pFSMode->uiBPP == format->BitsPerPixel) { - SDL_Rect *pRect = (SDL_Rect *) malloc(sizeof(SDL_Rect)); + SDL_Rect *pRect = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (pRect) { // Fill description @@ -2489,14 +2489,14 @@ static SDL_Rect **os2fslib_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flag #endif // We're the first one to be inserted! - _this->hidden->pListModesResult = (SDL_Rect**) malloc(2*sizeof(SDL_Rect*)); + _this->hidden->pListModesResult = (SDL_Rect**) SDL_malloc(2*sizeof(SDL_Rect*)); if (_this->hidden->pListModesResult) { _this->hidden->pListModesResult[0] = pRect; _this->hidden->pListModesResult[1] = NULL; } else { - free(pRect); + SDL_free(pRect); } } else { @@ -2528,7 +2528,7 @@ static SDL_Rect **os2fslib_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flag // printf("!!! From %d slots, it will be at %d\n", iNumOfSlots, iPlace); #endif - pNewList = (SDL_Rect**) realloc(_this->hidden->pListModesResult, (iNumOfSlots+1)*sizeof(SDL_Rect*)); + pNewList = (SDL_Rect**) SDL_realloc(_this->hidden->pListModesResult, (iNumOfSlots+1)*sizeof(SDL_Rect*)); if (pNewList) { for (i=iNumOfSlots;i>iPlace;i--) @@ -2537,7 +2537,7 @@ static SDL_Rect **os2fslib_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flag _this->hidden->pListModesResult = pNewList; } else { - free(pRect); + SDL_free(pRect); } } } @@ -2611,9 +2611,9 @@ static int os2fslib_VideoInit(_THIS, SDL_PixelFormat *vformat) // For this, we select the first available fullscreen mode as // current window size! - memcpy(&(_this->hidden->SrcBufferDesc), _this->hidden->pAvailableFSLibVideoModes, sizeof(_this->hidden->SrcBufferDesc)); + SDL_memcpy(&(_this->hidden->SrcBufferDesc), _this->hidden->pAvailableFSLibVideoModes, sizeof(_this->hidden->SrcBufferDesc)); // Allocate new video buffer! - _this->hidden->pchSrcBuffer = (char *) malloc(_this->hidden->pAvailableFSLibVideoModes->uiScanLineSize * _this->hidden->pAvailableFSLibVideoModes->uiYResolution); + _this->hidden->pchSrcBuffer = (char *) SDL_malloc(_this->hidden->pAvailableFSLibVideoModes->uiScanLineSize * _this->hidden->pAvailableFSLibVideoModes->uiYResolution); if (!_this->hidden->pchSrcBuffer) { #ifdef DEBUG_BUILD @@ -2666,12 +2666,12 @@ static void os2fslib_DeleteDevice(_THIS) // Free used memory FSLib_FreeVideoModeList(_this->hidden->pAvailableFSLibVideoModes); if (_this->hidden->pListModesResult) - free(_this->hidden->pListModesResult); + SDL_free(_this->hidden->pListModesResult); if (_this->hidden->pchSrcBuffer) - free(_this->hidden->pchSrcBuffer); + SDL_free(_this->hidden->pchSrcBuffer); DosCloseMutexSem(_this->hidden->hmtxUseSrcBuffer); - free(_this->hidden); - free(_this); + SDL_free(_this->hidden); + SDL_free(_this); FSLib_Uninitialize(); } @@ -2703,21 +2703,21 @@ static SDL_VideoDevice *os2fslib_CreateDevice(int devindex) #endif /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); // Also allocate memory for private data - device->hidden = (struct SDL_PrivateVideoData *) malloc((sizeof(struct SDL_PrivateVideoData))); + device->hidden = (struct SDL_PrivateVideoData *) SDL_malloc((sizeof(struct SDL_PrivateVideoData))); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) - free(device); + SDL_free(device); return NULL; } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ #ifdef DEBUG_BUILD @@ -2770,8 +2770,8 @@ static SDL_VideoDevice *os2fslib_CreateDevice(int devindex) printf("[os2fslib_CreateDevice] : Could not initialize FSLib!\n"); #endif SDL_SetError("Could not initialize FSLib!"); - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); return NULL; } device->hidden->pAvailableFSLibVideoModes = diff --git a/src/video/photon/SDL_ph_gl.c b/src/video/photon/SDL_ph_gl.c index 1f43d8648..301487f8f 100644 --- a/src/video/photon/SDL_ph_gl.c +++ b/src/video/photon/SDL_ph_gl.c @@ -123,7 +123,7 @@ int ph_GL_LoadLibrary(_THIS, const char* path) this->gl_config.dll_handle = handle; this->gl_config.driver_loaded = 1; - strncpy(this->gl_config.driver_path, path, sizeof(this->gl_config.driver_path)-1); + SDL_strncpy(this->gl_config.driver_path, path, sizeof(this->gl_config.driver_path)-1); return 0; } diff --git a/src/video/photon/SDL_ph_image.c b/src/video/photon/SDL_ph_image.c index 41ce4675c..9f43b1500 100644 --- a/src/video/photon/SDL_ph_image.c +++ b/src/video/photon/SDL_ph_image.c @@ -77,7 +77,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen) if ((bpp==8) && (desktoppal==SDLPH_PAL_EMULATE)) { /* creating image palette */ - palette=malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t)); + palette=SDL_malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t)); if (palette==NULL) { SDL_SetError("ph_SetupImage(): can't allocate memory for palette !\n"); @@ -89,7 +89,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen) if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL) { SDL_SetError("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); - free(palette); + SDL_free(palette); return -1; } } @@ -254,11 +254,11 @@ int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen) for (i=0; i<40; i++) { - memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); + SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); } for (i=440; i<480; i++) { - memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); + SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); } screen->pixels+=screen->pitch*40; } @@ -278,11 +278,11 @@ int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen) for (i=0; i<40; i++) { - memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); + SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); } for (i=440; i<480; i++) { - memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); + SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); } screen->pixels+=screen->pitch*40; } @@ -391,10 +391,10 @@ void ph_DestroyImage(_THIS, SDL_Surface* screen) /* if palette allocated, free it */ if (SDL_Image->palette) { - free(SDL_Image->palette); + SDL_free(SDL_Image->palette); } PgShmemDestroy(SDL_Image->image); - free(SDL_Image); + SDL_free(SDL_Image); } /* Must be zeroed everytime */ @@ -531,8 +531,8 @@ int ph_AllocHWSurface(_THIS, SDL_Surface* surface) SDL_SetError("ph_AllocHWSurface(): hwdata already exists!\n"); return -1; } - surface->hwdata=malloc(sizeof(struct private_hwdata)); - memset(surface->hwdata, 0x00, sizeof(struct private_hwdata)); + surface->hwdata=SDL_malloc(sizeof(struct private_hwdata)); + SDL_memset(surface->hwdata, 0x00, sizeof(struct private_hwdata)); surface->hwdata->offscreenctx=PdCreateOffscreenContext(0, surface->w, surface->h, Pg_OSC_MEM_PAGE_ALIGN); if (surface->hwdata->offscreenctx == NULL) { @@ -601,7 +601,7 @@ void ph_FreeHWSurface(_THIS, SDL_Surface* surface) PhDCRelease(surface->hwdata->offscreenctx); - free(surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata=NULL; /* Update video ram amount */ diff --git a/src/video/photon/SDL_ph_modes.c b/src/video/photon/SDL_ph_modes.c index cab9093b0..433c2c1e7 100644 --- a/src/video/photon/SDL_ph_modes.c +++ b/src/video/photon/SDL_ph_modes.c @@ -292,10 +292,10 @@ int ph_EnterFullScreen(_THIS, SDL_Surface* screen, int fmode) settings.refresh = 0; settings.flags = 0; - refreshrate=getenv("SDL_PHOTON_FULLSCREEN_REFRESH"); + refreshrate=SDL_getenv("SDL_PHOTON_FULLSCREEN_REFRESH"); if (refreshrate!=NULL) { - if (sscanf(refreshrate, "%d", &refreshratenum)==1) + if (SDL_sscanf(refreshrate, "%d", &refreshratenum)==1) { settings.refresh = refreshratenum; } diff --git a/src/video/photon/SDL_ph_mouse.c b/src/video/photon/SDL_ph_mouse.c index 1c2729491..8321d6e55 100644 --- a/src/video/photon/SDL_ph_mouse.c +++ b/src/video/photon/SDL_ph_mouse.c @@ -49,7 +49,7 @@ void ph_FreeWMCursor(_THIS, WMcursor *cursor) SDL_Unlock_EventThread(); } - free(cursor); + SDL_free(cursor); } WMcursor *ph_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) @@ -59,14 +59,14 @@ WMcursor *ph_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int h unsigned char bit, databit, maskbit; /* Allocate and initialize the cursor memory */ - if ((cursor = (WMcursor*)malloc(sizeof(WMcursor))) == NULL) + if ((cursor = (WMcursor*)SDL_malloc(sizeof(WMcursor))) == NULL) { SDL_OutOfMemory(); return(NULL); } - memset(cursor,0,sizeof(WMcursor)); + SDL_memset(cursor,0,sizeof(WMcursor)); - cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2); + cursor->ph_cursor = (PhCursorDef_t *) SDL_malloc(sizeof(PhCursorDef_t) + 32*4*2); if (cursor->ph_cursor == NULL) { @@ -74,7 +74,7 @@ WMcursor *ph_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int h return NULL; } - memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2)); + SDL_memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2)); cursor->ph_cursor->hdr.type =Ph_RDATA_CURSOR; cursor->ph_cursor->size1.x = (short)w; diff --git a/src/video/photon/SDL_ph_video.c b/src/video/photon/SDL_ph_video.c index 57354bd4a..cf017f8eb 100644 --- a/src/video/photon/SDL_ph_video.c +++ b/src/video/photon/SDL_ph_video.c @@ -76,11 +76,11 @@ static SDL_VideoDevice* ph_CreateDevice(int devindex) SDL_VideoDevice* device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData*)malloc((sizeof *device->hidden)); + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData*)SDL_malloc((sizeof *device->hidden)); device->gl_data = NULL; } if ((device == NULL) || (device->hidden == NULL)) @@ -89,7 +89,7 @@ static SDL_VideoDevice* ph_CreateDevice(int devindex) ph_DeleteDevice(device); return NULL; } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the driver flags */ device->handles_any_size = 1; @@ -158,15 +158,15 @@ static void ph_DeleteDevice(SDL_VideoDevice *device) { if (device->hidden) { - free(device->hidden); + SDL_free(device->hidden); device->hidden = NULL; } if (device->gl_data) { - free(device->gl_data); + SDL_free(device->gl_data); device->gl_data = NULL; } - free(device); + SDL_free(device); device = NULL; } } @@ -257,10 +257,10 @@ static int ph_SetupWindow(_THIS, int w, int h, int flags) } if (!currently_maximized) { - windowpos = getenv("SDL_VIDEO_WINDOW_POS"); - iscentered = getenv("SDL_VIDEO_CENTERED"); + windowpos = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + iscentered = SDL_getenv("SDL_VIDEO_CENTERED"); - if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0))) + if ((iscentered) || ((windowpos) && (SDL_strcmp(windowpos, "center")==0))) { PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent); if (desktop_mode.width>w) @@ -280,7 +280,7 @@ static int ph_SetupWindow(_THIS, int w, int h, int flags) { if (windowpos) { - if (sscanf(windowpos, "%d,%d", &x, &y) == 2) + if (SDL_sscanf(windowpos, "%d,%d", &x, &y) == 2) { if ((xhwdata->ischromakey=0; do { - memset(&overlay->hwdata->caps, 0x00, sizeof(PgScalerCaps_t)); + SDL_memset(&overlay->hwdata->caps, 0x00, sizeof(PgScalerCaps_t)); overlay->hwdata->caps.size = sizeof(PgScalerCaps_t); rtncode = PgGetScalerCapabilities(overlay->hwdata->channel, i, &overlay->hwdata->caps); if (rtncode==0) @@ -498,9 +498,9 @@ void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) overlay->hwdata->CurrentFrameData = NULL; - free(overlay->hwdata->FrameData0); - free(overlay->hwdata->FrameData1); + SDL_free(overlay->hwdata->FrameData0); + SDL_free(overlay->hwdata->FrameData1); overlay->hwdata->FrameData0 = NULL; overlay->hwdata->FrameData1 = NULL; - free(overlay->hwdata); + SDL_free(overlay->hwdata); } diff --git a/src/video/picogui/SDL_pgevents.c b/src/video/picogui/SDL_pgevents.c index 4ab3356fb..aaec24b27 100644 --- a/src/video/picogui/SDL_pgevents.c +++ b/src/video/picogui/SDL_pgevents.c @@ -44,7 +44,7 @@ int PG_HandleResize(struct pgEvent *evt) int PG_HandleKey(struct pgEvent *evt) { SDL_keysym sym; - memset(&sym,0,sizeof(sym)); + SDL_memset(&sym,0,sizeof(sym)); sym.sym = evt->e.kbd.key; sym.mod = evt->e.kbd.mods; SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym); @@ -54,7 +54,7 @@ int PG_HandleKey(struct pgEvent *evt) int PG_HandleChar(struct pgEvent *evt) { SDL_keysym sym; - memset(&sym,0,sizeof(sym)); + SDL_memset(&sym,0,sizeof(sym)); sym.unicode = evt->e.kbd.key; sym.mod = evt->e.kbd.mods; SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym); diff --git a/src/video/picogui/SDL_pgvideo.c b/src/video/picogui/SDL_pgvideo.c index a8e808efe..45ae78119 100644 --- a/src/video/picogui/SDL_pgvideo.c +++ b/src/video/picogui/SDL_pgvideo.c @@ -85,8 +85,8 @@ static int PG_Available(void) static void PG_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *PG_CreateDevice(int devindex) @@ -94,20 +94,20 @@ static SDL_VideoDevice *PG_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = PG_VideoInit; diff --git a/src/video/ps2gs/SDL_gsevents.c b/src/video/ps2gs/SDL_gsevents.c index 1189d0ab7..a61a165ac 100644 --- a/src/video/ps2gs/SDL_gsevents.c +++ b/src/video/ps2gs/SDL_gsevents.c @@ -78,7 +78,7 @@ static void GS_vgainitkeymaps(int fd) /* Load all the keysym mappings */ for ( map=0; mapd_name); } fclose(status); @@ -373,10 +373,10 @@ static int gpm_available(void) len = read(cmdline, args, sizeof(args)); arg = args; while ( len > 0 ) { - if ( strcmp(arg, "-R") == 0 ) { + if ( SDL_strcmp(arg, "-R") == 0 ) { available = 1; } - arglen = strlen(arg)+1; + arglen = SDL_strlen(arg)+1; len -= arglen; arg += arglen; } @@ -435,7 +435,7 @@ static int detect_imps2(int fd) imps2 = 0; - if ( getenv("SDL_MOUSEDEV_IMPS2") ) { + if ( SDL_getenv("SDL_MOUSEDEV_IMPS2") ) { imps2 = 1; } if ( ! imps2 ) { @@ -487,8 +487,8 @@ int GS_OpenMouse(_THIS) const char *mousedev; const char *mousedrv; - mousedrv = getenv("SDL_MOUSEDRV"); - mousedev = getenv("SDL_MOUSEDEV"); + mousedrv = SDL_getenv("SDL_MOUSEDRV"); + mousedev = SDL_getenv("SDL_MOUSEDEV"); mouse_fd = -1; /* STD MICE */ @@ -752,7 +752,7 @@ static void handle_mouse(_THIS) GS_vgamousecallback(button, dx, dy); } if ( i < nread ) { - memcpy(mousebuf, &mousebuf[i], (nread-i)); + SDL_memcpy(mousebuf, &mousebuf[i], (nread-i)); start = (nread-i); } else { start = 0; diff --git a/src/video/ps2gs/SDL_gsvideo.c b/src/video/ps2gs/SDL_gsvideo.c index df9030d86..c26326bda 100644 --- a/src/video/ps2gs/SDL_gsvideo.c +++ b/src/video/ps2gs/SDL_gsvideo.c @@ -76,8 +76,8 @@ static int GS_Available(void) static void GS_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *GS_CreateDevice(int devindex) @@ -85,20 +85,20 @@ static SDL_VideoDevice *GS_CreateDevice(int devindex) SDL_VideoDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + this = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( this ) { - memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { - free(this); + SDL_free(this); } return(0); } - memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); mouse_fd = -1; keyboard_fd = -1; @@ -335,7 +335,7 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat) if ( GS_OpenMouse(this) < 0 ) { const char *sdl_nomouse; - sdl_nomouse = getenv("SDL_NOMOUSE"); + sdl_nomouse = SDL_getenv("SDL_NOMOUSE"); if ( ! sdl_nomouse ) { GS_VideoQuit(this); SDL_SetError("Unable to open mouse"); @@ -531,13 +531,13 @@ static SDL_Surface *GS_SetVideoMode(_THIS, SDL_Surface *current, (mapped_mem + pixels_len); image_tags_mem = (unsigned long long *) ((caddr_t)head_tags_mem + sizeof(head_tags)); - memcpy(head_tags_mem, head_tags, sizeof(head_tags)); + SDL_memcpy(head_tags_mem, head_tags, sizeof(head_tags)); if ( saved_vinfo.mode != PS2_GS_VESA ) { tex_tags_mem = (unsigned long long *) ((caddr_t)image_tags_mem + ((2*MAXTAGS)*16)); scale_tags_mem = (unsigned long long *) ((caddr_t)tex_tags_mem + sizeof(tex_tags)); - memcpy(tex_tags_mem, tex_tags, sizeof(tex_tags)); + SDL_memcpy(tex_tags_mem, tex_tags, sizeof(tex_tags)); tex_tags_mem[2] = (vinfo.h * vinfo.w) / 64 + ((unsigned long long)screen_image.fbw << 14) + @@ -546,7 +546,7 @@ static SDL_Surface *GS_SetVideoMode(_THIS, SDL_Surface *current, ((unsigned long long)power_of_2(screen_image.h) << 30) + ((unsigned long long)1 << 34) + ((unsigned long long)1 << 35); - memcpy(scale_tags_mem, scale_tags, sizeof(scale_tags)); + SDL_memcpy(scale_tags_mem, scale_tags, sizeof(scale_tags)); scale_tags_mem[8] = ((unsigned long long)screen_image.w * 16) + (((unsigned long long)screen_image.h * 16) << 16); @@ -556,7 +556,7 @@ static SDL_Surface *GS_SetVideoMode(_THIS, SDL_Surface *current, } } current->pixels = NULL; - if ( getenv("SDL_FULLSCREEN_UPDATE") ) { + if ( SDL_getenv("SDL_FULLSCREEN_UPDATE") ) { /* Correct semantics */ current->flags |= SDL_ASYNCBLIT; } else { diff --git a/src/video/ps2gs/SDL_gsyuv.c b/src/video/ps2gs/SDL_gsyuv.c index e8612f907..d93805b8b 100644 --- a/src/video/ps2gs/SDL_gsyuv.c +++ b/src/video/ps2gs/SDL_gsyuv.c @@ -114,12 +114,12 @@ SDL_Overlay *GS_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD } /* Create the overlay structure */ - overlay = (SDL_Overlay *)malloc(sizeof *overlay); + overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); if ( overlay == NULL ) { SDL_OutOfMemory(); return(NULL); } - memset(overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -131,7 +131,7 @@ SDL_Overlay *GS_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD overlay->hw_overlay = 1; /* Create the pixel data */ - hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata); + hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); overlay->hwdata = hwdata; if ( hwdata == NULL ) { SDL_FreeYUVOverlay(overlay); @@ -139,7 +139,7 @@ SDL_Overlay *GS_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD return(NULL); } hwdata->ipu_fd = -1; - hwdata->pixels = (Uint8 *)malloc(width*height*2); + hwdata->pixels = (Uint8 *)SDL_malloc(width*height*2); if ( hwdata->pixels == NULL ) { SDL_FreeYUVOverlay(overlay); SDL_OutOfMemory(); @@ -202,7 +202,7 @@ SDL_Overlay *GS_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD /* Allocate memory for the DMA packets */ hwdata->plist.num = hwdata->macroblocks * 4 + 1; - hwdata->plist.packet = (struct ps2_packet *)malloc( + hwdata->plist.packet = (struct ps2_packet *)SDL_malloc( hwdata->plist.num*sizeof(struct ps2_packet)); if ( ! hwdata->plist.packet ) { SDL_FreeYUVOverlay(overlay); @@ -453,11 +453,11 @@ void GS_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) munmap(hwdata->dma_mem, hwdata->dma_len); } if ( hwdata->plist.packet ) { - free(hwdata->plist.packet); + SDL_free(hwdata->plist.packet); } if ( hwdata->pixels ) { - free(hwdata->pixels); + SDL_free(hwdata->pixels); } - free(hwdata); + SDL_free(hwdata); } } diff --git a/src/video/qtopia/SDL_QWin.cc b/src/video/qtopia/SDL_QWin.cc index dc6335981..c5592d057 100644 --- a/src/video/qtopia/SDL_QWin.cc +++ b/src/video/qtopia/SDL_QWin.cc @@ -243,7 +243,7 @@ bool SDL_QWin::repaintRotation0(const QRect& rect) { uchar *fb = (uchar*)my_painter->frameBuffer(); uchar *buf = (uchar*)my_image->bits(); if(rect == my_image->rect()) { - memcpy(fb, buf, width()*height()*2); + SDL_memcpy(fb, buf, width()*height()*2); } else { int h = rect.height(); int wd = rect.width()<<1; @@ -252,7 +252,7 @@ bool SDL_QWin::repaintRotation0(const QRect& rect) { fb += (rect.left()<<1) + rect.top() * my_painter->lineStep(); buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine(); while(h--) { - memcpy(fb, buf, wd); + SDL_memcpy(fb, buf, wd); fb += fblineadd; buf += buflineadd; } @@ -279,7 +279,7 @@ bool SDL_QWin::repaintRotation3(const QRect& rect) { uchar *fb = (uchar*)my_painter->frameBuffer(); uchar *buf = (uchar*)my_image->bits(); if(rect == my_image->rect()) { - memcpy(fb, buf, width()*height()*2); + SDL_memcpy(fb, buf, width()*height()*2); } else { int h = rect.height(); int wd = rect.width()<<1; @@ -288,7 +288,7 @@ bool SDL_QWin::repaintRotation3(const QRect& rect) { fb += (rect.left()<<1) + rect.top() * my_painter->lineStep(); buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine(); while(h--) { - memcpy(fb, buf, wd); + SDL_memcpy(fb, buf, wd); fb += fblineadd; buf += buflineadd; } diff --git a/src/video/qtopia/SDL_sysevents.cc b/src/video/qtopia/SDL_sysevents.cc index f664433f6..605996237 100644 --- a/src/video/qtopia/SDL_sysevents.cc +++ b/src/video/qtopia/SDL_sysevents.cc @@ -85,7 +85,7 @@ void QT_PumpEvents(_THIS) } /* If our view is active, we'll find key changes here */ - if ( memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) { + if ( SDL_memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) { for ( i=0; i<16; ++i ) { Uint8 new_state, transition; @@ -149,7 +149,7 @@ void QT_InitOSKeymap(_THIS) /* Initialize all the key states as "up" */ key_flip = 0; - memset(keyinfo[key_flip].key_states, 0, 16); + SDL_memset(keyinfo[key_flip].key_states, 0, 16); /* Initialize the key translation table */ for ( i=0; ihidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *QT_CreateDevice(int devindex) @@ -91,20 +91,20 @@ extern "C" { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = QT_VideoInit; @@ -185,7 +185,7 @@ extern "C" { } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *)malloc(sizeof *mode); + mode = (SDL_Rect *)SDL_malloc(sizeof *mode); if ( mode == NULL ) { SDL_OutOfMemory(); return(-1); @@ -201,11 +201,11 @@ extern "C" { /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if ( SDL_modelist[index] == NULL ) { SDL_OutOfMemory(); SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return(-1); } SDL_modelist[index][next_mode] = mode; @@ -288,7 +288,7 @@ extern "C" { current->h = desktop_size.height(); } else if(width <= desktop_size.height() && height <= desktop_size.width()) { // Landscape mode - char * envString = getenv(SDL_QT_ROTATION_ENV_NAME); + char * envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME); int envValue = envString ? atoi(envString) : 0; screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90; current->h = desktop_size.width(); diff --git a/src/video/riscos/SDL_riscosFullScreenVideo.c b/src/video/riscos/SDL_riscosFullScreenVideo.c index 522bbf528..81cc30258 100644 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c @@ -198,7 +198,7 @@ SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface *current, if (riscos_backbuffer == 3) this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp); else - this->hidden->bank[0] = malloc(height * current->pitch); + this->hidden->bank[0] = SDL_malloc(height * current->pitch); if (this->hidden->bank[0] == 0) { RISCOS_RestoreWimpMode(); @@ -210,7 +210,7 @@ SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface *current, } /* Store address of allocated screen bank to be freed later */ - if (this->hidden->alloc_bank) free(this->hidden->alloc_bank); + if (this->hidden->alloc_bank) SDL_free(this->hidden->alloc_bank); if (create_back_buffer) { this->hidden->alloc_bank = this->hidden->bank[0]; @@ -223,8 +223,8 @@ SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface *current, this->hidden->alloc_bank = 0; // Clear both banks to black - memset(this->hidden->bank[0], 0, height * current->pitch); - memset(this->hidden->bank[1], 0, height * current->pitch); + SDL_memset(this->hidden->bank[0], 0, height * current->pitch); + SDL_memset(this->hidden->bank[1], 0, height * current->pitch); this->hidden->current_bank = 0; current->pixels = this->hidden->bank[0]; @@ -316,7 +316,7 @@ void FULLSCREEN_BuildModeList(_THIS) /* Video memory should be in r[5] */ this->info.video_mem = regs.r[5]/1024; - enumInfo = (unsigned char *)malloc(-regs.r[7]); + enumInfo = (unsigned char *)SDL_malloc(-regs.r[7]); if (enumInfo == NULL) { SDL_OutOfMemory(); @@ -352,7 +352,7 @@ void FULLSCREEN_BuildModeList(_THIS) enum_ptr += blockInfo[0]; } - free(enumInfo); + SDL_free(enumInfo); /* Sort the mode lists */ for ( j=0; jhidden->bank[1] + rects->x * xmult + rects->y * pitch; for (row = 0; row < rects->h; row++) { - memcpy(to, from, rects->w * xmult); + SDL_memcpy(to, from, rects->w * xmult); from += pitch; to += pitch; } @@ -594,7 +594,7 @@ static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h) } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *)malloc(sizeof *mode); + mode = (SDL_Rect *)SDL_malloc(sizeof *mode); if ( mode == NULL ) { SDL_OutOfMemory(); return(-1); @@ -607,11 +607,11 @@ static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h) /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if ( SDL_modelist[index] == NULL ) { SDL_OutOfMemory(); SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return(-1); } SDL_modelist[index][next_mode] = mode; @@ -663,7 +663,7 @@ static void FULLSCREEN_EnableEscape() /** Store caption in case this is called before we create a window */ void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon) { - strncpy(this->hidden->title, title, 255); + SDL_strncpy(this->hidden->title, title, 255); this->hidden->title[255] = 0; } @@ -772,7 +772,7 @@ int FULLSCREEN_ToggleFromWimp(_THIS) this->screen->pixels = this->hidden->bank[0]; /* Copy back buffer to screen memory */ - memcpy(this->hidden->bank[1], this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel); + SDL_memcpy(this->hidden->bank[1], this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel); FULLSCREEN_SetDeviceMode(this); return 1; diff --git a/src/video/riscos/SDL_riscosevents.c b/src/video/riscos/SDL_riscosevents.c index 59f550705..e2bb8a4ca 100644 --- a/src/video/riscos/SDL_riscosevents.c +++ b/src/video/riscos/SDL_riscosevents.c @@ -210,7 +210,7 @@ void RISCOS_InitOSKeymap(_THIS) RO_keymap[123] = SDLK_KP5; RO_keymap[124] = SDLK_KP2; - memset(RO_pressed, 0, ROKEYBD_ARRAYSIZE); + SDL_memset(RO_pressed, 0, ROKEYBD_ARRAYSIZE); } diff --git a/src/video/riscos/SDL_riscosmouse.c b/src/video/riscos/SDL_riscosmouse.c index 1bc85b3dc..67549aa34 100644 --- a/src/video/riscos/SDL_riscosmouse.c +++ b/src/video/riscos/SDL_riscosmouse.c @@ -60,8 +60,8 @@ void WIMP_SetSDLCursorPalette(); void RISCOS_FreeWMCursor(_THIS, WMcursor *cursor) { - free(cursor->data); - free(cursor); + SDL_free(cursor->data); + SDL_free(cursor); } WMcursor *RISCOS_CreateWMCursor(_THIS, @@ -80,17 +80,17 @@ WMcursor *RISCOS_CreateWMCursor(_THIS, } /* Allocate the cursor */ - cursor = (WMcursor *)malloc(sizeof(*cursor)); + cursor = (WMcursor *)SDL_malloc(sizeof(*cursor)); if ( cursor == NULL ) { SDL_SetError("Out of memory"); return(NULL); } /* Note: SDL says width must be a multiple of 8 */ - cursor_data = malloc(w/4 * h); + cursor_data = SDL_malloc(w/4 * h); if (cursor_data == NULL) { - free(cursor); + SDL_free(cursor); SDL_SetError("Out of memory"); return(NULL); } diff --git a/src/video/riscos/SDL_riscossprite.c b/src/video/riscos/SDL_riscossprite.c index 2fcf07807..8a41830f1 100644 --- a/src/video/riscos/SDL_riscossprite.c +++ b/src/video/riscos/SDL_riscossprite.c @@ -70,7 +70,7 @@ unsigned char *WIMP_CreateBuffer(int width, int height, int bpp) } size = bytesPerRow * height; - buffer = malloc( (size_t) size + offsetToSpriteData ); + buffer = SDL_malloc( (size_t) size + offsetToSpriteData ); if (!buffer) return NULL; /* Initialise a sprite area */ @@ -129,7 +129,7 @@ unsigned char *WIMP_CreateBuffer(int width, int height, int bpp) } } else { - free(buffer); + SDL_free(buffer); buffer = NULL; } @@ -153,14 +153,14 @@ void WIMP_SetupPlotInfo(_THIS) regs.r[6] = 0; regs.r[7] = 0; - if (this->hidden->pixtrans) free(this->hidden->pixtrans); + if (this->hidden->pixtrans) SDL_free(this->hidden->pixtrans); this->hidden->pixtrans = 0; /* Get the size required for the buffer */ _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); if (regs.r[4]) { - this->hidden->pixtrans = malloc(regs.r[4]); + this->hidden->pixtrans = SDL_malloc(regs.r[4]); regs.r[4] = (unsigned int)this->hidden->pixtrans; /* Actually read the buffer */ diff --git a/src/video/riscos/SDL_riscostask.c b/src/video/riscos/SDL_riscostask.c index fd3a5d2a7..20026a4fa 100644 --- a/src/video/riscos/SDL_riscostask.c +++ b/src/video/riscos/SDL_riscostask.c @@ -189,19 +189,19 @@ int RISCOS_GetTaskName(char *task_name) if (_kernel_swi(OS_GetEnv, ®s, ®s) == 0) { char *command_line = (char *)regs.r[0]; - char *buffer = malloc(strlen(command_line)+1); + char *buffer = SDL_malloc(SDL_strlen(command_line)+1); char *env_var; char *p; - strcpy(buffer, command_line); - p = strchr(buffer, ' '); + SDL_strcpy(buffer, command_line); + p = SDL_strchr(buffer, ' '); if (p) *p = 0; - p = strrchr(buffer, '.'); + p = SDL_strrchr(buffer, '.'); if (p == 0) p = buffer; if (stricmp(p+1,"!RunImage") == 0) { *p = 0; - p = strrchr(buffer, '.'); + p = SDL_strrchr(buffer, '.'); if (p == 0) p = buffer; } if (*p == '.') p++; @@ -210,8 +210,8 @@ int RISCOS_GetTaskName(char *task_name) if (*p == '<') { // Probably in the form - char *q = strchr(p, '$'); - if (q == 0) q = strchr(p,'>'); /* Use variable name if not */ + char *q = SDL_strchr(p, '$'); + if (q == 0) q = SDL_strchr(p,'>'); /* Use variable name if not */ if (q) *q = 0; p++; /* Move over the < */ } @@ -219,45 +219,45 @@ int RISCOS_GetTaskName(char *task_name) if (*p) { /* Read variables that effect the RISC OS SDL engine for this task */ - env_var = malloc(strlen(p) + 18); /* 18 is larger than the biggest variable name */ + env_var = SDL_malloc(SDL_strlen(p) + 18); /* 18 is larger than the biggest variable name */ if (env_var) { char *env_val; /* See if a variable of form SDL$$TaskName exists */ - strcpy(env_var, "SDL$"); + SDL_strcpy(env_var, "SDL$"); strcat(env_var, p); strcat(env_var, "$TaskName"); - env_val = getenv(env_var); - if (env_val) strncpy(task_name, env_val, 31); + env_val = SDL_getenv(env_var); + if (env_val) SDL_strncpy(task_name, env_val, 31); - strcpy(env_var, "SDL$"); + SDL_strcpy(env_var, "SDL$"); strcat(env_var, p); strcat(env_var, "$BackBuffer"); - env_val = getenv(env_var); + env_val = SDL_getenv(env_var); if (env_val) riscos_backbuffer = atoi(env_val); - strcpy(env_var, "SDL$"); + SDL_strcpy(env_var, "SDL$"); strcat(env_var, p); strcat(env_var, "$CloseAction"); - env_val = getenv(env_var); - if (env_val && strcmp(env_val,"0") == 0) riscos_closeaction = 0; + env_val = SDL_getenv(env_var); + if (env_val && SDL_strcmp(env_val,"0") == 0) riscos_closeaction = 0; - free(env_var); + SDL_free(env_var); } - if (task_name[0] == 0) strncpy(task_name, p, 31); + if (task_name[0] == 0) SDL_strncpy(task_name, p, 31); task_name[31] = 0; } - free(buffer); + SDL_free(buffer); } - if (task_name[0] == 0) strcpy(task_name, "SDL Task"); + if (task_name[0] == 0) SDL_strcpy(task_name, "SDL Task"); return 1; } @@ -287,7 +287,7 @@ void RISCOS_StoreWimpMode() while(blockSize < 5 || retBlock[blockSize] != -1) blockSize++; blockSize++; - storeBlock = (int *)malloc(blockSize * sizeof(int)); + storeBlock = (int *)SDL_malloc(blockSize * sizeof(int)); retBlock = (int *)regs.r[1]; for ( j = 0; j < blockSize; j++) storeBlock[j] = retBlock[j]; @@ -320,7 +320,7 @@ void RISCOS_RestoreWimpMode() _kernel_swi(Wimp_SetMode, ®s, ®s); if (stored_mode < 0 || stored_mode > 256) { - free((int *)stored_mode); + SDL_free((int *)stored_mode); } stored_mode = -1; diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 4c5e1f7d1..6b4c53742 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -92,8 +92,8 @@ static int RISCOS_Available(void) static void RISCOS_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *RISCOS_CreateDevice(int devindex) @@ -101,20 +101,20 @@ static SDL_VideoDevice *RISCOS_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = RISCOS_VideoInit; @@ -225,7 +225,7 @@ void RISCOS_VideoQuit(_THIS) { RISCOS_ExitTask(); - if (this->hidden->alloc_bank) free(this->hidden->alloc_bank); + if (this->hidden->alloc_bank) SDL_free(this->hidden->alloc_bank); this->hidden->alloc_bank = 0; } diff --git a/src/video/riscos/SDL_wimppoll.c b/src/video/riscos/SDL_wimppoll.c index f929f21ba..99a5092d5 100644 --- a/src/video/riscos/SDL_wimppoll.c +++ b/src/video/riscos/SDL_wimppoll.c @@ -284,7 +284,7 @@ void WIMP_Poll(_THIS, int waitTime) SDL_VERSION(&wmmsg.version); wmmsg.eventCode = code; - memcpy(wmmsg.pollBlock, message, 64 * sizeof(int)); + SDL_memcpy(wmmsg.pollBlock, message, 64 * sizeof(int)); /* Fall out of polling loop if message is successfully posted */ if (SDL_PrivateSysWMEvent(&wmmsg)) doPoll = 0; diff --git a/src/video/riscos/SDL_wimpvideo.c b/src/video/riscos/SDL_wimpvideo.c index 6f9de7ed4..144ad5813 100644 --- a/src/video/riscos/SDL_wimpvideo.c +++ b/src/video/riscos/SDL_wimpvideo.c @@ -151,7 +151,7 @@ SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface *current, this->hidden->bank[1] = buffer; /* Start of buffer */ /* Remember sprite buffer so it can be freed later */ - if (this->hidden->alloc_bank) free(this->hidden->alloc_bank); + if (this->hidden->alloc_bank) SDL_free(this->hidden->alloc_bank); this->hidden->alloc_bank = buffer; current->pitch = width * bytesPerPixel; @@ -165,7 +165,7 @@ SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface *current, WIMP_ReadModeInfo(this); - memset(this->hidden->bank[0], 0, height * current->pitch); + SDL_memset(this->hidden->bank[0], 0, height * current->pitch); this->hidden->current_bank = 0; current->pixels = this->hidden->bank[0]; @@ -390,7 +390,7 @@ void WIMP_SetWMCaption(_THIS, const char *title, const char *icon) { _kernel_swi_regs regs; - strncpy(this->hidden->title, title, 255); + SDL_strncpy(this->hidden->title, title, 255); this->hidden->title[255] = 0; if (RISCOS_GetWimpVersion() < 380) @@ -462,7 +462,7 @@ int WIMP_ToggleFromFullScreen(_THIS) if (bpp == 8) data += 2048; /* 8bpp sprite have palette first */ if (buffer == NULL) return 0; - memcpy(data, this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel); + SDL_memcpy(data, this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel); } /* else We've switch to full screen before so we already have a sprite */ @@ -488,7 +488,7 @@ int WIMP_ToggleFromFullScreen(_THIS) if (riscos_backbuffer == 0) riscos_backbuffer = 1; - if (buffer && old_alloc_bank) free(old_alloc_bank); + if (buffer && old_alloc_bank) SDL_free(old_alloc_bank); return 1; } else @@ -497,7 +497,7 @@ int WIMP_ToggleFromFullScreen(_THIS) this->hidden->bank[0] = old_bank[0]; this->hidden->bank[1] = old_bank[1]; this->hidden->alloc_bank = old_alloc_bank; - if (buffer) free(buffer); + if (buffer) SDL_free(buffer); RISCOS_StoreWimpMode(); FULLSCREEN_SetMode(width, height, bpp); diff --git a/src/video/svga/SDL_svgaevents.c b/src/video/svga/SDL_svgaevents.c index 6f0c529b6..2afdcbe91 100644 --- a/src/video/svga/SDL_svgaevents.c +++ b/src/video/svga/SDL_svgaevents.c @@ -69,7 +69,7 @@ int SVGA_initkeymaps(int fd) /* Load all the keysym mappings */ for ( map=0; maphidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *SVGA_CreateDevice(int devindex) @@ -113,20 +113,20 @@ static SDL_VideoDevice *SVGA_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = SVGA_VideoInit; @@ -278,24 +278,24 @@ int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat) return(-1); } for ( i=0; ihidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *VGL_CreateDevice(int devindex) @@ -117,20 +117,20 @@ static SDL_VideoDevice *VGL_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = VGL_VideoInit; @@ -188,7 +188,7 @@ static int VGL_AddMode(_THIS, VGLMode *inmode) } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *)malloc(sizeof *mode); + mode = (SDL_Rect *)SDL_malloc(sizeof *mode); if (mode == NULL) { SDL_OutOfMemory(); return -1; @@ -201,11 +201,11 @@ static int VGL_AddMode(_THIS, VGLMode *inmode) /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { SDL_OutOfMemory(); SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return -1; } SDL_modelist[index][next_mode] = mode; @@ -243,7 +243,7 @@ int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat) } /* Enable mouse and keyboard support */ - if (getenv("SDL_NO_RAWKBD") == NULL) { + if (SDL_getenv("SDL_NO_RAWKBD") == NULL) { if (VGLKeyboardInit(VGL_CODEKEYS) != 0) { SDL_SetError("Unable to initialize keyboard"); return -1; @@ -340,7 +340,7 @@ SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface *current, return NULL; } - VGLCurMode = realloc(VGLCurMode, sizeof(VGLMode)); + VGLCurMode = SDL_realloc(VGLCurMode, sizeof(VGLMode)); VGLCurMode->ModeInfo = *VGLDisplay; VGLCurMode->Depth = modes[i]->Depth; VGLCurMode->ModeId = modes[i]->ModeId; @@ -466,7 +466,7 @@ void VGL_VideoQuit(_THIS) /* Reset the console video mode if we actually initialised one */ if (VGLCurMode != NULL) { VGLEnd(); - free(VGLCurMode); + SDL_free(VGLCurMode); VGLCurMode = NULL; } @@ -480,9 +480,9 @@ void VGL_VideoQuit(_THIS) for (i = 0; i < NUM_MODELISTS; i++) { if (SDL_modelist[i] != NULL) { for (j = 0; SDL_modelist[i][j] != NULL; ++j) { - free(SDL_modelist[i][j]); + SDL_free(SDL_modelist[i][j]); } - free(SDL_modelist[i]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } @@ -508,7 +508,7 @@ VGLListModes(int depth, int mem_model) int adptype, i, modenum; if (modes == NULL) { - modes = malloc(sizeof(VGLMode *) * M_VESA_MODE_MAX); + modes = SDL_malloc(sizeof(VGLMode *) * M_VESA_MODE_MAX); bzero(modes, sizeof(VGLMode *) * M_VESA_MODE_MAX); } modesp = modes; @@ -621,7 +621,7 @@ VGLListModes(int depth, int mem_model) } if (*modesp != NULL) { - free(*modesp); + SDL_free(*modesp); *modesp = NULL; } diff --git a/src/video/wincommon/SDL_lowvideo.h b/src/video/wincommon/SDL_lowvideo.h index 96fd8304f..6776515a3 100644 --- a/src/video/wincommon/SDL_lowvideo.h +++ b/src/video/wincommon/SDL_lowvideo.h @@ -35,15 +35,15 @@ SDL_VideoSurface && \ ((SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && \ (((SDL_VideoSurface->flags & SDL_OPENGL ) == SDL_OPENGL ) || \ - ((strcmp(this->name, "windib") == 0) || \ - (strcmp(this->name, "gapi") == 0))) \ + ((SDL_strcmp(this->name, "windib") == 0) || \ + (SDL_strcmp(this->name, "gapi") == 0))) \ ) #define DDRAW_FULLSCREEN() \ ( \ SDL_VideoSurface && \ ((SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && \ ((SDL_VideoSurface->flags & SDL_OPENGL ) != SDL_OPENGL ) && \ - (strcmp(this->name, "directx") == 0) \ + (SDL_strcmp(this->name, "directx") == 0) \ ) #define DINPUT_FULLSCREEN() DDRAW_FULLSCREEN() diff --git a/src/video/wincommon/SDL_sysevents.c b/src/video/wincommon/SDL_sysevents.c index fd889ba8a..7441d5742 100644 --- a/src/video/wincommon/SDL_sysevents.c +++ b/src/video/wincommon/SDL_sysevents.c @@ -706,13 +706,13 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst) if ( name ) { #ifdef _WIN32_WCE /* WinCE uses the UNICODE version */ - int nLen = strlen(name)+1; - SDL_Appname = malloc(nLen*2); + int nLen = SDL_strlen(name)+1; + SDL_Appname = SDL_malloc(nLen*2); MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen); #else - int nLen = strlen(name)+1; - SDL_Appname = malloc(nLen); - strcpy(SDL_Appname, name); + int nLen = SDL_strlen(name)+1; + SDL_Appname = SDL_malloc(nLen); + SDL_strcpy(SDL_Appname, name); #endif /* _WIN32_WCE */ SDL_Appstyle = style; SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); @@ -783,7 +783,7 @@ static int Is9xME() { OSVERSIONINFO info; - memset(&info, 0, sizeof(info)); + SDL_memset(&info, 0, sizeof(info)); info.dwOSVersionInfoSize = sizeof(info); if (!GetVersionEx(&info)) { return 0; @@ -798,7 +798,7 @@ static int GetCodePage() int cp = GetACP(); if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { - cp = strtol(buff, NULL, 0); + cp = SDL_strtol(buff, NULL, 0); } return cp; } diff --git a/src/video/wincommon/SDL_sysmouse.c b/src/video/wincommon/SDL_sysmouse.c index 99653a63f..4935c9c79 100644 --- a/src/video/wincommon/SDL_sysmouse.c +++ b/src/video/wincommon/SDL_sysmouse.c @@ -96,11 +96,11 @@ void WIN_FreeWMCursor(_THIS, WMcursor *cursor) if ( cursor->curs != NULL ) DestroyCursor(cursor->curs); if ( cursor->ands != NULL ) - free(cursor->ands); + SDL_free(cursor->ands); if ( cursor->xors != NULL ) - free(cursor->xors); + SDL_free(cursor->xors); #endif /* !USE_STATIC_CURSOR */ - free(cursor); + SDL_free(cursor); } WMcursor *WIN_CreateWMCursor(_THIS, @@ -110,7 +110,7 @@ WMcursor *WIN_CreateWMCursor(_THIS, WMcursor *cursor; /* Allocate the cursor */ - cursor = (WMcursor *)malloc(sizeof(*cursor)); + cursor = (WMcursor *)SDL_malloc(sizeof(*cursor)); if ( cursor ) { cursor->curs = LoadCursor(NULL, IDC_ARROW); } @@ -132,7 +132,7 @@ WMcursor *WIN_CreateWMCursor(_THIS, } /* Allocate the cursor */ - cursor = (WMcursor *)malloc(sizeof(*cursor)); + cursor = (WMcursor *)SDL_malloc(sizeof(*cursor)); if ( cursor == NULL ) { SDL_SetError("Out of memory"); return(NULL); @@ -144,8 +144,8 @@ WMcursor *WIN_CreateWMCursor(_THIS, /* Pad out to the normal cursor size */ run = PAD_BITS(w); pad = PAD_BITS(allowed_x)-run; - aptr = cursor->ands = (Uint8 *)malloc((run+pad)*allowed_y); - xptr = cursor->xors = (Uint8 *)malloc((run+pad)*allowed_y); + aptr = cursor->ands = (Uint8 *)SDL_malloc((run+pad)*allowed_y); + xptr = cursor->xors = (Uint8 *)SDL_malloc((run+pad)*allowed_y); if ( (aptr == NULL) || (xptr == NULL) ) { WIN_FreeWMCursor(NULL, cursor); SDL_OutOfMemory(); @@ -158,16 +158,16 @@ WMcursor *WIN_CreateWMCursor(_THIS, memnot(aptr, mask, run); mask += run; aptr += run; - memset(xptr, 0, pad); + SDL_memset(xptr, 0, pad); xptr += pad; - memset(aptr, ~0, pad); + SDL_memset(aptr, ~0, pad); aptr += pad; } pad += run; for ( ; ibiSize = sizeof(*icon_win32)-sizeof(icon_win32->biColors); @@ -144,7 +144,7 @@ void WIN_SetWMIcon(_THIS, SDL_Surface *icon, Uint8 *mask) if (icon->format->palette && (icon->format->BitsPerPixel == icon_256->format->BitsPerPixel)){ Uint8 black; - memcpy(pal_256->colors, icon->format->palette->colors, + SDL_memcpy(pal_256->colors, icon->format->palette->colors, pal_256->ncolors*sizeof(SDL_Color)); /* Make sure that 0 is black! */ black = SDL_FindColor(pal_256, 0x00, 0x00, 0x00); @@ -234,7 +234,7 @@ void WIN_SetWMCaption(_THIS, const char *title, const char *icon) { #ifdef _WIN32_WCE /* WinCE uses the UNICODE version */ - int nLen = strlen(title)+1; + int nLen = SDL_strlen(title)+1; LPWSTR lpszW = alloca(nLen*2); MultiByteToWideChar(CP_ACP, 0, title, -1, lpszW, nLen); SetWindowText(SDL_Window, lpszW); diff --git a/src/video/wincommon/SDL_wingl.c b/src/video/wincommon/SDL_wingl.c index 1a14815f5..179b1ef57 100644 --- a/src/video/wincommon/SDL_wingl.c +++ b/src/video/wincommon/SDL_wingl.c @@ -80,7 +80,7 @@ static int ExtensionSupported(const char *extension, const char *extensions) const char *where, *terminator; /* Extension names should not have spaces. */ - where = strchr(extension, ' '); + where = SDL_strchr(extension, ' '); if ( where || *extension == '\0' ) return 0; @@ -95,10 +95,10 @@ static int ExtensionSupported(const char *extension, const char *extensions) for (;;) { - where = strstr(start, extension); + where = SDL_strstr(start, extension); if (!where) break; - terminator = where + strlen(extension); + terminator = where + SDL_strlen(extension); if (where == start || *(where - 1) == ' ') if (*terminator == ' ' || *terminator == '\0') return 1; @@ -191,7 +191,7 @@ int WIN_GL_SetupWindow(_THIS) } /* Set up the pixel format descriptor with our needed format */ - memset(&GL_pfd, 0, sizeof(GL_pfd)); + SDL_memset(&GL_pfd, 0, sizeof(GL_pfd)); GL_pfd.nSize = sizeof(GL_pfd); GL_pfd.nVersion = 1; GL_pfd.dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL); @@ -534,7 +534,7 @@ int WIN_GL_LoadLibrary(_THIS, const char* path) WIN_GL_UnloadLibrary(this); /* Load new function pointers */ - memset(this->gl_data, 0, sizeof(*this->gl_data)); + SDL_memset(this->gl_data, 0, sizeof(*this->gl_data)); this->gl_data->wglGetProcAddress = (void * (WINAPI *)(const char *)) GetProcAddress(handle, "wglGetProcAddress"); this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC)) @@ -554,7 +554,7 @@ int WIN_GL_LoadLibrary(_THIS, const char* path) } this->gl_config.dll_handle = handle; - strcpy(this->gl_config.driver_path, path); + SDL_strcpy(this->gl_config.driver_path, path); this->gl_config.driver_loaded = 1; return 0; } diff --git a/src/video/windib/SDL_dibevents.c b/src/video/windib/SDL_dibevents.c index 220c41646..ec690cf13 100644 --- a/src/video/windib/SDL_dibevents.c +++ b/src/video/windib/SDL_dibevents.c @@ -404,7 +404,7 @@ static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, in int DIB_CreateWindow(_THIS) { - char *windowid = getenv("SDL_WINDOWID"); + char *windowid = SDL_getenv("SDL_WINDOWID"); SDL_RegisterApp(NULL, 0, 0); @@ -412,12 +412,12 @@ int DIB_CreateWindow(_THIS) if ( SDL_windowid ) { #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) /* wince 2.1 does not have strtol */ - wchar_t *windowid_t = malloc((strlen(windowid) + 1) * sizeof(wchar_t)); - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, strlen(windowid) + 1); + wchar_t *windowid_t = SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t)); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, SDL_strlen(windowid) + 1); SDL_Window = (HWND)wcstol(windowid_t, NULL, 0); - free(windowid_t); + SDL_free(windowid_t); #else - SDL_Window = (HWND)strtol(windowid, NULL, 0); + SDL_Window = (HWND)SDL_strtol(windowid, NULL, 0); #endif if ( SDL_Window == NULL ) { SDL_SetError("Couldn't get user specified window"); diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index 11cc72367..2242b3b83 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -105,12 +105,12 @@ static void DIB_DeleteDevice(SDL_VideoDevice *device) { if ( device ) { if ( device->hidden ) { - free(device->hidden); + SDL_free(device->hidden); } if ( device->gl_data ) { - free(device->gl_data); + SDL_free(device->gl_data); } - free(device); + SDL_free(device); } } @@ -119,13 +119,13 @@ static SDL_VideoDevice *DIB_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - malloc((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ( (device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL) ) { @@ -133,8 +133,8 @@ static SDL_VideoDevice *DIB_CreateDevice(int devindex) DIB_DeleteDevice(device); return(NULL); } - memset(device->hidden, 0, (sizeof *device->hidden)); - memset(device->gl_data, 0, (sizeof *device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); /* Set the function pointers */ device->VideoInit = DIB_VideoInit; @@ -223,7 +223,7 @@ static int DIB_AddMode(_THIS, int bpp, int w, int h) } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *)malloc(sizeof *mode); + mode = (SDL_Rect *)SDL_malloc(sizeof *mode); if ( mode == NULL ) { SDL_OutOfMemory(); return(-1); @@ -236,11 +236,11 @@ static int DIB_AddMode(_THIS, int bpp, int w, int h) /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); + SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); if ( SDL_modelist[index] == NULL ) { SDL_OutOfMemory(); SDL_nummodes[index] = 0; - free(mode); + SDL_free(mode); return(-1); } SDL_modelist[index][next_mode] = mode; @@ -270,7 +270,7 @@ static HPALETTE DIB_CreatePalette(int bpp) for ( i=0; ipalVersion = 0x300; palette->palNumEntries = ncolors; @@ -278,7 +278,7 @@ static HPALETTE DIB_CreatePalette(int bpp) GetSystemPaletteEntries(hdc, 0, ncolors, palette->palPalEntry); ReleaseDC(SDL_Window, hdc); handle = CreatePalette(palette); - free(palette); + SDL_free(palette); } return handle; @@ -339,7 +339,7 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Sort the mode lists */ for ( i=0; i 0 ) { - qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); + SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); } } #endif /* !NO_CHANGEDISPLAYSETTINGS */ @@ -400,8 +400,8 @@ static int DIB_SussScreenDepth() * 8-bit modes) or bitfields (for 16- and 32-bit modes) */ dib_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD); - dib_hdr = (LPBITMAPINFOHEADER) malloc(dib_size); - memset(dib_hdr, 0, dib_size); + dib_hdr = (LPBITMAPINFOHEADER) SDL_malloc(dib_size); + SDL_memset(dib_hdr, 0, dib_size); dib_hdr->biSize = sizeof(BITMAPINFOHEADER); /* Get a device-dependent bitmap that's compatible with the @@ -531,7 +531,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, DEVMODE settings; BOOL changed; - memset(&settings, 0, sizeof(DEVMODE)); + SDL_memset(&settings, 0, sizeof(DEVMODE)); settings.dmSize = sizeof(DEVMODE); settings.dmBitsPerPel = video->format->BitsPerPixel; settings.dmPelsWidth = width; @@ -616,7 +616,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, binfo_size += video->format->palette->ncolors * sizeof(RGBQUAD); } - binfo = (BITMAPINFO *)malloc(binfo_size); + binfo = (BITMAPINFO *)SDL_malloc(binfo_size); if ( ! binfo ) { if ( video != current ) { SDL_FreeSurface(video); @@ -645,7 +645,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, } else { binfo->bmiHeader.biCompression = BI_RGB; /* BI_BITFIELDS for 565 vs 555 */ if ( video->format->palette ) { - memset(binfo->bmiColors, 0, + SDL_memset(binfo->bmiColors, 0, video->format->palette->ncolors*sizeof(RGBQUAD)); } } @@ -655,7 +655,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS, (void **)(&video->pixels), NULL, 0); ReleaseDC(SDL_Window, hdc); - free(binfo); + SDL_free(binfo); if ( screen_bmp == NULL ) { if ( video != current ) { SDL_FreeSurface(video); @@ -680,14 +680,14 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, const char *center = NULL; if ( !SDL_windowX && !SDL_windowY ) { - window = getenv("SDL_VIDEO_WINDOW_POS"); - center = getenv("SDL_VIDEO_CENTERED"); + window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + center = SDL_getenv("SDL_VIDEO_CENTERED"); if ( window ) { - if ( sscanf(window, "%d,%d", &x, &y) == 2 ) { + if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) { SDL_windowX = x; SDL_windowY = y; } - if ( strcmp(window, "center") == 0 ) { + if ( SDL_strcmp(window, "center") == 0 ) { center = window; } } @@ -878,7 +878,7 @@ void DIB_QuitGamma(_THIS) } /* Free the saved gamma memory */ - free(gamma_saved); + SDL_free(gamma_saved); gamma_saved = 0; } #endif /* !NO_GAMMA_SUPPORT */ @@ -895,7 +895,7 @@ int DIB_SetGammaRamp(_THIS, Uint16 *ramp) /* Set the ramp for the display */ if ( ! gamma_saved ) { - gamma_saved = (WORD *)malloc(3*256*sizeof(*gamma_saved)); + gamma_saved = (WORD *)SDL_malloc(3*256*sizeof(*gamma_saved)); if ( ! gamma_saved ) { SDL_OutOfMemory(); return -1; diff --git a/src/video/windx5/SDL_dx5events.c b/src/video/windx5/SDL_dx5events.c index 88c1615d9..58ea42192 100644 --- a/src/video/windx5/SDL_dx5events.c +++ b/src/video/windx5/SDL_dx5events.c @@ -112,13 +112,13 @@ static void SetDIerror(char *function, int code) error = "Device not initialized"; break; default: - snprintf(errbuf, SDL_arraysize(errbuf), + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: Unknown DirectInput error: 0x%x", function, code); break; } 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); return; @@ -199,7 +199,7 @@ static int DX5_DInputInit(_THIS) } /* Set buffered input -- we aren't polling */ - memset(&dipdw, 0, sizeof(dipdw)); + SDL_memset(&dipdw, 0, sizeof(dipdw)); dipdw.diph.dwSize = sizeof(dipdw); dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); dipdw.diph.dwObj = 0; @@ -598,7 +598,7 @@ static int DX5_CheckInput(_THIS, int timeout, BOOL processInput) result = IDirectInputDevice2_Poll(SDL_DIdev[i]); if ( (result == DIERR_INPUTLOST) || (result == DIERR_NOTACQUIRED) ) { - if ( strcmp(inputs[i].name, "mouse") == 0 ) { + if ( SDL_strcmp(inputs[i].name, "mouse") == 0 ) { mouse_lost = 1; } IDirectInputDevice2_Acquire(SDL_DIdev[i]); @@ -621,7 +621,7 @@ static int DX5_CheckInput(_THIS, int timeout, BOOL processInput) evtbuf, &numevents, 0); if ( (result == DIERR_INPUTLOST) || (result == DIERR_NOTACQUIRED) ) { - if ( strcmp(inputs[event].name, "mouse") == 0 ) { + if ( SDL_strcmp(inputs[event].name, "mouse") == 0 ) { mouse_lost = 1; } IDirectInputDevice2_Acquire(SDL_DIdev[event]); @@ -850,7 +850,7 @@ static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed) int DX5_CreateWindow(_THIS) { - char *windowid = getenv("SDL_WINDOWID"); + char *windowid = SDL_getenv("SDL_WINDOWID"); int i; /* Clear out DirectInput variables in case we fail */ @@ -864,7 +864,7 @@ int DX5_CreateWindow(_THIS) SDL_windowid = (windowid != NULL); if ( SDL_windowid ) { - SDL_Window = (HWND)strtol(windowid, NULL, 0); + SDL_Window = (HWND)SDL_strtol(windowid, NULL, 0); if ( SDL_Window == NULL ) { SDL_SetError("Couldn't get user specified window"); return(-1); diff --git a/src/video/windx5/SDL_dx5video.c b/src/video/windx5/SDL_dx5video.c index a5cdebe48..a73efb9b3 100644 --- a/src/video/windx5/SDL_dx5video.c +++ b/src/video/windx5/SDL_dx5video.c @@ -472,7 +472,7 @@ static int DX5_Available(void) LPDIRECTDRAWSURFACE3 DDrawSurf3; /* Try to create a DirectDrawSurface3 object */ - memset(&desc, 0, sizeof(desc)); + SDL_memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.dwFlags = DDSD_CAPS; desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY; @@ -546,12 +546,12 @@ static void DX5_DeleteDevice(SDL_VideoDevice *this) DX5_Unload(); if ( this ) { if ( this->hidden ) { - free(this->hidden); + SDL_free(this->hidden); } if ( this->gl_data ) { - free(this->gl_data); + SDL_free(this->gl_data); } - free(this); + SDL_free(this); } } @@ -565,13 +565,13 @@ static SDL_VideoDevice *DX5_CreateDevice(int devindex) } /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - malloc((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ( (device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL) ) { @@ -579,8 +579,8 @@ static SDL_VideoDevice *DX5_CreateDevice(int devindex) DX5_DeleteDevice(device); return(NULL); } - memset(device->hidden, 0, (sizeof *device->hidden)); - memset(device->gl_data, 0, (sizeof *device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); /* Set the function pointers */ device->VideoInit = DX5_VideoInit; @@ -678,7 +678,7 @@ static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata) break; } ++SDL_nummodes[bpp]; - enumrect = (struct DX5EnumRect*)malloc(sizeof(struct DX5EnumRect)); + enumrect = (struct DX5EnumRect*)SDL_malloc(sizeof(struct DX5EnumRect)); if ( !enumrect ) { SDL_OutOfMemory(); return(DDENUMRET_CANCEL); @@ -809,13 +809,13 @@ void SetDDerror(const char *function, int code) error = "Interface not present"; break; default: - snprintf(errbuf, SDL_arraysize(errbuf), + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: Unknown DirectDraw error: 0x%x", function, code); break; } 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); return; @@ -837,7 +837,7 @@ static int DX5_UpdateVideoInfo(_THIS) HRESULT result; /* Fill in our hardware acceleration capabilities */ - memset(&DDCaps, 0, sizeof(DDCaps)); + SDL_memset(&DDCaps, 0, sizeof(DDCaps)); DDCaps.dwSize = sizeof(DDCaps); result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *)&DDCaps, NULL); if ( result != DD_OK ) { @@ -946,7 +946,7 @@ int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat) for ( i=0; iformat->BitsPerPixel; settings.dmPelsWidth = width; @@ -1163,14 +1163,14 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, const char *center = NULL; if ( !SDL_windowX && !SDL_windowY ) { - window = getenv("SDL_VIDEO_WINDOW_POS"); - center = getenv("SDL_VIDEO_CENTERED"); + window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + center = SDL_getenv("SDL_VIDEO_CENTERED"); if ( window ) { - if ( sscanf(window, "%d,%d", &x, &y) == 2 ) { + if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) { SDL_windowX = x; SDL_windowY = y; } - if ( strcmp(window, "center") == 0 ) { + if ( SDL_strcmp(window, "center") == 0 ) { center = window; } } @@ -1306,7 +1306,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, DX5_UpdateVideoInfo(this); /* Create a primary DirectDraw surface */ - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = (DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY); @@ -1340,7 +1340,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, IDirectDrawSurface_Release(dd_surface1); /* Get the format of the primary DirectDraw surface */ - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_PIXELFORMAT|DDSD_CAPS; result = IDirectDrawSurface3_GetSurfaceDesc(SDL_primary, &ddsd); @@ -1465,7 +1465,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, video->pitch = (width*video->format->BytesPerPixel); /* Pitch needs to be QWORD (8-byte) aligned */ video->pitch = (video->pitch + 7) & ~7; - video->pixels = (void *)malloc(video->h*video->pitch); + video->pixels = (void *)SDL_malloc(video->h*video->pitch); if ( video->pixels == NULL ) { if ( video != current ) { SDL_FreeSurface(video); @@ -1493,7 +1493,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, } else { /* Necessary if we're going from window to fullscreen */ if ( video->pixels != NULL ) { - free(video->pixels); + SDL_free(video->pixels); video->pixels = NULL; } dd_surface3 = SDL_primary; @@ -1566,14 +1566,14 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, const char *center = NULL; if ( !SDL_windowX && !SDL_windowY ) { - window = getenv("SDL_VIDEO_WINDOW_POS"); - center = getenv("SDL_VIDEO_CENTERED"); + window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + center = SDL_getenv("SDL_VIDEO_CENTERED"); if ( window ) { - if ( sscanf(window, "%d,%d", &x, &y) == 2 ) { + if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) { SDL_windowX = x; SDL_windowY = y; } - if ( strcmp(window, "center") == 0 ) { + if ( SDL_strcmp(window, "center") == 0 ) { center = window; } } @@ -1629,7 +1629,7 @@ static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, /* Allocate the hardware acceleration data */ surface->hwdata = (struct private_hwdata *) - malloc(sizeof(*surface->hwdata)); + SDL_malloc(sizeof(*surface->hwdata)); if ( surface->hwdata == NULL ) { SDL_OutOfMemory(); return(-1); @@ -1637,7 +1637,7 @@ static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, dd_surface3 = NULL; /* Set up the surface description */ - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS| DDSD_PITCH|DDSD_PIXELFORMAT); @@ -1720,7 +1720,7 @@ static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, } /* Make sure the surface format was set properly */ - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); result = IDirectDrawSurface3_Lock(dd_surface3, NULL, &ddsd, (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL); @@ -1804,7 +1804,7 @@ static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, if ( (dd_surface3 != NULL) && (dd_surface3 != requested) ) { IDirectDrawSurface_Release(dd_surface3); } - free(surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata = NULL; return(-1); } @@ -1825,7 +1825,7 @@ void PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags) DDSURFACEDESC ddsd; /* Lock and load! */ - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); if ( IDirectDrawSurface3_Lock(surface, NULL, &ddsd, (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL) != DD_OK ) { @@ -2013,7 +2013,7 @@ static int DX5_LockHWSurface(_THIS, SDL_Surface *surface) /* Lock and load! */ dd_surface = surface->hwdata->dd_writebuf; - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL); @@ -2081,7 +2081,7 @@ static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface) if ( surface->hwdata->dd_surface != SDL_primary ) { IDirectDrawSurface3_Release(surface->hwdata->dd_surface); } - free(surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata = NULL; } } @@ -2177,7 +2177,7 @@ static void DX5_CompressPalette(_THIS, SDL_Color *colors, int ncolors, int maxco return; } seen = pool; - memset(seen, 0, ncolors*sizeof(int)); + SDL_memset(seen, 0, ncolors*sizeof(int)); order = pool+ncolors; /* Start with the brightest color */ @@ -2287,9 +2287,9 @@ static int DX5_SetGammaRamp(_THIS, Uint16 *ramp) } /* Set up the gamma ramp */ - memcpy(gamma_ramp.red, &ramp[0*256], 256*sizeof(*ramp)); - memcpy(gamma_ramp.green, &ramp[1*256], 256*sizeof(*ramp)); - memcpy(gamma_ramp.blue, &ramp[2*256], 256*sizeof(*ramp)); + SDL_memcpy(gamma_ramp.red, &ramp[0*256], 256*sizeof(*ramp)); + SDL_memcpy(gamma_ramp.green, &ramp[1*256], 256*sizeof(*ramp)); + SDL_memcpy(gamma_ramp.blue, &ramp[2*256], 256*sizeof(*ramp)); result = IDirectDrawGammaControl_SetGammaRamp(gamma, 0, &gamma_ramp); if ( result != DD_OK ) { SetDDerror("DirectDrawGammaControl::SetGammaRamp()", result); @@ -2335,9 +2335,9 @@ static int DX5_GetGammaRamp(_THIS, Uint16 *ramp) /* Set up the gamma ramp */ result = IDirectDrawGammaControl_GetGammaRamp(gamma, 0, &gamma_ramp); if ( result == DD_OK ) { - memcpy(&ramp[0*256], gamma_ramp.red, 256*sizeof(*ramp)); - memcpy(&ramp[1*256], gamma_ramp.green, 256*sizeof(*ramp)); - memcpy(&ramp[2*256], gamma_ramp.blue, 256*sizeof(*ramp)); + SDL_memcpy(&ramp[0*256], gamma_ramp.red, 256*sizeof(*ramp)); + SDL_memcpy(&ramp[1*256], gamma_ramp.green, 256*sizeof(*ramp)); + SDL_memcpy(&ramp[2*256], gamma_ramp.blue, 256*sizeof(*ramp)); } else { SetDDerror("DirectDrawGammaControl::GetGammaRamp()", result); } @@ -2391,8 +2391,8 @@ void DX5_VideoQuit(_THIS) for ( i=0; incolors); - memcpy(saved, palette->colors, + SDL_memcpy(saved, palette->colors, palette->ncolors*sizeof(SDL_Color)); } for ( i=0; incolors; ++i ) { @@ -2478,7 +2478,7 @@ void DX5_PaletteChanged(_THIS, HWND window) if ( ! colorchange_expected ) { Uint8 mapping[256]; - memset(mapping, 0, sizeof(mapping)); + SDL_memset(mapping, 0, sizeof(mapping)); for ( i=0; incolors; ++i ) { mapping[i] = SDL_FindColor(palette, saved[i].r, saved[i].g, saved[i].b); diff --git a/src/video/windx5/SDL_dx5yuv.c b/src/video/windx5/SDL_dx5yuv.c index fa07660d4..7e83931bd 100644 --- a/src/video/windx5/SDL_dx5yuv.c +++ b/src/video/windx5/SDL_dx5yuv.c @@ -57,7 +57,7 @@ static LPDIRECTDRAWSURFACE3 CreateYUVSurface(_THIS, DDSURFACEDESC ddsd; /* Set up the surface description */ - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS|DDSD_PIXELFORMAT); ddsd.dwWidth = width; @@ -86,7 +86,7 @@ static LPDIRECTDRAWSURFACE3 CreateYUVSurface(_THIS, } /* Make sure the surface format was set properly */ - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); result = IDirectDrawSurface3_Lock(dd_surface3, NULL, &ddsd, DDLOCK_NOSYSLOCK, NULL); @@ -134,13 +134,13 @@ SDL_Overlay *DX5_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S IDirectDraw2_GetFourCCCodes(ddraw2, &numcodes, NULL); if ( numcodes ) { DWORD i; - codes = malloc(numcodes*sizeof(*codes)); + codes = SDL_malloc(numcodes*sizeof(*codes)); if ( codes ) { IDirectDraw2_GetFourCCCodes(ddraw2, &numcodes, codes); for ( i=0; iformat = format; @@ -164,7 +164,7 @@ SDL_Overlay *DX5_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S overlay->hwfuncs = &dx5_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata); + hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); overlay->hwdata = hwdata; if ( hwdata == NULL ) { SDL_OutOfMemory(); @@ -202,7 +202,7 @@ int DX5_LockYUVOverlay(_THIS, SDL_Overlay *overlay) DDSURFACEDESC ddsd; surface = overlay->hwdata->surface; - memset(&ddsd, 0, sizeof(ddsd)); + SDL_memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); result = IDirectDrawSurface3_Lock(surface, NULL, &ddsd, DDLOCK_NOSYSLOCK, NULL); @@ -291,7 +291,7 @@ void DX5_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) if ( hwdata->surface ) { IDirectDrawSurface_Release(hwdata->surface); } - free(hwdata); + SDL_free(hwdata); } } diff --git a/src/video/wscons/SDL_wsconsvideo.c b/src/video/wscons/SDL_wsconsvideo.c index 2524f4882..d7a3f86ee 100644 --- a/src/video/wscons/SDL_wsconsvideo.c +++ b/src/video/wscons/SDL_wsconsvideo.c @@ -96,8 +96,8 @@ static int WSCONS_Available(void) static void WSCONS_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *WSCONS_CreateDevice(int devindex) @@ -105,20 +105,20 @@ static SDL_VideoDevice *WSCONS_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if (device == NULL) { SDL_OutOfMemory(); return 0; } - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = - (struct SDL_PrivateVideoData *)malloc((sizeof *device->hidden)); + (struct SDL_PrivateVideoData *)SDL_malloc((sizeof *device->hidden)); if (device->hidden == NULL) { SDL_OutOfMemory(); - free(device); + SDL_free(device); return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); device->hidden->fd = -1; /* Set the function pointers */ @@ -159,7 +159,7 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat) int pagemask; int width, height; - devname = getenv("SDL_WSCONSDEV"); + devname = SDL_getenv("SDL_WSCONSDEV"); if (devname == NULL) { int activeVT; if (ioctl(STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) { @@ -167,7 +167,7 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat) strerror(errno)); return -1; } - snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT, activeVT - 1); + SDL_snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT, activeVT - 1); devname = devnamebuf; } @@ -211,25 +211,25 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat) } private->rotate = WSCONS_ROTATE_NONE; - rotation = getenv("SDL_VIDEO_WSCONS_ROTATION"); + rotation = SDL_getenv("SDL_VIDEO_WSCONS_ROTATION"); if (rotation != NULL) { - if (strlen(rotation) == 0) { + if (SDL_strlen(rotation) == 0) { private->shadowFB = 0; private->rotate = WSCONS_ROTATE_NONE; printf("Not rotating, no shadow\n"); - } else if (!strcmp(rotation, "NONE")) { + } else if (!SDL_strcmp(rotation, "NONE")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_NONE; printf("Not rotating, but still using shadow\n"); - } else if (!strcmp(rotation, "CW")) { + } else if (!SDL_strcmp(rotation, "CW")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_CW; printf("Rotating screen clockwise\n"); - } else if (!strcmp(rotation, "CCW")) { + } else if (!SDL_strcmp(rotation, "CCW")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_CCW; printf("Rotating screen counter clockwise\n"); - } else if (!strcmp(rotation, "UD")) { + } else if (!SDL_strcmp(rotation, "UD")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_UD; printf("Rotating screen upside down\n"); @@ -304,7 +304,7 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat) } if (private->shadowFB) { - private->shadowmem = (Uint8 *)malloc(len); + private->shadowmem = (Uint8 *)SDL_malloc(len); if (private->shadowmem == NULL) { WSCONS_ReportError("No memory for shadow"); return -1; @@ -316,7 +316,7 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat) private->fblinebytes = private->physlinebytes; } - private->SDL_modelist[0] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + private->SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); private->SDL_modelist[0]->w = width; private->SDL_modelist[0]->h = height; @@ -374,7 +374,7 @@ SDL_Surface *WSCONS_SetVideoMode(_THIS, SDL_Surface *current, current->pitch = private->fblinebytes; current->pixels = private->fbstart; - memset(private->fbstart, 0, private->fbmem_len); + SDL_memset(private->fbstart, 0, private->fbmem_len); return current; } @@ -583,7 +583,7 @@ void WSCONS_VideoQuit(_THIS) int mode = WSDISPLAYIO_MODE_EMUL; if (private->shadowmem != NULL) { - free(private->shadowmem); + SDL_free(private->shadowmem); private->shadowmem = NULL; } private->fbstart = NULL; @@ -592,7 +592,7 @@ void WSCONS_VideoQuit(_THIS) } if (private->SDL_modelist[0] != NULL) { - free(private->SDL_modelist[0]); + SDL_free(private->SDL_modelist[0]); private->SDL_modelist[0] = NULL; } diff --git a/src/video/x11/SDL_x11dga.c b/src/video/x11/SDL_x11dga.c index a5fccd48b..6a6665b1b 100644 --- a/src/video/x11/SDL_x11dga.c +++ b/src/video/x11/SDL_x11dga.c @@ -25,7 +25,7 @@ There will be a completely separate DGA driver that is fullscreen-only. */ -#include /* For getenv() */ +#include /* For SDL_getenv() */ #include "SDL_video.h" #include "SDL_cursor_c.h" #include "SDL_x11dga_c.h" @@ -46,7 +46,7 @@ void X11_EnableDGAMouse(_THIS) #else use_dgamouse = 0; #endif - env_use_dgamouse = getenv("SDL_VIDEO_X11_DGAMOUSE"); + env_use_dgamouse = SDL_getenv("SDL_VIDEO_X11_DGAMOUSE"); if ( env_use_dgamouse ) { use_dgamouse = atoi(env_use_dgamouse); } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index dd99a2d2a..4e7247f4d 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -274,7 +274,7 @@ static int X11_DispatchEvent(_THIS) int posted; XEvent xevent; - memset(&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */ + SDL_memset(&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */ pXNextEvent(SDL_Display, &xevent); posted = 0; @@ -967,7 +967,7 @@ Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers) return 0; } - memset(&xkey, 0, sizeof(xkey)); + SDL_memset(&xkey, 0, sizeof(xkey)); xkey.display = SDL_Display; xsym = keysym; /* last resort if not found */ @@ -1048,7 +1048,7 @@ void X11_SetKeyboardState(Display *display, const char *key_vec) } /* Zero the new keyboard state and generate it */ - memset(kstate, 0, SDLK_LAST); + SDL_memset(kstate, 0, SDLK_LAST); /* * An obvious optimisation is to check entire longwords at a time in * both loops, but we can't be sure the arrays are aligned so it's not diff --git a/src/video/x11/SDL_x11gl.c b/src/video/x11/SDL_x11gl.c index 262fdf97c..c1e373222 100644 --- a/src/video/x11/SDL_x11gl.c +++ b/src/video/x11/SDL_x11gl.c @@ -20,7 +20,7 @@ slouken@libsdl.org */ -#include /* For getenv() prototype */ +#include /* For SDL_getenv() prototype */ #include #include "SDL_events_c.h" @@ -141,7 +141,7 @@ XVisualInfo *X11_GL_GetVisual(_THIS) } #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ - if ( !getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { + if ( !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { attribs[i++] = GLX_X_VISUAL_TYPE; attribs[i++] = GLX_DIRECT_COLOR; } @@ -151,7 +151,7 @@ XVisualInfo *X11_GL_GetVisual(_THIS) glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, SDL_Screen, attribs); #ifdef GLX_DIRECT_COLOR - if( !glx_visualinfo && !getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { /* No DirectColor visual? Try again.. */ + if( !glx_visualinfo && !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { /* No DirectColor visual? Try again.. */ attribs[i-3] = None; glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, SDL_Screen, attribs); @@ -389,7 +389,7 @@ int X11_GL_LoadLibrary(_THIS, const char* path) } if ( path == NULL ) { - path = getenv("SDL_VIDEO_GL_DRIVER"); + path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); if ( path == NULL ) { path = DEFAULT_OPENGL; } @@ -454,10 +454,10 @@ int X11_GL_LoadLibrary(_THIS, const char* path) this->gl_config.dll_handle = handle; this->gl_config.driver_loaded = 1; if ( path ) { - strncpy(this->gl_config.driver_path, path, + SDL_strncpy(this->gl_config.driver_path, path, sizeof(this->gl_config.driver_path)-1); } else { - strcpy(this->gl_config.driver_path, ""); + SDL_strcpy(this->gl_config.driver_path, ""); } return 0; } @@ -476,9 +476,9 @@ void *X11_GL_GetProcAddress(_THIS, const char* proc) #undef do_dlsym #endif retval = do_dlsym(handle, proc); - if (!retval && strlen(proc) <= 1022) { + if (!retval && SDL_strlen(proc) <= 1022) { procname[0] = '_'; - strcpy(procname + 1, proc); + SDL_strcpy(procname + 1, proc); retval = do_dlsym(handle, procname); } return retval; diff --git a/src/video/x11/SDL_x11image.c b/src/video/x11/SDL_x11image.c index 3fb40618f..a6320666e 100644 --- a/src/video/x11/SDL_x11image.c +++ b/src/video/x11/SDL_x11image.c @@ -99,7 +99,7 @@ int X11_SetupImage(_THIS, SDL_Surface *screen) #endif /* not NO_SHARED_MEMORY */ { int bpp; - screen->pixels = malloc(screen->h*screen->pitch); + screen->pixels = SDL_malloc(screen->h*screen->pitch); if ( screen->pixels == NULL ) { SDL_OutOfMemory(); return -1; @@ -154,7 +154,7 @@ static int num_CPU(void) FILE *pstat = fopen("/proc/stat", "r"); if ( pstat ) { while ( fgets(line, sizeof(line), pstat) ) { - if (memcmp(line, "cpu", 3) == 0 && line[3] != ' ') { + if (SDL_memcmp(line, "cpu", 3) == 0 && line[3] != ' ') { ++num_cpus; } } diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 96338f15a..a3da7f7a3 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -51,7 +51,7 @@ Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidMod #ifdef XFREE86_VM static void save_mode(_THIS) { - memset(&saved_mode, 0, sizeof(saved_mode)); + SDL_memset(&saved_mode, 0, sizeof(saved_mode)); SDL_NAME(XF86VidModeGetModeInfo)(SDL_Display,SDL_Screen,&saved_mode); SDL_NAME(XF86VidModeGetViewPort)(SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y); } @@ -260,8 +260,8 @@ static int add_visual_byid(_THIS, const char *visual_id) int nvis; if ( visual_id ) { - memset(&template, 0, (sizeof template)); - template.visualid = strtol(visual_id, NULL, 0); + SDL_memset(&template, 0, (sizeof template)); + template.visualid = SDL_strtol(visual_id, NULL, 0); vi = pXGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); if ( vi ) { int n = this->hidden->nvisuals; @@ -304,7 +304,7 @@ int X11_GetVideoModes(_THIS) XF86VidModeGetAllModeLines() - it hangs the client. */ buggy_X11 = 0; - if ( strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { + if ( SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) { FILE *metro_fp; metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r"); @@ -360,7 +360,7 @@ int X11_GetVideoModes(_THIS) #endif qsort(modes, nmodes, sizeof *modes, cmpmodes); - SDL_modelist = (SDL_Rect **)malloc((nmodes+2)*sizeof(SDL_Rect *)); + SDL_modelist = (SDL_Rect **)SDL_malloc((nmodes+2)*sizeof(SDL_Rect *)); if ( SDL_modelist ) { n = 0; for ( i=0; ivdisplay; if ( (screen_w * screen_h) >= (w * h) ) { if ( (screen_w != w) || (screen_h != h) ) { - SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[n] ) { SDL_modelist[n]->x = 0; SDL_modelist[n]->y = 0; @@ -392,7 +392,7 @@ int X11_GetVideoModes(_THIS) } /* Add the size from the video mode list */ - SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[n] == NULL ) { break; } @@ -449,7 +449,7 @@ int X11_GetVideoModes(_THIS) nummodes, ractive); #endif - SDL_modelist = (SDL_Rect **)malloc((nummodes+1)*sizeof(SDL_Rect *)); + SDL_modelist = (SDL_Rect **)SDL_malloc((nummodes+1)*sizeof(SDL_Rect *)); /* we get the list already sorted in */ /* descending order. We'll copy it in */ @@ -457,7 +457,7 @@ int X11_GetVideoModes(_THIS) if (SDL_modelist) { for ( i=0, j=nummodes-1; j>=0; i++, j-- ) { if ((SDL_modelist[i] = - (SDL_Rect *)malloc(sizeof(SDL_Rect))) == NULL) + (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect))) == NULL) break; #ifdef XIG_DEBUG fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n", @@ -490,11 +490,11 @@ int X11_GetVideoModes(_THIS) /* Search for the visuals in deepest-first order, so that the first will be the richest one */ - if ( getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { + if ( SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { use_directcolor = 0; } this->hidden->nvisuals = 0; - if ( ! add_visual_byid(this, getenv("SDL_VIDEO_X11_VISUALID")) ) { + if ( ! add_visual_byid(this, SDL_getenv("SDL_VIDEO_X11_VISUALID")) ) { for ( i=0; i 8 ) { if ( use_directcolor ) { @@ -526,10 +526,10 @@ int X11_GetVideoModes(_THIS) } if ( SDL_modelist == NULL ) { - SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *)); + SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); if ( SDL_modelist ) { n = 0; - SDL_modelist[n] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); + SDL_modelist[n] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); if ( SDL_modelist[n] ) { SDL_modelist[n]->x = 0; SDL_modelist[n]->y = 0; @@ -578,7 +578,7 @@ int X11_GetVideoModes(_THIS) printf("X11 detected Xinerama:\n"); #endif #if 0 /* Apparently the vidmode extension doesn't work with Xinerama */ - const char *variable = getenv("SDL_VIDEO_X11_XINERAMA_SCREEN"); + const char *variable = SDL_getenv("SDL_VIDEO_X11_XINERAMA_SCREEN"); if ( variable ) { desired = atoi(variable); } @@ -631,9 +631,9 @@ void X11_FreeVideoModes(_THIS) if ( SDL_modelist ) { for ( i=0; SDL_modelist[i]; ++i ) { - free(SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - free(SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } } @@ -727,7 +727,7 @@ int X11_EnterFullScreen(_THIS) tmpwin = windows[nwindows-1]; for ( i=0; ihidden ) { - free(device->hidden); + SDL_free(device->hidden); } if ( device->gl_data ) { - free(device->gl_data); + SDL_free(device->gl_data); } - free(device); + SDL_free(device); SDL_X11_UnloadSymbols(); } } @@ -116,13 +116,13 @@ static SDL_VideoDevice *X11_CreateDevice(int devindex) if ( SDL_X11_LoadSymbols() ) { /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - malloc((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ( (device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL) ) { @@ -130,8 +130,8 @@ static SDL_VideoDevice *X11_CreateDevice(int devindex) X11_DeleteDevice(device); /* calls SDL_X11_UnloadSymbols(). */ return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); - memset(device->gl_data, 0, (sizeof *device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); /* Set the driver flags */ device->handles_any_size = 1; @@ -266,7 +266,7 @@ static int xext_errhandler(Display *d, char *ext_name, char *reason) ext_name, reason, pXDisplayString(d)); #endif - if (strcmp(reason, "missing") == 0) { + if (SDL_strcmp(reason, "missing") == 0) { /* * Since the query itself, elsewhere, can handle a missing extension * and the default behaviour in Xlib is to write to stderr, which @@ -290,9 +290,9 @@ static char *get_classname(char *classname, int maxlen) #endif /* First allow environment variable override */ - spot = getenv("SDL_VIDEO_X11_WMCLASS"); + spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); if ( spot ) { - strncpy(classname, spot, maxlen); + SDL_strncpy(classname, spot, maxlen); return classname; } @@ -308,18 +308,18 @@ static char *get_classname(char *classname, int maxlen) linksize = readlink(procfile, linkfile, sizeof(linkfile)-1); if ( linksize > 0 ) { linkfile[linksize] = '\0'; - spot = strrchr(linkfile, '/'); + spot = SDL_strrchr(linkfile, '/'); if ( spot ) { - strncpy(classname, spot+1, maxlen); + SDL_strncpy(classname, spot+1, maxlen); } else { - strncpy(classname, linkfile, maxlen); + SDL_strncpy(classname, linkfile, maxlen); } return classname; } #endif /* linux */ /* Finally use the default we've used forever */ - strncpy(classname, "SDL_App", maxlen); + SDL_strncpy(classname, "SDL_App", maxlen); return classname; } @@ -335,7 +335,7 @@ static void create_aux_windows(_THIS) /* Don't create any extra windows if we are being managed */ if ( SDL_windowid ) { FSwindow = 0; - WMwindow = strtol(SDL_windowid, NULL, 0); + WMwindow = SDL_strtol(SDL_windowid, NULL, 0); return; } @@ -361,7 +361,7 @@ static void create_aux_windows(_THIS) XEvent ev; long mask; - memset(&ev, 0, sizeof(ev)); + SDL_memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = SDL_Root; ev.xclient.message_type = pXInternAtom(SDL_Display, @@ -461,8 +461,8 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Open the X11 display */ display = NULL; /* Get it from DISPLAY environment variable */ - if ( (strncmp(pXDisplayName(display), ":", 1) == 0) || - (strncmp(pXDisplayName(display), "unix:", 5) == 0) ) { + if ( (SDL_strncmp(pXDisplayName(display), ":", 1) == 0) || + (SDL_strncmp(pXDisplayName(display), "unix:", 5) == 0) ) { local_X11 = 1; } else { local_X11 = 0; @@ -552,7 +552,7 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat) X11_SaveVidModeGamma(this); /* See if we have been passed a window to use */ - SDL_windowid = getenv("SDL_WINDOWID"); + SDL_windowid = SDL_getenv("SDL_WINDOWID"); /* Create the fullscreen and managed windows */ create_aux_windows(this); @@ -605,7 +605,7 @@ static void X11_DestroyWindow(_THIS, SDL_Surface *screen) --SDL_XPixels[pixel]; } } - free(SDL_XPixels); + SDL_free(SDL_XPixels); SDL_XPixels = NULL; } @@ -619,13 +619,13 @@ static void X11_DestroyWindow(_THIS, SDL_Surface *screen) static SDL_bool X11_WindowPosition(_THIS, int *x, int *y, int w, int h) { - const char *window = getenv("SDL_VIDEO_WINDOW_POS"); - const char *center = getenv("SDL_VIDEO_CENTERED"); + const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + const char *center = SDL_getenv("SDL_VIDEO_CENTERED"); if ( window ) { - if ( sscanf(window, "%d,%d", x, y) == 2 ) { + if ( SDL_sscanf(window, "%d,%d", x, y) == 2 ) { return SDL_TRUE; } - if ( strcmp(window, "center") == 0 ) { + if ( SDL_strcmp(window, "center") == 0 ) { center = window; } } @@ -773,7 +773,7 @@ static int X11_CreateWindow(_THIS, SDL_Surface *screen, /* See if we have been given a window id */ if ( SDL_windowid ) { - SDL_Window = strtol(SDL_windowid, NULL, 0); + SDL_Window = SDL_strtol(SDL_windowid, NULL, 0); } else { SDL_Window = 0; } @@ -827,12 +827,12 @@ static int X11_CreateWindow(_THIS, SDL_Surface *screen, /* Allocate the pixel flags */ ncolors = SDL_Visual->map_entries; - SDL_XPixels = malloc(ncolors * sizeof(int)); + SDL_XPixels = SDL_malloc(ncolors * sizeof(int)); if(SDL_XPixels == NULL) { SDL_OutOfMemory(); return -1; } - memset(SDL_XPixels, 0, ncolors * sizeof(*SDL_XPixels)); + SDL_memset(SDL_XPixels, 0, ncolors * sizeof(*SDL_XPixels)); /* always allocate a private colormap on non-default visuals */ if ( SDL_Visual != DefaultVisual(SDL_Display, SDL_Screen) ) { @@ -937,7 +937,7 @@ static int X11_CreateWindow(_THIS, SDL_Surface *screen, } #if 0 /* This is an experiment - are the graphics faster now? - nope. */ - if ( getenv("SDL_VIDEO_X11_BACKINGSTORE") ) + if ( SDL_getenv("SDL_VIDEO_X11_BACKINGSTORE") ) #endif /* Cache the window in the server, when possible */ { @@ -1259,10 +1259,10 @@ int X11_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) want = ALLOCA(ncolors * sizeof(SDL_Color)); reject = ALLOCA(ncolors * sizeof(SDL_Color)); - memcpy(want, colors + firstcolor, ncolors * sizeof(SDL_Color)); + SDL_memcpy(want, colors + firstcolor, ncolors * sizeof(SDL_Color)); /* make sure the user isn't fooled by her own wishes (black is safe, always available in the default colormap) */ - memset(colors + firstcolor, 0, ncolors * sizeof(SDL_Color)); + SDL_memset(colors + firstcolor, 0, ncolors * sizeof(SDL_Color)); /* now try to allocate the colours */ for(i = 0; i < ncolors; i++) { @@ -1361,7 +1361,7 @@ void X11_VideoQuit(_THIS) --SDL_iconcolors[pixel]; } } - free(SDL_iconcolors); + SDL_free(SDL_iconcolors); SDL_iconcolors = NULL; } /* Restore gamma settings if they've changed */ diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 439c45280..e5dad3ee6 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -185,7 +185,7 @@ struct SDL_PrivateVideoData { #define SDL_iconcolors (this->hidden->iconcolors) /* Some versions of XFree86 have bugs - detect if this is one of them */ #define BUGGY_XFREE86(condition, buggy_version) \ -((strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \ +((SDL_strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \ (VendorRelease(SDL_Display) condition buggy_version)) #endif /* _SDL_x11video_h */ diff --git a/src/video/x11/SDL_x11wm.c b/src/video/x11/SDL_x11wm.c index d915e7d7a..2cd69d04f 100644 --- a/src/video/x11/SDL_x11wm.c +++ b/src/video/x11/SDL_x11wm.c @@ -93,7 +93,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) /* The icon has a palette as well - we just have to find those colours */ nwant = icon->format->palette->ncolors; - memcpy(want, icon->format->palette->colors, + SDL_memcpy(want, icon->format->palette->colors, nwant * sizeof want[0]); } else { /* try the standard 6x6x6 cube for lack of better @@ -121,11 +121,11 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) pXFreeColors(GFX_Display, dcmap, freelist, nfree, 0); } if(!SDL_iconcolors) - SDL_iconcolors = malloc(256 * sizeof *SDL_iconcolors); - memset(SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors); + SDL_iconcolors = SDL_malloc(256 * sizeof *SDL_iconcolors); + SDL_memset(SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors); /* try to allocate the colours */ - memset(got, 0, sizeof got); + SDL_memset(got, 0, sizeof got); missing = 0; for(i = 0; i < nwant; i++) { XColor c; @@ -179,11 +179,11 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) /* We need the mask as given, except in LSBfirst format instead of MSBfirst. Reverse the bits in each byte. */ masksize = ((sicon->w + 7) >> 3) * sicon->h; - LSBmask = malloc(masksize); + LSBmask = SDL_malloc(masksize); if ( LSBmask == NULL ) { goto done; } - memset(LSBmask, 0, masksize); + SDL_memset(LSBmask, 0, masksize); for(i = 0; i < masksize; i++) LSBmask[i] = reverse_byte(mask[i]); mask_pixmap = pXCreatePixmapFromBitmapData(SDL_Display, WMwindow, @@ -207,13 +207,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) 0, 0, 0, 0, sicon->w, sicon->h); pXFreeGC(SDL_Display, gc); pXDestroyImage(icon_image); - free(LSBmask); + SDL_free(LSBmask); sicon->pixels = NULL; /* Some buggy window managers (some versions of Enlightenment, it seems) need an icon window *and* icon pixmap to work properly, while it screws up others. The default is only to use a pixmap. */ - p = getenv("SDL_VIDEO_X11_ICONWIN"); + p = SDL_getenv("SDL_VIDEO_X11_ICONWIN"); if(p && *p) { icon_window = pXCreateSimpleWindow(SDL_Display, SDL_Root, 0, 0, sicon->w, sicon->h, 0, diff --git a/src/video/x11/SDL_x11yuv.c b/src/video/x11/SDL_x11yuv.c index ec5da1b45..9e31d05e9 100644 --- a/src/video/x11/SDL_x11yuv.c +++ b/src/video/x11/SDL_x11yuv.c @@ -222,13 +222,13 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S } /* Create the overlay structure */ - overlay = (SDL_Overlay *)malloc(sizeof *overlay); + overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); if ( overlay == NULL ) { SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); SDL_OutOfMemory(); return(NULL); } - memset(overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -240,7 +240,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S overlay->hw_overlay = 1; /* Create the pixel data and lookup tables */ - hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata); + hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); overlay->hwdata = hwdata; if ( hwdata == NULL ) { SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); @@ -251,7 +251,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S hwdata->port = xv_port; #ifndef NO_SHARED_MEMORY yuvshm = &hwdata->yuvshm; - memset(yuvshm, 0, sizeof(*yuvshm)); + SDL_memset(yuvshm, 0, sizeof(*yuvshm)); hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, 0, width, height, yuvshm); #ifdef PITCH_WORKAROUND @@ -312,7 +312,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S SDL_FreeYUVOverlay(overlay); return(NULL); } - hwdata->image->data = malloc(hwdata->image->data_size); + hwdata->image->data = SDL_malloc(hwdata->image->data_size); if ( hwdata->image->data == NULL ) { SDL_OutOfMemory(); SDL_FreeYUVOverlay(overlay); @@ -322,8 +322,8 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S /* Find the pitch and offset values for the overlay */ overlay->planes = hwdata->image->num_planes; - overlay->pitches = (Uint16 *)malloc(overlay->planes * sizeof(Uint16)); - overlay->pixels = (Uint8 **)malloc(overlay->planes * sizeof(Uint8 *)); + overlay->pitches = (Uint16 *)SDL_malloc(overlay->planes * sizeof(Uint16)); + overlay->pixels = (Uint8 **)SDL_malloc(overlay->planes * sizeof(Uint8 *)); if ( !overlay->pitches || !overlay->pixels ) { SDL_OutOfMemory(); SDL_FreeYUVOverlay(overlay); @@ -395,14 +395,14 @@ void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) if ( hwdata->image ) { pXFree(hwdata->image); } - free(hwdata); + SDL_free(hwdata); } if ( overlay->pitches ) { - free(overlay->pitches); + SDL_free(overlay->pitches); overlay->pitches = NULL; } if ( overlay->pixels ) { - free(overlay->pixels); + SDL_free(overlay->pixels); overlay->pixels = NULL; } #ifdef XFREE86_REFRESH_HACK diff --git a/src/video/xbios/SDL_xbios.c b/src/video/xbios/SDL_xbios.c index 02e5bd20b..1607d8f4c 100644 --- a/src/video/xbios/SDL_xbios.c +++ b/src/video/xbios/SDL_xbios.c @@ -139,8 +139,8 @@ static int XBIOS_Available(void) static void XBIOS_DeleteDevice(SDL_VideoDevice *device) { - free(device->hidden); - free(device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice *XBIOS_CreateDevice(int devindex) @@ -148,23 +148,23 @@ static SDL_VideoDevice *XBIOS_CreateDevice(int devindex) SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if ( device ) { - memset(device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - malloc((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ( (device == NULL) || (device->hidden == NULL) ) { SDL_OutOfMemory(); if ( device ) { - free(device); + SDL_free(device); } return(0); } - memset(device->hidden, 0, (sizeof *device->hidden)); - memset(device->gl_data, 0, sizeof(*device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); /* Video functions */ device->VideoInit = XBIOS_VideoInit; @@ -223,7 +223,7 @@ void SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height, } ++XBIOS_nummodes; - XBIOS_modelist = (xbiosmode_t *) realloc(XBIOS_modelist, XBIOS_nummodes * sizeof(xbiosmode_t)); + XBIOS_modelist = (xbiosmode_t *) SDL_realloc(XBIOS_modelist, XBIOS_nummodes * sizeof(xbiosmode_t)); /* Keep the list sorted: bpp, width, height */ curpos=0; @@ -243,7 +243,7 @@ void SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height, /* Push remaining modes further */ for(i=XBIOS_nummodes-1; i>curpos; i--) { - memcpy(&XBIOS_modelist[i], &XBIOS_modelist[i-1], sizeof(xbiosmode_t)); + SDL_memcpy(&XBIOS_modelist[i], &XBIOS_modelist[i-1], sizeof(xbiosmode_t)); } XBIOS_modelist[curpos].number = modecode; @@ -268,7 +268,7 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) } /* Allocate memory for old palette */ - XBIOS_oldpalette = (void *)malloc(256*sizeof(long)); + XBIOS_oldpalette = (void *)SDL_malloc(256*sizeof(long)); if ( !XBIOS_oldpalette ) { SDL_SetError("Unable to allocate memory for old palette\n"); return(-1); @@ -426,7 +426,7 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) switch (current_mode->depth) { case 4: case 8: - SDL_modelist[0][j8] = malloc(sizeof(SDL_Rect)); + SDL_modelist[0][j8] = SDL_malloc(sizeof(SDL_Rect)); SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0; SDL_modelist[0][j8]->w = current_mode->width; SDL_modelist[0][j8]->h = current_mode->height; @@ -434,7 +434,7 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) j8++; break; case 16: - SDL_modelist[1][j16] = malloc(sizeof(SDL_Rect)); + SDL_modelist[1][j16] = SDL_malloc(sizeof(SDL_Rect)); SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0; SDL_modelist[1][j16]->w = current_mode->width; SDL_modelist[1][j16]->h = current_mode->height; @@ -550,7 +550,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, SDL_SetError("Can not allocate %d KB for shadow buffer", new_screen_size>>10); return (NULL); } - memset(XBIOS_shadowscreen, 0, new_screen_size); + SDL_memset(XBIOS_shadowscreen, 0, new_screen_size); } /* Output buffer needs to be twice in size for the software double-line mode */ @@ -567,7 +567,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, SDL_SetError("Can not allocate %d KB for frame buffer", new_screen_size>>10); return (NULL); } - memset(XBIOS_screensmem[0], 0, new_screen_size); + SDL_memset(XBIOS_screensmem[0], 0, new_screen_size); XBIOS_screens[0]=(void *) (( (long) XBIOS_screensmem[0]+256) & 0xFFFFFF00UL); @@ -588,7 +588,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, SDL_SetError("Can not allocate %d KB for double buffer", new_screen_size>>10); return (NULL); } - memset(XBIOS_screensmem[1], 0, new_screen_size); + SDL_memset(XBIOS_screensmem[1], 0, new_screen_size); XBIOS_screens[1]=(void *) (( (long) XBIOS_screensmem[1]+256) & 0xFFFFFF00UL); modeflags |= SDL_DOUBLEBUF; @@ -678,7 +678,7 @@ static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, #endif /* Set hardware palette to black in True Colour */ if (new_depth == 16) { - memset(F30_palette, 0, sizeof(F30_palette)); + SDL_memset(F30_palette, 0, sizeof(F30_palette)); VsetRGB(0,256,F30_palette); } break; @@ -903,7 +903,7 @@ static void XBIOS_VideoQuit(_THIS) #endif if (XBIOS_oldpalette) { - free(XBIOS_oldpalette); + SDL_free(XBIOS_oldpalette); XBIOS_oldpalette=NULL; } XBIOS_FreeBuffers(this); @@ -912,14 +912,14 @@ static void XBIOS_VideoQuit(_THIS) for (j=0;j