Use SDL_ prefixed versions of C library functions.
authorSam Lantinga <slouken@libsdl.org>
Tue, 07 Feb 2006 06:59:48 +0000
changeset 13363692456e7b0f
parent 1335 c39265384763
child 1337 c687f06c7473
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
include/SDL_config.h
include/SDL_getenv.h
include/SDL_stdlib.h
include/SDL_string.h
src/SDL.c
src/SDL_error.c
src/audio/SDL_audio.c
src/audio/SDL_audiodev.c
src/audio/SDL_audiomem.c
src/audio/SDL_sysaudio.h
src/audio/SDL_wave.c
src/audio/SDL_wave.h
src/audio/alsa/SDL_alsa_audio.c
src/audio/amigaos/SDL_ahiaudio.c
src/audio/arts/SDL_artsaudio.c
src/audio/baudio/SDL_beaudio.cc
src/audio/dart/SDL_dart.c
src/audio/dc/SDL_dcaudio.c
src/audio/disk/SDL_diskaudio.c
src/audio/dma/SDL_dmaaudio.c
src/audio/dmedia/SDL_irixaudio.c
src/audio/dsp/SDL_dspaudio.c
src/audio/esd/SDL_esdaudio.c
src/audio/macosx/SDL_coreaudio.c
src/audio/macrom/SDL_romaudio.c
src/audio/mint/SDL_mintaudio.c
src/audio/mint/SDL_mintaudio_dma8.c
src/audio/mint/SDL_mintaudio_gsxb.c
src/audio/mint/SDL_mintaudio_mcsn.c
src/audio/mint/SDL_mintaudio_stfa.c
src/audio/mint/SDL_mintaudio_xbios.c
src/audio/mme/SDL_mmeaudio.c
src/audio/nas/SDL_nasaudio.c
src/audio/nto/SDL_nto_audio.c
src/audio/openbsd/SDL_openbsdaudio.c
src/audio/paudio/SDL_paudio.c
src/audio/sun/SDL_sunaudio.c
src/audio/ums/SDL_umsaudio.c
src/audio/windib/SDL_dibaudio.c
src/audio/windx5/SDL_dx5audio.c
src/cdrom/SDL_cdrom.c
src/cdrom/SDL_syscdrom.h
src/cdrom/aix/SDL_syscdrom.c
src/cdrom/beos/SDL_syscdrom.cc
src/cdrom/bsdi/SDL_syscdrom.c
src/cdrom/freebsd/SDL_syscdrom.c
src/cdrom/linux/SDL_syscdrom.c
src/cdrom/macos/SDL_syscdrom.c
src/cdrom/macosx/AudioFilePlayer.c
src/cdrom/macosx/AudioFileReaderThread.c
src/cdrom/macosx/SDLOSXCAGuard.c
src/cdrom/openbsd/SDL_syscdrom.c
src/cdrom/os2/SDL_syscdrom.c
src/cdrom/osf/SDL_syscdrom.c
src/cdrom/qnx/SDL_syscdrom.c
src/cdrom/win32/SDL_syscdrom.c
src/events/SDL_active.c
src/events/SDL_events.c
src/events/SDL_keyboard.c
src/events/SDL_mouse.c
src/events/SDL_sysevents.h
src/file/SDL_rwops.c
src/joystick/SDL_joystick.c
src/joystick/SDL_sysjoystick.h
src/joystick/amigaos/SDL_sysjoystick.c
src/joystick/beos/SDL_bejoystick.cc
src/joystick/bsd/SDL_sysjoystick.c
src/joystick/dc/SDL_sysjoystick.c
src/joystick/linux/SDL_sysjoystick.c
src/joystick/macos/SDL_sysjoystick.c
src/joystick/mint/SDL_sysjoystick.c
src/joystick/os2/SDL_sysjoystick.c
src/joystick/riscos/SDL_sysjoystick.c
src/joystick/win32/SDL_mmjoystick.c
src/loadso/macos/SDL_loadso.c
src/loadso/macosx/SDL_loadso.c
src/loadso/windows/SDL_loadso.c
src/main/macos/SDL_main.c
src/main/win32/SDL_win32_main.c
src/stdlib/SDL_getenv.c
src/stdlib/SDL_malloc.c
src/stdlib/SDL_qsort.c
src/stdlib/SDL_string.c
src/thread/SDL_thread.c
src/thread/amigaos/SDL_syssem.c
src/thread/amigaos/SDL_thread.c
src/thread/beos/SDL_syssem.c
src/thread/bsdi/SDL_syssem.c
src/thread/dc/SDL_syscond.c
src/thread/dc/SDL_sysmutex.c
src/thread/generic/SDL_syscond.c
src/thread/generic/SDL_sysmutex.c
src/thread/generic/SDL_syssem.c
src/thread/linux/SDL_syscond.c
src/thread/linux/SDL_sysmutex.c
src/thread/linux/SDL_syssem.c
src/thread/linux/SDL_systhread.c
src/thread/os2/SDL_syscond.c
src/thread/os2/SDL_sysmutex.c
src/thread/os2/SDL_syssem.c
src/thread/os2/SDL_systhread.c
src/thread/pth/SDL_syscond.c
src/thread/pth/SDL_sysmutex.c
src/thread/riscos/SDL_syscond.c
src/thread/riscos/SDL_sysmutex.c
src/thread/riscos/SDL_syssem.c
src/thread/win32/SDL_sysmutex.c
src/thread/win32/SDL_syssem.c
src/thread/win32/SDL_systhread.c
src/timer/SDL_timer.c
src/timer/linux/SDL_systimer.c
src/video/SDL_RLEaccel.c
src/video/SDL_blit_0.c
src/video/SDL_blit_N.c
src/video/SDL_bmp.c
src/video/SDL_cursor.c
src/video/SDL_gamma.c
src/video/SDL_pixels.c
src/video/SDL_surface.c
src/video/SDL_video.c
src/video/SDL_yuv.c
src/video/SDL_yuv_sw.c
src/video/Xext/Xv/Xv.c
src/video/Xext/Xxf86dga/XF86DGA.c
src/video/aalib/SDL_aavideo.c
src/video/ataricommon/SDL_atarievents.c
src/video/ataricommon/SDL_atarigl.c
src/video/ataricommon/SDL_biosevents.c
src/video/ataricommon/SDL_gemdosevents.c
src/video/ataricommon/SDL_ikbdevents.c
src/video/bwindow/SDL_BWin.h
src/video/bwindow/SDL_sysmouse.cc
src/video/bwindow/SDL_sysvideo.cc
src/video/bwindow/SDL_sysyuv.cc
src/video/cybergfx/SDL_amigamouse.c
src/video/cybergfx/SDL_cgxaccel.c
src/video/cybergfx/SDL_cgximage.c
src/video/cybergfx/SDL_cgxmodes.c
src/video/cybergfx/SDL_cgxvideo.c
src/video/cybergfx/SDL_cgxwm.c
src/video/cybergfx/SDL_cgxyuv.c
src/video/dc/SDL_dcevents.c
src/video/dc/SDL_dcvideo.c
src/video/dga/SDL_dgavideo.c
src/video/directfb/SDL_DirectFB_video.c
src/video/dummy/SDL_nullvideo.c
src/video/epoc/SDL_epocvideo.cpp
src/video/fbcon/SDL_fbelo.c
src/video/fbcon/SDL_fbevents.c
src/video/fbcon/SDL_fbvideo.c
src/video/gapi/SDL_gapivideo.c
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemmouse.c
src/video/gem/SDL_gemvideo.c
src/video/ggi/SDL_ggivideo.c
src/video/ipod/SDL_ipodvideo.c
src/video/maccommon/SDL_macmouse.c
src/video/maccommon/SDL_macwm.c
src/video/macdsp/SDL_dspvideo.c
src/video/macrom/SDL_romvideo.c
src/video/os2fslib/SDL_os2fslib.c
src/video/photon/SDL_ph_gl.c
src/video/photon/SDL_ph_image.c
src/video/photon/SDL_ph_modes.c
src/video/photon/SDL_ph_mouse.c
src/video/photon/SDL_ph_video.c
src/video/photon/SDL_ph_wm.c
src/video/photon/SDL_phyuv.c
src/video/picogui/SDL_pgevents.c
src/video/picogui/SDL_pgvideo.c
src/video/ps2gs/SDL_gsevents.c
src/video/ps2gs/SDL_gsvideo.c
src/video/ps2gs/SDL_gsyuv.c
src/video/qtopia/SDL_QWin.cc
src/video/qtopia/SDL_sysevents.cc
src/video/qtopia/SDL_sysvideo.cc
src/video/riscos/SDL_riscosFullScreenVideo.c
src/video/riscos/SDL_riscosevents.c
src/video/riscos/SDL_riscosmouse.c
src/video/riscos/SDL_riscossprite.c
src/video/riscos/SDL_riscostask.c
src/video/riscos/SDL_riscosvideo.c
src/video/riscos/SDL_wimppoll.c
src/video/riscos/SDL_wimpvideo.c
src/video/svga/SDL_svgaevents.c
src/video/svga/SDL_svgavideo.c
src/video/vgl/SDL_vglevents.c
src/video/vgl/SDL_vglvideo.c
src/video/wincommon/SDL_lowvideo.h
src/video/wincommon/SDL_sysevents.c
src/video/wincommon/SDL_sysmouse.c
src/video/wincommon/SDL_syswm.c
src/video/wincommon/SDL_wingl.c
src/video/windib/SDL_dibevents.c
src/video/windib/SDL_dibvideo.c
src/video/windx5/SDL_dx5events.c
src/video/windx5/SDL_dx5video.c
src/video/windx5/SDL_dx5yuv.c
src/video/wscons/SDL_wsconsvideo.c
src/video/x11/SDL_x11dga.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11gl.c
src/video/x11/SDL_x11image.c
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11mouse.c
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
src/video/x11/SDL_x11wm.c
src/video/x11/SDL_x11yuv.c
src/video/xbios/SDL_xbios.c
src/video/xbios/SDL_xbios_centscreen.c
src/video/xbios/SDL_xbios_sb3.c
     1.1 --- a/include/SDL_config.h	Mon Feb 06 17:28:04 2006 +0000
     1.2 +++ b/include/SDL_config.h	Tue Feb 07 06:59:48 2006 +0000
     1.3 @@ -54,16 +54,16 @@
     1.4  #endif /* !_WIN32_WCE */
     1.5  
     1.6  /* Features provided by SDL_stdlib.h */
     1.7 -#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
     1.8 -#define HAVE_GETENV
     1.9 -#define HAVE_PUTENV
    1.10 -#endif
    1.11  #define HAVE_MALLOC
    1.12  #define HAVE_REALLOC
    1.13  #define HAVE_FREE
    1.14  #ifndef HAVE_ALLOCA
    1.15  #define HAVE_ALLOCA
    1.16  #endif
    1.17 +#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
    1.18 +#define HAVE_GETENV
    1.19 +#define HAVE_PUTENV
    1.20 +#endif
    1.21  /*#define HAVE_QSORT*/
    1.22  
    1.23  /* Features provided by SDL_string.h */
    1.24 @@ -74,6 +74,8 @@
    1.25  #define HAVE_STRLEN
    1.26  #define HAVE_STRCPY
    1.27  #define HAVE_STRNCPY
    1.28 +#define HAVE_STRCAT
    1.29 +#define HAVE_STRNCAT
    1.30  /*#define HAVE__STRREV*/
    1.31  /*#define HAVE__STRUPR*/
    1.32  /*#define HAVE__STRLWR*/
    1.33 @@ -94,7 +96,7 @@
    1.34  /*#define HAVE_STRCASECMP*/
    1.35  #define HAVE_SSCANF
    1.36  /*#define HAVE_SNPRINTF*/
    1.37 -#define HAVE_VSNPRINTF
    1.38 +/*#define HAVE_VSNPRINTF*/
    1.39  
    1.40  #endif /* HAVE_LIBC */
    1.41  
     2.1 --- a/include/SDL_getenv.h	Mon Feb 06 17:28:04 2006 +0000
     2.2 +++ b/include/SDL_getenv.h	Tue Feb 07 06:59:48 2006 +0000
     2.3 @@ -20,39 +20,4 @@
     2.4      slouken@libsdl.org
     2.5  */
     2.6  
     2.7 -#ifndef _SDL_getenv_h
     2.8 -#define _SDL_getenv_h
     2.9 -
    2.10 -#include "SDL_config.h"
    2.11 -
    2.12 -#ifdef HAVE_STDLIB_H
    2.13 -#include <stdlib.h>
    2.14 -#endif
    2.15 -
    2.16 -#include "begin_code.h"
    2.17 -/* Set up for C function definitions, even when using C++ */
    2.18 -#ifdef __cplusplus
    2.19 -extern "C" {
    2.20 -#endif
    2.21 -
    2.22 -#ifdef HAVE_GETENV
    2.23 -#define SDL_getenv	getenv
    2.24 -#else
    2.25 -#define getenv		SDL_getenv
    2.26 -extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
    2.27 -#endif
    2.28 -
    2.29 -#ifdef HAVE_PUTENV
    2.30 -#define SDL_putenv	putenv
    2.31 -#else
    2.32 -#define putenv		SDL_putenv
    2.33 -extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
    2.34 -#endif
    2.35 -
    2.36 -/* Ends C function definitions when using C++ */
    2.37 -#ifdef __cplusplus
    2.38 -}
    2.39 -#endif
    2.40 -#include "close_code.h"
    2.41 -
    2.42 -#endif /* _SDL_getenv_h */
    2.43 +#include "SDL_stdlib.h"
     3.1 --- a/include/SDL_stdlib.h	Mon Feb 06 17:28:04 2006 +0000
     3.2 +++ b/include/SDL_stdlib.h	Tue Feb 07 06:59:48 2006 +0000
     3.3 @@ -49,9 +49,6 @@
     3.4  #endif
     3.5  
     3.6  #include "SDL_types.h"
     3.7 -#include "SDL_stdarg.h"
     3.8 -#include "SDL_getenv.h"
     3.9 -
    3.10  
    3.11  #include "begin_code.h"
    3.12  /* Set up for C function definitions, even when using C++ */
    3.13 @@ -62,21 +59,18 @@
    3.14  #ifdef HAVE_MALLOC
    3.15  #define SDL_malloc	malloc
    3.16  #else
    3.17 -#define malloc		SDL_malloc
    3.18  extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
    3.19  #endif
    3.20  
    3.21  #ifdef HAVE_REALLOC
    3.22  #define SDL_realloc	realloc
    3.23  #else
    3.24 -#define realloc		SDL_realloc
    3.25  extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
    3.26  #endif
    3.27  
    3.28  #ifdef HAVE_FREE
    3.29  #define SDL_free	free
    3.30  #else
    3.31 -#define free		SDL_free
    3.32  extern DECLSPEC void SDLCALL SDL_free(void *mem);
    3.33  #endif
    3.34  
    3.35 @@ -84,14 +78,25 @@
    3.36  #define SDL_stack_alloc(type, count)    (type*)alloca(sizeof(type)*count)
    3.37  #define SDL_stack_free(data)
    3.38  #else
    3.39 -#define SDL_stack_alloc(type, count)    SDL_malloc(sizeof(type)*count)
    3.40 +#define SDL_stack_alloc(type, count)    (type*)SDL_malloc(sizeof(type)*count)
    3.41  #define SDL_stack_free(data)            SDL_free(data)
    3.42  #endif
    3.43  
    3.44 +#ifdef HAVE_GETENV
    3.45 +#define SDL_getenv	getenv
    3.46 +#else
    3.47 +extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
    3.48 +#endif
    3.49 +
    3.50 +#ifdef HAVE_PUTENV
    3.51 +#define SDL_putenv	putenv
    3.52 +#else
    3.53 +extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
    3.54 +#endif
    3.55 +
    3.56  #ifdef HAVE_QSORT
    3.57  #define SDL_qsort	qsort
    3.58  #else
    3.59 -#define qsort		SDL_qsort
    3.60  extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
    3.61             int (*compare)(const void *, const void *));
    3.62  #endif
     4.1 --- a/include/SDL_string.h	Mon Feb 06 17:28:04 2006 +0000
     4.2 +++ b/include/SDL_string.h	Tue Feb 07 06:59:48 2006 +0000
     4.3 @@ -44,10 +44,9 @@
     4.4  extern "C" {
     4.5  #endif
     4.6  
     4.7 -#ifndef HAVE_MEMSET
     4.8 -#define memset          SDL_memset
     4.9 -#endif
    4.10 -#ifndef SDL_memset
    4.11 +#ifdef HAVE_MEMSET
    4.12 +#define SDL_memset      memset
    4.13 +#else
    4.14  extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
    4.15  #endif
    4.16  
    4.17 @@ -98,23 +97,14 @@
    4.18  		: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
    4.19  		: "memory" );						  \
    4.20  } while(0)
    4.21 -#define SDL_memcpy4(dst, src, len)				\
    4.22 -do {								\
    4.23 -	int ecx, edi, esi;					\
    4.24 -	__asm__ __volatile__ (					\
    4.25 -		"cld\n\t"					\
    4.26 -		"rep ; movsl"					\
    4.27 -		: "=&c" (ecx), "=&D" (edi), "=&S" (esi)		\
    4.28 -		: "0" ((unsigned)(len)), "1" (dst), "2" (src)	\
    4.29 -		: "memory" );					\
    4.30 -} while(0)
    4.31 -#endif
    4.32 -#ifndef HAVE_MEMCPY
    4.33 -#define memcpy          SDL_memcpy
    4.34  #endif
    4.35  #ifndef SDL_memcpy
    4.36 +#ifdef HAVE_MEMCPY
    4.37 +#define SDL_memcpy      memcpy
    4.38 +#else
    4.39  extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
    4.40  #endif
    4.41 +#endif
    4.42  
    4.43  #if defined(__GNUC__) && defined(i386)
    4.44  #define SDL_memcpy4(dst, src, len)				\
    4.45 @@ -162,9 +152,9 @@
    4.46  extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
    4.47  #endif
    4.48  
    4.49 -#ifndef HAVE_MEMMOVE
    4.50 -#define memmove         SDL_memmove
    4.51 -#endif
    4.52 +#ifdef HAVE_MEMMOVE
    4.53 +#define SDL_memmove     memmove
    4.54 +#else
    4.55  #define SDL_memmove(dst, src, len)			\
    4.56  do {							\
    4.57  	if ( dst < src ) {				\
    4.58 @@ -173,109 +163,107 @@
    4.59  		SDL_revcpy(dst, src, len);		\
    4.60  	}						\
    4.61  } while(0)
    4.62 +#endif
    4.63  
    4.64 -#ifndef HAVE_MEMCMP
    4.65 -#define memcmp          SDL_memcmp
    4.66 -#endif
    4.67 -#ifndef SDL_memcmp
    4.68 +#ifdef HAVE_MEMCMP
    4.69 +#define SDL_memcmp      memcmp
    4.70 +#else
    4.71  extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
    4.72  #endif
    4.73  
    4.74  #ifdef HAVE_STRLEN
    4.75  #define SDL_strlen      strlen
    4.76  #else
    4.77 -#define strlen          SDL_strlen
    4.78  extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
    4.79  #endif
    4.80  
    4.81  #ifdef HAVE_STRCPY
    4.82  #define SDL_strcpy     strcpy
    4.83  #else
    4.84 -#define strcpy         SDL_strcpy
    4.85  extern DECLSPEC char * SDLCALL SDL_strcpy(char *dst, const char *src);
    4.86  #endif
    4.87  
    4.88  #ifdef HAVE_STRNCPY
    4.89  #define SDL_strncpy     strncpy
    4.90  #else
    4.91 -#define strncpy         SDL_strncpy
    4.92  extern DECLSPEC char * SDLCALL SDL_strncpy(char *dst, const char *src, size_t maxlen);
    4.93  #endif
    4.94  
    4.95 +#ifdef HAVE_STRCAT
    4.96 +#define SDL_strcat     strcat
    4.97 +#else
    4.98 +#define SDL_strcat(dst, src)    (SDL_strcpy(dst+SDL_strlen(dst), src), dst)
    4.99 +#endif
   4.100 +
   4.101 +#ifdef HAVE_STRNCAT
   4.102 +#define SDL_strncat    strncat
   4.103 +#else
   4.104 +#define SDL_strncat(dst, src, n) (SDL_strncpy(dst+SDL_strlen(dst), src, n), dst)
   4.105 +#endif
   4.106 +
   4.107  #ifdef HAVE__STRREV
   4.108  #define SDL_strrev      _strrev
   4.109  #else
   4.110 -#define _strrev	        SDL_strrev
   4.111  extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
   4.112  #endif
   4.113  
   4.114  #ifdef HAVE__STRUPR
   4.115  #define SDL_strupr      _strupr
   4.116  #else
   4.117 -#define _strupr         SDL_strupr
   4.118  extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
   4.119  #endif
   4.120  
   4.121  #ifdef HAVE__STRLWR
   4.122  #define SDL_strlwr      _strlwr
   4.123  #else
   4.124 -#define _strlwr         SDL_strlwr
   4.125  extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
   4.126  #endif
   4.127  
   4.128  #ifdef HAVE_STRCHR
   4.129  #define SDL_strchr      strchr
   4.130  #else
   4.131 -#define strchr          SDL_strchr
   4.132  extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
   4.133  #endif
   4.134  
   4.135  #ifdef HAVE_STRRCHR
   4.136  #define SDL_strrchr     strrchr
   4.137  #else
   4.138 -#define strrchr         SDL_strrchr
   4.139  extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
   4.140  #endif
   4.141  
   4.142  #ifdef HAVE_STRSTR
   4.143  #define SDL_strstr      strstr
   4.144  #else
   4.145 -#define strstr          SDL_strstr
   4.146  extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
   4.147  #endif
   4.148  
   4.149  #ifdef HAVE_ITOA
   4.150  #define SDL_itoa        itoa
   4.151  #else
   4.152 -#define itoa            SDL_itoa
   4.153  #define SDL_itoa(value, string, radix)	SDL_ltoa((long)value, string, radix)
   4.154  #endif
   4.155  
   4.156  #ifdef HAVE__LTOA
   4.157  #define SDL_ltoa        _ltoa
   4.158  #else
   4.159 -#define _ltoa        SDL_ltoa
   4.160  extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
   4.161  #endif
   4.162  
   4.163  #ifdef HAVE__UITOA
   4.164  #define SDL_uitoa       _uitoa
   4.165  #else
   4.166 -#define _uitoa          SDL_uitoa
   4.167  #define SDL_uitoa(value, string, radix)	SDL_ultoa((long)value, string, radix)
   4.168  #endif
   4.169  
   4.170  #ifdef HAVE__ULTOA
   4.171  #define SDL_ultoa       _ultoa
   4.172  #else
   4.173 -#define _ultoa          SDL_ultoa
   4.174  extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
   4.175  #endif
   4.176  
   4.177  #ifdef HAVE_STRTOL
   4.178  #define SDL_strtol      strtol
   4.179  #else
   4.180 -#define strtol          SDL_strtol
   4.181  extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
   4.182  #endif
   4.183  
   4.184 @@ -284,21 +272,18 @@
   4.185  #ifdef HAVE__I64TOA
   4.186  #define SDL_lltoa       _i64toa
   4.187  #else
   4.188 -#define _i64toa         SDL_lltoa
   4.189  extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
   4.190  #endif
   4.191  
   4.192  #ifdef HAVE__UI64TOA
   4.193  #define SDL_ulltoa      _ui64toa
   4.194  #else
   4.195 -#define _ui64toa        SDL_ulltoa
   4.196  extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
   4.197  #endif
   4.198  
   4.199  #ifdef HAVE_STRTOLL
   4.200  #define SDL_strtoll     strtoll
   4.201  #else
   4.202 -#define strtoll         SDL_strtoll
   4.203  extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
   4.204  #endif
   4.205  
   4.206 @@ -307,14 +292,12 @@
   4.207  #ifdef HAVE_STRCMP
   4.208  #define SDL_strcmp      strcmp
   4.209  #else
   4.210 -#define strcmp          SDL_strcmp
   4.211  extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
   4.212  #endif
   4.213  
   4.214  #ifdef HAVE_STRNCMP
   4.215  #define SDL_strncmp     strncmp
   4.216  #else
   4.217 -#define strncmp         SDL_strncmp
   4.218  extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
   4.219  #endif
   4.220  
   4.221 @@ -325,28 +308,24 @@
   4.222  #ifdef HAVE_STRCASECMP
   4.223  #define SDL_strcasecmp  strcasecmp
   4.224  #else
   4.225 -#define strcasecmp      SDL_strcasecmp
   4.226  extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
   4.227  #endif
   4.228  
   4.229  #ifdef HAVE_SSCANF
   4.230  #define SDL_sscanf      sscanf
   4.231  #else
   4.232 -#define sscanf          SDL_sscanf
   4.233  extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
   4.234  #endif
   4.235  
   4.236  #ifdef HAVE_SNPRINTF
   4.237  #define SDL_snprintf    snprintf
   4.238  #else
   4.239 -#define snprintf        SDL_snprintf
   4.240  extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
   4.241  #endif
   4.242  
   4.243  #ifdef HAVE_VSNPRINTF
   4.244  #define SDL_vsnprintf   vsnprintf
   4.245  #else
   4.246 -#define vsnprintf       SDL_vsnprintf
   4.247  extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
   4.248  #endif
   4.249  
     5.1 --- a/src/SDL.c	Mon Feb 06 17:28:04 2006 +0000
     5.2 +++ b/src/SDL.c	Tue Feb 07 06:59:48 2006 +0000
     5.3 @@ -66,7 +66,7 @@
     5.4  #ifndef DISABLE_VIDEO
     5.5  	/* Initialize the video/event subsystem */
     5.6  	if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) {
     5.7 -		if ( SDL_VideoInit(getenv("SDL_VIDEODRIVER"),
     5.8 +		if ( SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"),
     5.9  		                   (flags&SDL_INIT_EVENTTHREAD)) < 0 ) {
    5.10  			return(-1);
    5.11  		}
    5.12 @@ -82,7 +82,7 @@
    5.13  #ifndef DISABLE_AUDIO
    5.14  	/* Initialize the audio subsystem */
    5.15  	if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) {
    5.16 -		if ( SDL_AudioInit(getenv("SDL_AUDIODRIVER")) < 0 ) {
    5.17 +		if ( SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0 ) {
    5.18  			return(-1);
    5.19  		}
    5.20  		SDL_initialized |= SDL_INIT_AUDIO;
     6.1 --- a/src/SDL_error.c	Mon Feb 06 17:28:04 2006 +0000
     6.2 +++ b/src/SDL_error.c	Tue Feb 07 06:59:48 2006 +0000
     6.3 @@ -63,7 +63,7 @@
     6.4  	/* Copy in the key, mark error as valid */
     6.5  	error = SDL_GetErrBuf();
     6.6  	error->error = 1;
     6.7 -	strncpy((char *)error->key, fmt, sizeof(error->key));
     6.8 +	SDL_strncpy((char *)error->key, fmt, sizeof(error->key));
     6.9  	error->key[sizeof(error->key)-1] = '\0';
    6.10  
    6.11  	va_start(ap, fmt);
    6.12 @@ -98,7 +98,7 @@
    6.13  				  char *str = va_arg(ap, char *);
    6.14  				  if (str == NULL)
    6.15  				      str = "(null)";
    6.16 -				  strncpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
    6.17 +				  SDL_strncpy((char *)error->args[index].buf, str, ERR_MAX_STRLEN);
    6.18  				  error->args[index].buf[ERR_MAX_STRLEN-1] = 0;
    6.19  				  error->argc++;
    6.20  				}
    6.21 @@ -125,9 +125,9 @@
    6.22  	char tmp[128];
    6.23  	int len, i;
    6.24  
    6.25 -	snprintf(tmp, SDL_arraysize(tmp), "%d", value);
    6.26 +	SDL_snprintf(tmp, SDL_arraysize(tmp), "%d", value);
    6.27  	len = 0;
    6.28 -	if ( strlen(tmp) < maxlen ) {
    6.29 +	if ( SDL_strlen(tmp) < maxlen ) {
    6.30  		for ( i=0; tmp[i]; ++i ) {
    6.31  			*str++ = tmp[i];
    6.32  			++len;
    6.33 @@ -141,9 +141,9 @@
    6.34  	char tmp[128];
    6.35  	int len, i;
    6.36  
    6.37 -	snprintf(tmp, SDL_arraysize(tmp), "%f", value);
    6.38 +	SDL_snprintf(tmp, SDL_arraysize(tmp), "%f", value);
    6.39  	len = 0;
    6.40 -	if ( strlen(tmp) < maxlen ) {
    6.41 +	if ( SDL_strlen(tmp) < maxlen ) {
    6.42  		for ( i=0; tmp[i]; ++i ) {
    6.43  			*str++ = tmp[i];
    6.44  			++len;
    6.45 @@ -157,9 +157,9 @@
    6.46  	char tmp[128];
    6.47  	int len, i;
    6.48  
    6.49 -	snprintf(tmp, SDL_arraysize(tmp), "%p", value);
    6.50 +	SDL_snprintf(tmp, SDL_arraysize(tmp), "%p", value);
    6.51  	len = 0;
    6.52 -	if ( strlen(tmp) < maxlen ) {
    6.53 +	if ( SDL_strlen(tmp) < maxlen ) {
    6.54  		for ( i=0; tmp[i]; ++i ) {
    6.55  			*str++ = tmp[i];
    6.56  			++len;
    6.57 @@ -253,9 +253,9 @@
    6.58  	unsigned int i;
    6.59  
    6.60  	/* Allocate the UNICODE buffer */
    6.61 -	errstr16 = (Uint16 *)malloc(maxlen * (sizeof *errstr16));
    6.62 +	errstr16 = (Uint16 *)SDL_malloc(maxlen * (sizeof *errstr16));
    6.63  	if ( ! errstr16 ) {
    6.64 -		strncpy((char *)errstr, "Out of memory", maxlen);
    6.65 +		SDL_strncpy((char *)errstr, "Out of memory", maxlen);
    6.66  		errstr[maxlen-1] = '\0';
    6.67  		return(errstr);
    6.68  	}
    6.69 @@ -269,7 +269,7 @@
    6.70  	}
    6.71  
    6.72  	/* Free UNICODE buffer (if necessary) */
    6.73 -	free(errstr16);
    6.74 +	SDL_free(errstr16);
    6.75  
    6.76  	return(errstr);
    6.77  }
    6.78 @@ -320,7 +320,7 @@
    6.79  	SDL_SetError("Hi there!");
    6.80  	printf("Error 1: %s\n", SDL_GetError());
    6.81  	SDL_ClearError();
    6.82 -	memset(buffer, '1', BUFSIZ);
    6.83 +	SDL_memset(buffer, '1', BUFSIZ);
    6.84  	buffer[BUFSIZ] = 0;
    6.85  	SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
    6.86  	printf("Error 2: %s\n", SDL_GetError());
     7.1 --- a/src/audio/SDL_audio.c	Mon Feb 06 17:28:04 2006 +0000
     7.2 +++ b/src/audio/SDL_audio.c	Tue Feb 07 06:59:48 2006 +0000
     7.3 @@ -220,7 +220,7 @@
     7.4  				stream = audio->fake_stream;
     7.5  			}
     7.6  		}
     7.7 -		memset(stream, silence, stream_len);
     7.8 +		SDL_memset(stream, silence, stream_len);
     7.9  
    7.10  		if ( ! audio->paused ) {
    7.11  			SDL_mutexP(audio->mixer_lock);
    7.12 @@ -235,7 +235,7 @@
    7.13  			if ( stream == NULL ) {
    7.14  				stream = audio->fake_stream;
    7.15  			}
    7.16 -			memcpy(stream, audio->convert.buf,
    7.17 +			SDL_memcpy(stream, audio->convert.buf,
    7.18  			               audio->convert.len_cvt);
    7.19  		}
    7.20  
    7.21 @@ -299,17 +299,17 @@
    7.22  	audio = NULL;
    7.23  	idx = 0;
    7.24  #ifdef unix
    7.25 -	if ( (driver_name == NULL) && (getenv("ESPEAKER") != NULL) ) {
    7.26 +	if ( (driver_name == NULL) && (SDL_getenv("ESPEAKER") != NULL) ) {
    7.27  		/* Ahem, we know that if ESPEAKER is set, user probably wants
    7.28  		   to use ESD, but don't start it if it's not already running.
    7.29  		   This probably isn't the place to do this, but... Shh! :)
    7.30  		 */
    7.31  		for ( i=0; bootstrap[i]; ++i ) {
    7.32 -			if ( strcmp(bootstrap[i]->name, "esd") == 0 ) {
    7.33 +			if ( SDL_strcmp(bootstrap[i]->name, "esd") == 0 ) {
    7.34  				const char *esd_no_spawn;
    7.35  
    7.36  				/* Don't start ESD if it's not running */
    7.37 -				esd_no_spawn = getenv("ESD_NO_SPAWN");
    7.38 +				esd_no_spawn = SDL_getenv("ESD_NO_SPAWN");
    7.39  				if ( esd_no_spawn == NULL ) {
    7.40  					putenv("ESD_NO_SPAWN=1");
    7.41  				}
    7.42 @@ -329,13 +329,13 @@
    7.43  	if ( audio == NULL ) {
    7.44  		if ( driver_name != NULL ) {
    7.45  #if 0	/* This will be replaced with a better driver selection API */
    7.46 -			if ( strrchr(driver_name, ':') != NULL ) {
    7.47 -				idx = atoi(strrchr(driver_name, ':')+1);
    7.48 +			if ( SDL_strrchr(driver_name, ':') != NULL ) {
    7.49 +				idx = atoi(SDL_strrchr(driver_name, ':')+1);
    7.50  			}
    7.51  #endif
    7.52  			for ( i=0; bootstrap[i]; ++i ) {
    7.53 -				if (strncmp(bootstrap[i]->name, driver_name,
    7.54 -				            strlen(bootstrap[i]->name)) == 0) {
    7.55 +				if (SDL_strncmp(bootstrap[i]->name, driver_name,
    7.56 +				            SDL_strlen(bootstrap[i]->name)) == 0) {
    7.57  					if ( bootstrap[i]->available() ) {
    7.58  						audio=bootstrap[i]->create(idx);
    7.59  						break;
    7.60 @@ -375,7 +375,7 @@
    7.61  char *SDL_AudioDriverName(char *namebuf, int maxlen)
    7.62  {
    7.63  	if ( current_audio != NULL ) {
    7.64 -		strncpy(namebuf, current_audio->name, maxlen-1);
    7.65 +		SDL_strncpy(namebuf, current_audio->name, maxlen-1);
    7.66  		namebuf[maxlen-1] = '\0';
    7.67  		return(namebuf);
    7.68  	}
    7.69 @@ -436,7 +436,7 @@
    7.70  	SDL_CalculateAudioSpec(desired);
    7.71  
    7.72  	/* Open the audio subsystem */
    7.73 -	memcpy(&audio->spec, desired, sizeof(audio->spec));
    7.74 +	SDL_memcpy(&audio->spec, desired, sizeof(audio->spec));
    7.75  	audio->convert.needed = 0;
    7.76  	audio->enabled = 1;
    7.77  	audio->paused  = 1;
    7.78 @@ -489,7 +489,7 @@
    7.79  
    7.80  	/* See if we need to do any conversion */
    7.81  	if ( obtained != NULL ) {
    7.82 -		memcpy(obtained, &audio->spec, sizeof(audio->spec));
    7.83 +		SDL_memcpy(obtained, &audio->spec, sizeof(audio->spec));
    7.84  	} else if ( desired->freq != audio->spec.freq ||
    7.85                      desired->format != audio->spec.format ||
    7.86  	            desired->channels != audio->spec.channels ) {
     8.1 --- a/src/audio/SDL_audiodev.c	Mon Feb 06 17:28:04 2006 +0000
     8.2 +++ b/src/audio/SDL_audiodev.c	Tue Feb 07 06:59:48 2006 +0000
     8.3 @@ -55,8 +55,8 @@
     8.4  	char audiopath[1024];
     8.5  
     8.6  	/* Figure out what our audio device is */
     8.7 -	if ( ((audiodev=getenv("SDL_PATH_DSP")) == NULL) &&
     8.8 -	     ((audiodev=getenv("AUDIODEV")) == NULL) ) {
     8.9 +	if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) &&
    8.10 +	     ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) {
    8.11  		if ( classic ) {
    8.12  			audiodev = _PATH_DEV_AUDIO;
    8.13  		} else {
    8.14 @@ -74,7 +74,7 @@
    8.15  	audio_fd = open(audiodev, flags, 0);
    8.16  
    8.17  	/* If the first open fails, look for other devices */
    8.18 -	if ( (audio_fd < 0) && (strlen(audiodev) < (sizeof(audiopath)-3)) ) {
    8.19 +	if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) {
    8.20  		int exists, instance;
    8.21  		struct stat sb;
    8.22  
    8.23 @@ -90,7 +90,7 @@
    8.24  		audiodev = audiopath;
    8.25  	}
    8.26  	if ( path != NULL ) {
    8.27 -		strncpy(path, audiodev, maxlen);
    8.28 +		SDL_strncpy(path, audiodev, maxlen);
    8.29  		path[maxlen-1] = '\0';
    8.30  	}
    8.31  	return(audio_fd);
    8.32 @@ -130,15 +130,15 @@
    8.33  	int  audio_fd;
    8.34  
    8.35  	/* Figure out what our audio device is */
    8.36 -	if ((audiodev=getenv("SDL_PATH_DSP")) == NULL) {
    8.37 -	    audiodev=getenv("AUDIODEV");
    8.38 +	if ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) {
    8.39 +	    audiodev=SDL_getenv("AUDIODEV");
    8.40  	}
    8.41  	if ( audiodev == NULL ) {
    8.42  	    return -1;
    8.43  	}
    8.44  	audio_fd = open(audiodev, flags, 0);
    8.45  	if ( path != NULL ) {
    8.46 -		strncpy(path, audiodev, maxlen);
    8.47 +		SDL_strncpy(path, audiodev, maxlen);
    8.48  		path[maxlen-1] = '\0';
    8.49  	}
    8.50  	return audio_fd;
    8.51 @@ -168,7 +168,7 @@
    8.52  	    audio_fd = open(audiopath, flags, 0);
    8.53  	    if ( audio_fd > 0 ) {
    8.54  		if ( path != NULL ) {
    8.55 -		    strncpy( path, audiopath, maxlen );
    8.56 +		    SDL_strncpy( path, audiopath, maxlen );
    8.57  		    path[maxlen-1] = '\0';
    8.58  		}
    8.59  	        return audio_fd;
     9.1 --- a/src/audio/SDL_audiomem.c	Mon Feb 06 17:28:04 2006 +0000
     9.2 +++ b/src/audio/SDL_audiomem.c	Tue Feb 07 06:59:48 2006 +0000
     9.3 @@ -52,7 +52,7 @@
     9.4  	/* Set the segment for deletion when it is detatched */
     9.5  	shmctl(semid, IPC_RMID, NULL);	/* Delets semid if shmat() fails */
     9.6  #else
     9.7 -	chunk = malloc(size);
     9.8 +	chunk = SDL_malloc(size);
     9.9  #endif
    9.10  	return((void *)chunk);
    9.11  }
    9.12 @@ -62,6 +62,6 @@
    9.13  #ifdef FORK_HACK
    9.14  	shmdt(chunk);
    9.15  #else
    9.16 -	free(chunk);
    9.17 +	SDL_free(chunk);
    9.18  #endif
    9.19  }
    10.1 --- a/src/audio/SDL_sysaudio.h	Mon Feb 06 17:28:04 2006 +0000
    10.2 +++ b/src/audio/SDL_sysaudio.h	Tue Feb 07 06:59:48 2006 +0000
    10.3 @@ -2,7 +2,7 @@
    10.4      SDL - Simple DirectMedia Layer
    10.5      Copyright (C) 1997-2006 Sam Lantinga
    10.6  
    10.7 -    This library is free software; you can redistribute it and/or
    10.8 +    This library is SDL_free software; you can redistribute it and/or
    10.9      modify it under the terms of the GNU Lesser General Public
   10.10      License as published by the Free Software Foundation; either
   10.11      version 2.1 of the License, or (at your option) any later version.
    11.1 --- a/src/audio/SDL_wave.c	Mon Feb 06 17:28:04 2006 +0000
    11.2 +++ b/src/audio/SDL_wave.c	Tue Feb 07 06:59:48 2006 +0000
    11.3 @@ -135,7 +135,7 @@
    11.4  	*audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) * 
    11.5  				MS_ADPCM_state.wSamplesPerBlock*
    11.6  				MS_ADPCM_state.wavefmt.channels*sizeof(Sint16);
    11.7 -	*audio_buf = (Uint8 *)malloc(*audio_len);
    11.8 +	*audio_buf = (Uint8 *)SDL_malloc(*audio_len);
    11.9  	if ( *audio_buf == NULL ) {
   11.10  		SDL_Error(SDL_ENOMEM);
   11.11  		return(-1);
   11.12 @@ -214,7 +214,7 @@
   11.13  		}
   11.14  		encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
   11.15  	}
   11.16 -	free(freeable);
   11.17 +	SDL_free(freeable);
   11.18  	return(0);
   11.19  }
   11.20  
   11.21 @@ -352,7 +352,7 @@
   11.22  	*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) * 
   11.23  				IMA_ADPCM_state.wSamplesPerBlock*
   11.24  				IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16);
   11.25 -	*audio_buf = (Uint8 *)malloc(*audio_len);
   11.26 +	*audio_buf = (Uint8 *)SDL_malloc(*audio_len);
   11.27  	if ( *audio_buf == NULL ) {
   11.28  		SDL_Error(SDL_ENOMEM);
   11.29  		return(-1);
   11.30 @@ -394,7 +394,7 @@
   11.31  		}
   11.32  		encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
   11.33  	}
   11.34 -	free(freeable);
   11.35 +	SDL_free(freeable);
   11.36  	return(0);
   11.37  }
   11.38  
   11.39 @@ -444,7 +444,7 @@
   11.40  	chunk.data = NULL;
   11.41  	do {
   11.42  		if ( chunk.data != NULL ) {
   11.43 -			free(chunk.data);
   11.44 +			SDL_free(chunk.data);
   11.45  		}
   11.46  		lenread = ReadChunk(src, &chunk);
   11.47  		if ( lenread < 0 ) {
   11.48 @@ -489,7 +489,7 @@
   11.49  			was_error = 1;
   11.50  			goto done;
   11.51  	}
   11.52 -	memset(spec, 0, (sizeof *spec));
   11.53 +	SDL_memset(spec, 0, (sizeof *spec));
   11.54  	spec->freq = SDL_SwapLE32(format->frequency);
   11.55  	switch (SDL_SwapLE16(format->bitspersample)) {
   11.56  		case 4:
   11.57 @@ -521,7 +521,7 @@
   11.58  	*audio_buf = NULL;
   11.59  	do {
   11.60  		if ( *audio_buf != NULL ) {
   11.61 -			free(*audio_buf);
   11.62 +			SDL_free(*audio_buf);
   11.63  		}
   11.64  		lenread = ReadChunk(src, &chunk);
   11.65  		if ( lenread < 0 ) {
   11.66 @@ -553,7 +553,7 @@
   11.67  
   11.68  done:
   11.69  	if ( format != NULL ) {
   11.70 -		free(format);
   11.71 +		SDL_free(format);
   11.72  	}
   11.73  	if ( freesrc && src ) {
   11.74  		SDL_RWclose(src);
   11.75 @@ -574,7 +574,7 @@
   11.76  void SDL_FreeWAV(Uint8 *audio_buf)
   11.77  {
   11.78  	if ( audio_buf != NULL ) {
   11.79 -		free(audio_buf);
   11.80 +		SDL_free(audio_buf);
   11.81  	}
   11.82  }
   11.83  
   11.84 @@ -582,14 +582,14 @@
   11.85  {
   11.86  	chunk->magic	= SDL_ReadLE32(src);
   11.87  	chunk->length	= SDL_ReadLE32(src);
   11.88 -	chunk->data = (Uint8 *)malloc(chunk->length);
   11.89 +	chunk->data = (Uint8 *)SDL_malloc(chunk->length);
   11.90  	if ( chunk->data == NULL ) {
   11.91  		SDL_Error(SDL_ENOMEM);
   11.92  		return(-1);
   11.93  	}
   11.94  	if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) {
   11.95  		SDL_Error(SDL_EFREAD);
   11.96 -		free(chunk->data);
   11.97 +		SDL_free(chunk->data);
   11.98  		return(-1);
   11.99  	}
  11.100  	return(chunk->length);
    12.1 --- a/src/audio/SDL_wave.h	Mon Feb 06 17:28:04 2006 +0000
    12.2 +++ b/src/audio/SDL_wave.h	Tue Feb 07 06:59:48 2006 +0000
    12.3 @@ -2,7 +2,7 @@
    12.4      SDL - Simple DirectMedia Layer
    12.5      Copyright (C) 1997-2006 Sam Lantinga
    12.6  
    12.7 -    This library is free software; you can redistribute it and/or
    12.8 +    This library is SDL_free software; you can redistribute it and/or
    12.9      modify it under the terms of the GNU Lesser General Public
   12.10      License as published by the Free Software Foundation; either
   12.11      version 2.1 of the License, or (at your option) any later version.
    13.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Mon Feb 06 17:28:04 2006 +0000
    13.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Feb 07 06:59:48 2006 +0000
    13.3 @@ -170,7 +170,7 @@
    13.4  {
    13.5  	const char *device;
    13.6  	
    13.7 -	device = getenv("AUDIODEV");	/* Is there a standard variable name? */
    13.8 +	device = SDL_getenv("AUDIODEV");	/* Is there a standard variable name? */
    13.9  	if ( device == NULL ) {
   13.10  		if (channels == 6) device = "surround51";
   13.11  		else if (channels == 4) device = "surround40";
   13.12 @@ -202,8 +202,8 @@
   13.13  
   13.14  static void Audio_DeleteDevice(SDL_AudioDevice *device)
   13.15  {
   13.16 -	free(device->hidden);
   13.17 -	free(device);
   13.18 +	SDL_free(device->hidden);
   13.19 +	SDL_free(device);
   13.20  	UnloadALSALibrary();
   13.21  }
   13.22  
   13.23 @@ -213,20 +213,20 @@
   13.24  
   13.25  	/* Initialize all variables that we clean on shutdown */
   13.26  	LoadALSALibrary();
   13.27 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   13.28 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   13.29  	if ( this ) {
   13.30 -		memset(this, 0, (sizeof *this));
   13.31 +		SDL_memset(this, 0, (sizeof *this));
   13.32  		this->hidden = (struct SDL_PrivateAudioData *)
   13.33 -				malloc((sizeof *this->hidden));
   13.34 +				SDL_malloc((sizeof *this->hidden));
   13.35  	}
   13.36  	if ( (this == NULL) || (this->hidden == NULL) ) {
   13.37  		SDL_OutOfMemory();
   13.38  		if ( this ) {
   13.39 -			free(this);
   13.40 +			SDL_free(this);
   13.41  		}
   13.42  		return(0);
   13.43  	}
   13.44 -	memset(this->hidden, 0, (sizeof *this->hidden));
   13.45 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   13.46  
   13.47  	/* Set the function pointers */
   13.48  	this->OpenAudio = ALSA_OpenAudio;
   13.49 @@ -435,7 +435,7 @@
   13.50  		ALSA_CloseAudio(this);
   13.51  		return(-1);
   13.52  	}
   13.53 -	memset(mixbuf, spec->silence, spec->size);
   13.54 +	SDL_memset(mixbuf, spec->silence, spec->size);
   13.55  
   13.56  	/* Get the parent process id (we're the parent of the audio thread) */
   13.57  	parent = getpid();
    14.1 --- a/src/audio/amigaos/SDL_ahiaudio.c	Mon Feb 06 17:28:04 2006 +0000
    14.2 +++ b/src/audio/amigaos/SDL_ahiaudio.c	Tue Feb 07 06:59:48 2006 +0000
    14.3 @@ -74,8 +74,8 @@
    14.4  
    14.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    14.6  {
    14.7 -	free(device->hidden);
    14.8 -	free(device);
    14.9 +	SDL_free(device->hidden);
   14.10 +	SDL_free(device);
   14.11  }
   14.12  
   14.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   14.14 @@ -87,20 +87,20 @@
   14.15  #endif
   14.16  
   14.17  	/* Initialize all variables that we clean on shutdown */
   14.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   14.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   14.20  	if ( this ) {
   14.21 -		memset(this, 0, (sizeof *this));
   14.22 +		SDL_memset(this, 0, (sizeof *this));
   14.23  		this->hidden = (struct SDL_PrivateAudioData *)
   14.24 -				malloc((sizeof *this->hidden));
   14.25 +				SDL_malloc((sizeof *this->hidden));
   14.26  	}
   14.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   14.28  		SDL_OutOfMemory();
   14.29  		if ( this ) {
   14.30 -			free(this);
   14.31 +			SDL_free(this);
   14.32  		}
   14.33  		return(0);
   14.34  	}
   14.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   14.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   14.37  
   14.38  	/* Set the function pointers */
   14.39  	this->OpenAudio = AHI_OpenAudio;
   14.40 @@ -316,7 +316,7 @@
   14.41  	
   14.42  	D(bug("Before audio_req memcpy\n"));
   14.43  
   14.44 -	memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest));
   14.45 +	SDL_memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest));
   14.46  
   14.47  	if ( mixbuf[0] == NULL || mixbuf[1] == NULL ) {
   14.48  		SDL_OutOfMemory();
   14.49 @@ -325,8 +325,8 @@
   14.50  
   14.51  	D(bug("Before mixbuf memset\n"));
   14.52  
   14.53 -	memset(mixbuf[0], spec->silence, spec->size);
   14.54 -	memset(mixbuf[1], spec->silence, spec->size);
   14.55 +	SDL_memset(mixbuf[0], spec->silence, spec->size);
   14.56 +	SDL_memset(mixbuf[1], spec->silence, spec->size);
   14.57  
   14.58  	current_buffer=0;
   14.59  	playing=0;
    15.1 --- a/src/audio/arts/SDL_artsaudio.c	Mon Feb 06 17:28:04 2006 +0000
    15.2 +++ b/src/audio/arts/SDL_artsaudio.c	Tue Feb 07 06:59:48 2006 +0000
    15.3 @@ -152,8 +152,8 @@
    15.4  
    15.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    15.6  {
    15.7 -	free(device->hidden);
    15.8 -	free(device);
    15.9 +	SDL_free(device->hidden);
   15.10 +	SDL_free(device);
   15.11  	UnloadARTSLibrary();
   15.12  }
   15.13  
   15.14 @@ -163,20 +163,20 @@
   15.15  
   15.16  	/* Initialize all variables that we clean on shutdown */
   15.17  	LoadARTSLibrary();
   15.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   15.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   15.20  	if ( this ) {
   15.21 -		memset(this, 0, (sizeof *this));
   15.22 +		SDL_memset(this, 0, (sizeof *this));
   15.23  		this->hidden = (struct SDL_PrivateAudioData *)
   15.24 -				malloc((sizeof *this->hidden));
   15.25 +				SDL_malloc((sizeof *this->hidden));
   15.26  	}
   15.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   15.28  		SDL_OutOfMemory();
   15.29  		if ( this ) {
   15.30 -			free(this);
   15.31 +			SDL_free(this);
   15.32  		}
   15.33  		return(0);
   15.34  	}
   15.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   15.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   15.37  	stream = 0;
   15.38  
   15.39  	/* Set the function pointers */
   15.40 @@ -331,7 +331,7 @@
   15.41  	if ( mixbuf == NULL ) {
   15.42  		return(-1);
   15.43  	}
   15.44 -	memset(mixbuf, spec->silence, spec->size);
   15.45 +	SDL_memset(mixbuf, spec->silence, spec->size);
   15.46  
   15.47  	/* Get the parent process id (we're the parent of the audio thread) */
   15.48  	parent = getpid();
    16.1 --- a/src/audio/baudio/SDL_beaudio.cc	Mon Feb 06 17:28:04 2006 +0000
    16.2 +++ b/src/audio/baudio/SDL_beaudio.cc	Tue Feb 07 06:59:48 2006 +0000
    16.3 @@ -54,8 +54,8 @@
    16.4  
    16.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    16.6  {
    16.7 -	free(device->hidden);
    16.8 -	free(device);
    16.9 +	SDL_free(device->hidden);
   16.10 +	SDL_free(device);
   16.11  }
   16.12  
   16.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   16.14 @@ -63,20 +63,20 @@
   16.15  	SDL_AudioDevice *device;
   16.16  
   16.17  	/* Initialize all variables that we clean on shutdown */
   16.18 -	device = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   16.19 +	device = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   16.20  	if ( device ) {
   16.21 -		memset(device, 0, (sizeof *device));
   16.22 +		SDL_memset(device, 0, (sizeof *device));
   16.23  		device->hidden = (struct SDL_PrivateAudioData *)
   16.24 -				malloc((sizeof *device->hidden));
   16.25 +				SDL_malloc((sizeof *device->hidden));
   16.26  	}
   16.27  	if ( (device == NULL) || (device->hidden == NULL) ) {
   16.28  		SDL_OutOfMemory();
   16.29  		if ( device ) {
   16.30 -			free(device);
   16.31 +			SDL_free(device);
   16.32  		}
   16.33  		return(0);
   16.34  	}
   16.35 -	memset(device->hidden, 0, (sizeof *device->hidden));
   16.36 +	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
   16.37  
   16.38  	/* Set the function pointers */
   16.39  	device->OpenAudio = BE_OpenAudio;
   16.40 @@ -102,7 +102,7 @@
   16.41  	SDL_AudioDevice *audio = (SDL_AudioDevice *)device;
   16.42  
   16.43  	/* Silence the buffer, since it's ours */
   16.44 -	memset(stream, audio->spec.silence, len);
   16.45 +	SDL_memset(stream, audio->spec.silence, len);
   16.46  
   16.47  	/* Only do soemthing if audio is enabled */
   16.48  	if ( ! audio->enabled )
   16.49 @@ -115,7 +115,7 @@
   16.50  				(Uint8 *)audio->convert.buf,audio->convert.len);
   16.51  			SDL_mutexV(audio->mixer_lock);
   16.52  			SDL_ConvertAudio(&audio->convert);
   16.53 -			memcpy(stream,audio->convert.buf,audio->convert.len_cvt);
   16.54 +			SDL_memcpy(stream,audio->convert.buf,audio->convert.len_cvt);
   16.55  		} else {
   16.56  			SDL_mutexP(audio->mixer_lock);
   16.57  			(*audio->spec.callback)(audio->spec.userdata,
    17.1 --- a/src/audio/dart/SDL_dart.c	Mon Feb 06 17:28:04 2006 +0000
    17.2 +++ b/src/audio/dart/SDL_dart.c	Tue Feb 07 06:59:48 2006 +0000
    17.3 @@ -94,7 +94,7 @@
    17.4    int rc;
    17.5  
    17.6    // First thing is to try to open a given DART device!
    17.7 -  memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS));
    17.8 +  SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS));
    17.9    // pszDeviceType should contain the device type in low word, and device ordinal in high word!
   17.10    AmpOpenParms.pszDeviceType = (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16));
   17.11  
   17.12 @@ -138,7 +138,7 @@
   17.13    iBufSize = spec->size;
   17.14  
   17.15    // Now query this device if it supports the given freq/bits/channels!
   17.16 -  memset(&(_this->hidden->MixSetupParms), 0, sizeof(MCI_MIXSETUP_PARMS));
   17.17 +  SDL_memset(&(_this->hidden->MixSetupParms), 0, sizeof(MCI_MIXSETUP_PARMS));
   17.18    _this->hidden->MixSetupParms.ulBitsPerSample = iBits;
   17.19    _this->hidden->MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM;
   17.20    _this->hidden->MixSetupParms.ulSamplesPerSec = iFreq;
   17.21 @@ -170,7 +170,7 @@
   17.22    // Ok, the device is initialized.
   17.23    // Now we should allocate buffers. For this, we need a place where
   17.24    // the buffer descriptors will be:
   17.25 -  _this->hidden->pMixBuffers = (MCI_MIX_BUFFER *) malloc(sizeof(MCI_MIX_BUFFER)*iNumBufs);
   17.26 +  _this->hidden->pMixBuffers = (MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER)*iNumBufs);
   17.27    if (!(_this->hidden->pMixBuffers))
   17.28    { // Not enough memory!
   17.29      // Close DART, and exit with error code!
   17.30 @@ -190,7 +190,7 @@
   17.31    if ((rc!=MCIERR_SUCCESS) || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers) || (_this->hidden->BufferParms.ulBufferSize==0))
   17.32    { // Could not allocate memory!
   17.33      // Close DART, and exit with error code!
   17.34 -    free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.35 +    SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.36      mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
   17.37      SDL_SetError("DART could not allocate buffers");
   17.38      return(-1);
   17.39 @@ -200,18 +200,18 @@
   17.40      int i;
   17.41      for (i=0; i<iNumBufs; i++)
   17.42      {
   17.43 -      pMixBufferDesc pBufferDesc = (pMixBufferDesc) malloc(sizeof(tMixBufferDesc));;
   17.44 +      pMixBufferDesc pBufferDesc = (pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));;
   17.45        // Check if this buffer was really allocated by DART
   17.46        if ((!(_this->hidden->pMixBuffers[i].pBuffer)) || (!pBufferDesc))
   17.47        { // Wrong buffer!
   17.48          // Close DART, and exit with error code!
   17.49          // Free buffer descriptions
   17.50          { int j;
   17.51 -          for (j=0; j<i; j++) free((void *)(_this->hidden->pMixBuffers[j].ulUserParm));
   17.52 +          for (j=0; j<i; j++) SDL_free((void *)(_this->hidden->pMixBuffers[j].ulUserParm));
   17.53          }
   17.54          // and cleanup
   17.55          mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
   17.56 -        free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.57 +        SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.58          mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
   17.59          SDL_SetError("Error at internal buffer check");
   17.60          return(-1);
   17.61 @@ -224,7 +224,7 @@
   17.62        _this->hidden->pMixBuffers[i].ulFlags = 0; // Some stuff should be flagged here for DART, like end of
   17.63                                              // audio data, but as we will continously send
   17.64                                              // audio data, there will be no end.:)
   17.65 -      memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence, iBufSize);
   17.66 +      SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence, iBufSize);
   17.67      }
   17.68    }
   17.69    _this->hidden->iNextFreeBuffer = 0;
   17.70 @@ -235,10 +235,10 @@
   17.71      // Could not create event semaphore!
   17.72      {
   17.73        int i;
   17.74 -      for (i=0; i<iNumBufs; i++) free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
   17.75 +      for (i=0; i<iNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
   17.76      }
   17.77      mciSendCommand(iDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
   17.78 -    free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.79 +    SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.80      mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
   17.81      SDL_SetError("Could not create event semaphore");
   17.82      return(-1);
   17.83 @@ -363,14 +363,14 @@
   17.84    // Free memory of buffer descriptions
   17.85    {
   17.86      int i;
   17.87 -    for (i=0; i<_this->hidden->iCurrNumBufs; i++) free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
   17.88 +    for (i=0; i<_this->hidden->iCurrNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
   17.89    }
   17.90  
   17.91    // Deallocate buffers
   17.92    rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
   17.93  
   17.94    // Free bufferlist
   17.95 -  free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.96 +  SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
   17.97  
   17.98    // Close dart
   17.99    rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, &(GenericParms), 0);
  17.100 @@ -385,8 +385,8 @@
  17.101  
  17.102  void Audio_DeleteDevice(SDL_AudioDevice *device)
  17.103  {
  17.104 -  free(device->hidden);
  17.105 -  free(device);
  17.106 +  SDL_free(device->hidden);
  17.107 +  SDL_free(device);
  17.108  }
  17.109  
  17.110  SDL_AudioDevice *Audio_CreateDevice(int devindex)
  17.111 @@ -394,21 +394,21 @@
  17.112    SDL_AudioDevice *this;
  17.113  
  17.114    /* Initialize all variables that we clean on shutdown */
  17.115 -  this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
  17.116 +  this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
  17.117    if ( this )
  17.118    {
  17.119 -    memset(this, 0, (sizeof *this));
  17.120 +    SDL_memset(this, 0, (sizeof *this));
  17.121      this->hidden = (struct SDL_PrivateAudioData *)
  17.122 -      malloc((sizeof *this->hidden));
  17.123 +      SDL_malloc((sizeof *this->hidden));
  17.124    }
  17.125    if ( (this == NULL) || (this->hidden == NULL) )
  17.126    {
  17.127      SDL_OutOfMemory();
  17.128      if ( this )
  17.129 -      free(this);
  17.130 +      SDL_free(this);
  17.131      return(0);
  17.132    }
  17.133 -  memset(this->hidden, 0, (sizeof *this->hidden));
  17.134 +  SDL_memset(this->hidden, 0, (sizeof *this->hidden));
  17.135  
  17.136    /* Set the function pointers */
  17.137    this->OpenAudio = DART_OpenAudio;
    18.1 --- a/src/audio/dc/SDL_dcaudio.c	Mon Feb 06 17:28:04 2006 +0000
    18.2 +++ b/src/audio/dc/SDL_dcaudio.c	Tue Feb 07 06:59:48 2006 +0000
    18.3 @@ -60,8 +60,8 @@
    18.4  
    18.5  static void DCAUD_DeleteDevice(SDL_AudioDevice *device)
    18.6  {
    18.7 -	free(device->hidden);
    18.8 -	free(device);
    18.9 +	SDL_free(device->hidden);
   18.10 +	SDL_free(device);
   18.11  }
   18.12  
   18.13  static SDL_AudioDevice *DCAUD_CreateDevice(int devindex)
   18.14 @@ -69,20 +69,20 @@
   18.15  	SDL_AudioDevice *this;
   18.16  
   18.17  	/* Initialize all variables that we clean on shutdown */
   18.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   18.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   18.20  	if ( this ) {
   18.21 -		memset(this, 0, (sizeof *this));
   18.22 +		SDL_memset(this, 0, (sizeof *this));
   18.23  		this->hidden = (struct SDL_PrivateAudioData *)
   18.24 -				malloc((sizeof *this->hidden));
   18.25 +				SDL_malloc((sizeof *this->hidden));
   18.26  	}
   18.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   18.28  		SDL_OutOfMemory();
   18.29  		if ( this ) {
   18.30 -			free(this);
   18.31 +			SDL_free(this);
   18.32  		}
   18.33  		return(0);
   18.34  	}
   18.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   18.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   18.37  
   18.38  	/* Set the function pointers */
   18.39  	this->OpenAudio = DCAUD_OpenAudio;
   18.40 @@ -229,7 +229,7 @@
   18.41  	if ( this->hidden->mixbuf == NULL ) {
   18.42  		return(-1);
   18.43  	}
   18.44 -	memset(this->hidden->mixbuf, spec->silence, spec->size);
   18.45 +	SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
   18.46  	this->hidden->leftpos = 0x11000;
   18.47  	this->hidden->rightpos = 0x11000+spec->size;
   18.48  	this->hidden->playing = 0;
    19.1 --- a/src/audio/disk/SDL_diskaudio.c	Mon Feb 06 17:28:04 2006 +0000
    19.2 +++ b/src/audio/disk/SDL_diskaudio.c	Tue Feb 07 06:59:48 2006 +0000
    19.3 @@ -62,7 +62,7 @@
    19.4  
    19.5  static const char *DISKAUD_GetOutputFilename(void)
    19.6  {
    19.7 -    const char *envr = getenv(DISKENVR_OUTFILE);
    19.8 +    const char *envr = SDL_getenv(DISKENVR_OUTFILE);
    19.9      return((envr != NULL) ? envr : DISKDEFAULT_OUTFILE);
   19.10  }
   19.11  
   19.12 @@ -75,10 +75,10 @@
   19.13      int exists = 0;
   19.14      struct stat statbuf;
   19.15      const char *fname = DISKAUD_GetOutputFilename();
   19.16 -	const char *envr = getenv("SDL_AUDIODRIVER");
   19.17 +	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
   19.18  	available = 0;
   19.19  
   19.20 -	if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
   19.21 +	if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
   19.22  		if (stat(fname, &statbuf) == 0)
   19.23  			exists = 1;
   19.24  
   19.25 @@ -93,8 +93,8 @@
   19.26  	}
   19.27  	return(available);
   19.28  #else
   19.29 -	const char *envr = getenv("SDL_AUDIODRIVER");
   19.30 -	if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
   19.31 +	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
   19.32 +	if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
   19.33  		return(1);
   19.34  	}
   19.35  
   19.36 @@ -104,8 +104,8 @@
   19.37  
   19.38  static void DISKAUD_DeleteDevice(SDL_AudioDevice *device)
   19.39  {
   19.40 -	free(device->hidden);
   19.41 -	free(device);
   19.42 +	SDL_free(device->hidden);
   19.43 +	SDL_free(device);
   19.44  }
   19.45  
   19.46  static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
   19.47 @@ -114,22 +114,22 @@
   19.48      const char *envr;
   19.49  
   19.50  	/* Initialize all variables that we clean on shutdown */
   19.51 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   19.52 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   19.53  	if ( this ) {
   19.54 -		memset(this, 0, (sizeof *this));
   19.55 +		SDL_memset(this, 0, (sizeof *this));
   19.56  		this->hidden = (struct SDL_PrivateAudioData *)
   19.57 -				malloc((sizeof *this->hidden));
   19.58 +				SDL_malloc((sizeof *this->hidden));
   19.59  	}
   19.60  	if ( (this == NULL) || (this->hidden == NULL) ) {
   19.61  		SDL_OutOfMemory();
   19.62  		if ( this ) {
   19.63 -			free(this);
   19.64 +			SDL_free(this);
   19.65  		}
   19.66  		return(0);
   19.67  	}
   19.68 -	memset(this->hidden, 0, (sizeof *this->hidden));
   19.69 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   19.70  
   19.71 -    envr = getenv(DISKENVR_WRITEDELAY);
   19.72 +    envr = SDL_getenv(DISKENVR_WRITEDELAY);
   19.73      this->hidden->write_delay = (envr) ? atoi(envr) : DISKDEFAULT_WRITEDELAY;
   19.74  
   19.75  	/* Set the function pointers */
   19.76 @@ -216,7 +216,7 @@
   19.77  	if ( this->hidden->mixbuf == NULL ) {
   19.78  		return(-1);
   19.79  	}
   19.80 -	memset(this->hidden->mixbuf, spec->silence, spec->size);
   19.81 +	SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
   19.82  
   19.83  	/* We're ready to rock and roll. :-) */
   19.84  	return(0);
    20.1 --- a/src/audio/dma/SDL_dmaaudio.c	Mon Feb 06 17:28:04 2006 +0000
    20.2 +++ b/src/audio/dma/SDL_dmaaudio.c	Tue Feb 07 06:59:48 2006 +0000
    20.3 @@ -93,8 +93,8 @@
    20.4  
    20.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    20.6  {
    20.7 -	free(device->hidden);
    20.8 -	free(device);
    20.9 +	SDL_free(device->hidden);
   20.10 +	SDL_free(device);
   20.11  }
   20.12  
   20.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   20.14 @@ -102,20 +102,20 @@
   20.15  	SDL_AudioDevice *this;
   20.16  
   20.17  	/* Initialize all variables that we clean on shutdown */
   20.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   20.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   20.20  	if ( this ) {
   20.21 -		memset(this, 0, (sizeof *this));
   20.22 +		SDL_memset(this, 0, (sizeof *this));
   20.23  		this->hidden = (struct SDL_PrivateAudioData *)
   20.24 -				malloc((sizeof *this->hidden));
   20.25 +				SDL_malloc((sizeof *this->hidden));
   20.26  	}
   20.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   20.28  		SDL_OutOfMemory();
   20.29  		if ( this ) {
   20.30 -			free(this);
   20.31 +			SDL_free(this);
   20.32  		}
   20.33  		return(0);
   20.34  	}
   20.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   20.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   20.37  	audio_fd = -1;
   20.38  
   20.39  	/* Set the function pointers */
   20.40 @@ -428,11 +428,11 @@
   20.41  		dma_buf = NULL;
   20.42  		return(-1);
   20.43  	}
   20.44 -	memset(dma_buf, spec->silence, dma_len);
   20.45 +	SDL_memset(dma_buf, spec->silence, dma_len);
   20.46  
   20.47  	/* Check to see if we need to use select() workaround */
   20.48  	{ char *workaround;
   20.49 -		workaround = getenv("SDL_DSP_NOSELECT");
   20.50 +		workaround = SDL_getenv("SDL_DSP_NOSELECT");
   20.51  		if ( workaround ) {
   20.52  			frame_ticks = (float)(spec->samples*1000)/spec->freq;
   20.53  			next_frame = SDL_GetTicks()+frame_ticks;
    21.1 --- a/src/audio/dmedia/SDL_irixaudio.c	Mon Feb 06 17:28:04 2006 +0000
    21.2 +++ b/src/audio/dmedia/SDL_irixaudio.c	Tue Feb 07 06:59:48 2006 +0000
    21.3 @@ -62,8 +62,8 @@
    21.4  
    21.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    21.6  {
    21.7 -	free(device->hidden);
    21.8 -	free(device);
    21.9 +	SDL_free(device->hidden);
   21.10 +	SDL_free(device);
   21.11  }
   21.12  
   21.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   21.14 @@ -71,20 +71,20 @@
   21.15  	SDL_AudioDevice *this;
   21.16  
   21.17  	/* Initialize all variables that we clean on shutdown */
   21.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   21.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   21.20  	if ( this ) {
   21.21 -		memset(this, 0, (sizeof *this));
   21.22 +		SDL_memset(this, 0, (sizeof *this));
   21.23  		this->hidden = (struct SDL_PrivateAudioData *)
   21.24 -				malloc((sizeof *this->hidden));
   21.25 +				SDL_malloc((sizeof *this->hidden));
   21.26  	}
   21.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   21.28  		SDL_OutOfMemory();
   21.29  		if ( this ) {
   21.30 -			free(this);
   21.31 +			SDL_free(this);
   21.32  		}
   21.33  		return(0);
   21.34  	}
   21.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   21.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   21.37  
   21.38  	/* Set the function pointers */
   21.39  	this->OpenAudio = AL_OpenAudio;
   21.40 @@ -211,7 +211,7 @@
   21.41  		SDL_OutOfMemory();
   21.42  		return(-1);
   21.43  	}
   21.44 -	memset(mixbuf, spec->silence, spec->size);
   21.45 +	SDL_memset(mixbuf, spec->silence, spec->size);
   21.46  
   21.47  	/* We're ready to rock and roll. :-) */
   21.48  	return(0);
    22.1 --- a/src/audio/dsp/SDL_dspaudio.c	Mon Feb 06 17:28:04 2006 +0000
    22.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Tue Feb 07 06:59:48 2006 +0000
    22.3 @@ -82,8 +82,8 @@
    22.4  
    22.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    22.6  {
    22.7 -	free(device->hidden);
    22.8 -	free(device);
    22.9 +	SDL_free(device->hidden);
   22.10 +	SDL_free(device);
   22.11  }
   22.12  
   22.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   22.14 @@ -91,20 +91,20 @@
   22.15  	SDL_AudioDevice *this;
   22.16  
   22.17  	/* Initialize all variables that we clean on shutdown */
   22.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   22.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   22.20  	if ( this ) {
   22.21 -		memset(this, 0, (sizeof *this));
   22.22 +		SDL_memset(this, 0, (sizeof *this));
   22.23  		this->hidden = (struct SDL_PrivateAudioData *)
   22.24 -				malloc((sizeof *this->hidden));
   22.25 +				SDL_malloc((sizeof *this->hidden));
   22.26  	}
   22.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   22.28  		SDL_OutOfMemory();
   22.29  		if ( this ) {
   22.30 -			free(this);
   22.31 +			SDL_free(this);
   22.32  		}
   22.33  		return(0);
   22.34  	}
   22.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   22.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   22.37  	audio_fd = -1;
   22.38  
   22.39  	/* Set the function pointers */
   22.40 @@ -322,7 +322,7 @@
   22.41  		DSP_CloseAudio(this);
   22.42  		return(-1);
   22.43  	}
   22.44 -	memset(mixbuf, spec->silence, spec->size);
   22.45 +	SDL_memset(mixbuf, spec->silence, spec->size);
   22.46  
   22.47  	/* Get the parent process id (we're the parent of the audio thread) */
   22.48  	parent = getpid();
    23.1 --- a/src/audio/esd/SDL_esdaudio.c	Mon Feb 06 17:28:04 2006 +0000
    23.2 +++ b/src/audio/esd/SDL_esdaudio.c	Tue Feb 07 06:59:48 2006 +0000
    23.3 @@ -142,8 +142,8 @@
    23.4  
    23.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    23.6  {
    23.7 -	free(device->hidden);
    23.8 -	free(device);
    23.9 +	SDL_free(device->hidden);
   23.10 +	SDL_free(device);
   23.11  	UnloadESDLibrary();
   23.12  }
   23.13  
   23.14 @@ -153,20 +153,20 @@
   23.15  
   23.16  	/* Initialize all variables that we clean on shutdown */
   23.17  	LoadESDLibrary();
   23.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   23.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   23.20  	if ( this ) {
   23.21 -		memset(this, 0, (sizeof *this));
   23.22 +		SDL_memset(this, 0, (sizeof *this));
   23.23  		this->hidden = (struct SDL_PrivateAudioData *)
   23.24 -				malloc((sizeof *this->hidden));
   23.25 +				SDL_malloc((sizeof *this->hidden));
   23.26  	}
   23.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   23.28  		SDL_OutOfMemory();
   23.29  		if ( this ) {
   23.30 -			free(this);
   23.31 +			SDL_free(this);
   23.32  		}
   23.33  		return(0);
   23.34  	}
   23.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   23.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   23.37  	audio_fd = -1;
   23.38  
   23.39  	/* Set the function pointers */
   23.40 @@ -261,7 +261,7 @@
   23.41  	fp = fopen(temp, "r");
   23.42  	if ( fp != NULL ) {
   23.43  		if ( fgets(temp, sizeof(temp)-1, fp) ) {
   23.44 -			progname = strrchr(temp, '/');
   23.45 +			progname = SDL_strrchr(temp, '/');
   23.46  			if ( progname == NULL ) {
   23.47  				progname = temp;
   23.48  			} else {
   23.49 @@ -318,7 +318,7 @@
   23.50  	if ( mixbuf == NULL ) {
   23.51  		return(-1);
   23.52  	}
   23.53 -	memset(mixbuf, spec->silence, spec->size);
   23.54 +	SDL_memset(mixbuf, spec->silence, spec->size);
   23.55  
   23.56  	/* Get the parent process id (we're the parent of the audio thread) */
   23.57  	parent = getpid();
    24.1 --- a/src/audio/macosx/SDL_coreaudio.c	Mon Feb 06 17:28:04 2006 +0000
    24.2 +++ b/src/audio/macosx/SDL_coreaudio.c	Tue Feb 07 06:59:48 2006 +0000
    24.3 @@ -52,8 +52,8 @@
    24.4  
    24.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    24.6  {
    24.7 -    free(device->hidden);
    24.8 -    free(device);
    24.9 +    SDL_free(device->hidden);
   24.10 +    SDL_free(device);
   24.11  }
   24.12  
   24.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   24.14 @@ -61,20 +61,20 @@
   24.15      SDL_AudioDevice *this;
   24.16  
   24.17      /* Initialize all variables that we clean on shutdown */
   24.18 -    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   24.19 +    this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   24.20      if ( this ) {
   24.21 -        memset(this, 0, (sizeof *this));
   24.22 +        SDL_memset(this, 0, (sizeof *this));
   24.23          this->hidden = (struct SDL_PrivateAudioData *)
   24.24 -                malloc((sizeof *this->hidden));
   24.25 +                SDL_malloc((sizeof *this->hidden));
   24.26      }
   24.27      if ( (this == NULL) || (this->hidden == NULL) ) {
   24.28          SDL_OutOfMemory();
   24.29          if ( this ) {
   24.30 -            free(this);
   24.31 +            SDL_free(this);
   24.32          }
   24.33          return(0);
   24.34      }
   24.35 -    memset(this->hidden, 0, (sizeof *this->hidden));
   24.36 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   24.37  
   24.38      /* Set the function pointers */
   24.39      this->OpenAudio = Core_OpenAudio;
   24.40 @@ -106,7 +106,7 @@
   24.41  
   24.42      /* Only do anything if audio is enabled and not paused */
   24.43      if ( ! this->enabled || this->paused ) {
   24.44 -        memset(ioData->mData, this->spec.silence, ioData->mDataByteSize);
   24.45 +        SDL_memset(ioData->mData, this->spec.silence, ioData->mDataByteSize);
   24.46          return 0;
   24.47      }
   24.48      
   24.49 @@ -121,7 +121,7 @@
   24.50      while (remaining > 0) {
   24.51          if (bufferOffset >= bufferSize) {
   24.52              /* Generate the data */
   24.53 -            memset(buffer, this->spec.silence, bufferSize);
   24.54 +            SDL_memset(buffer, this->spec.silence, bufferSize);
   24.55              SDL_mutexP(this->mixer_lock);
   24.56              (*this->spec.callback)(this->spec.userdata,
   24.57                          buffer, bufferSize);
   24.58 @@ -132,7 +132,7 @@
   24.59          len = bufferSize - bufferOffset;
   24.60          if (len > remaining)
   24.61              len = remaining;
   24.62 -        memcpy(ptr, buffer + bufferOffset, len);
   24.63 +        SDL_memcpy(ptr, buffer + bufferOffset, len);
   24.64          ptr += len;
   24.65          remaining -= len;
   24.66          bufferOffset += len;
   24.67 @@ -189,7 +189,7 @@
   24.68          return;
   24.69      }
   24.70      
   24.71 -    free(buffer);
   24.72 +    SDL_free(buffer);
   24.73  }
   24.74  
   24.75  #define CHECK_RESULT(msg) \
   24.76 @@ -269,7 +269,7 @@
   24.77      
   24.78      /* Allocate a sample buffer */
   24.79      bufferOffset = bufferSize = this->spec.size;
   24.80 -    buffer = malloc(bufferSize);
   24.81 +    buffer = SDL_malloc(bufferSize);
   24.82      assert(buffer);
   24.83      
   24.84      /* Finally, start processing of the audio unit */
    25.1 --- a/src/audio/macrom/SDL_romaudio.c	Mon Feb 06 17:28:04 2006 +0000
    25.2 +++ b/src/audio/macrom/SDL_romaudio.c	Tue Feb 07 06:59:48 2006 +0000
    25.3 @@ -66,8 +66,8 @@
    25.4  
    25.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    25.6  {
    25.7 -    free(device->hidden);
    25.8 -    free(device);
    25.9 +    SDL_free(device->hidden);
   25.10 +    SDL_free(device);
   25.11  }
   25.12  
   25.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   25.14 @@ -75,20 +75,20 @@
   25.15      SDL_AudioDevice *this;
   25.16  
   25.17      /* Initialize all variables that we clean on shutdown */
   25.18 -    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   25.19 +    this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   25.20      if ( this ) {
   25.21 -        memset(this, 0, (sizeof *this));
   25.22 +        SDL_memset(this, 0, (sizeof *this));
   25.23          this->hidden = (struct SDL_PrivateAudioData *)
   25.24 -                malloc((sizeof *this->hidden));
   25.25 +                SDL_malloc((sizeof *this->hidden));
   25.26      }
   25.27      if ( (this == NULL) || (this->hidden == NULL) ) {
   25.28          SDL_OutOfMemory();
   25.29          if ( this ) {
   25.30 -            free(this);
   25.31 +            SDL_free(this);
   25.32          }
   25.33          return(0);
   25.34      }
   25.35 -    memset(this->hidden, 0, (sizeof *this->hidden));
   25.36 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   25.37  
   25.38      /* Set the function pointers */
   25.39      this->OpenAudio   = Mac_OpenAudio;
   25.40 @@ -135,7 +135,7 @@
   25.41              if ( audio->convert.len_cvt != audio->spec.size ) {
   25.42                  /* Uh oh... probably crashes here */;
   25.43              }
   25.44 -            memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
   25.45 +            SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
   25.46          } else {
   25.47              audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
   25.48          }
   25.49 @@ -267,7 +267,7 @@
   25.50     }
   25.51     
   25.52     /* Create the sound manager channel */
   25.53 -    channel = (SndChannelPtr)malloc(sizeof(*channel));
   25.54 +    channel = (SndChannelPtr)SDL_malloc(sizeof(*channel));
   25.55      if ( channel == NULL ) {
   25.56          SDL_OutOfMemory();
   25.57          return(-1);
   25.58 @@ -281,7 +281,7 @@
   25.59      channel->qLength = 128;
   25.60      if ( SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr ) {
   25.61          SDL_SetError("Unable to create audio channel");
   25.62 -        free(channel);
   25.63 +        SDL_free(channel);
   25.64          channel = NULL;
   25.65          return(-1);
   25.66      }
   25.67 @@ -311,7 +311,7 @@
   25.68     
   25.69      for ( i=0; i<2; ++i ) {
   25.70          if ( buffer[i] ) {
   25.71 -            free(buffer[i]);
   25.72 +            SDL_free(buffer[i]);
   25.73              buffer[i] = NULL;
   25.74          }
   25.75      }
   25.76 @@ -355,7 +355,7 @@
   25.77                  /* Uh oh... probably crashes here */;
   25.78              }
   25.79  #endif
   25.80 -            memcpy(newbuf->dbSoundData, audio->convert.buf,
   25.81 +            SDL_memcpy(newbuf->dbSoundData, audio->convert.buf,
   25.82                              audio->convert.len_cvt);
   25.83          } else {
   25.84              audio->spec.callback(audio->spec.userdata,
   25.85 @@ -400,7 +400,7 @@
   25.86      }
   25.87      for ( i=0; i<2; ++i ) {
   25.88          if ( audio_buf[i] ) {
   25.89 -            free(audio_buf[i]);
   25.90 +            SDL_free(audio_buf[i]);
   25.91              audio_buf[i] = NULL;
   25.92          }
   25.93      }
   25.94 @@ -435,7 +435,7 @@
   25.95      SDL_CalculateAudioSpec(spec);
   25.96  
   25.97      /* initialize the double-back header */
   25.98 -    memset(&audio_dbh, 0, sizeof(audio_dbh));
   25.99 +    SDL_memset(&audio_dbh, 0, sizeof(audio_dbh));
  25.100      doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc);
  25.101      sample_bits = spec->size / spec->samples / spec->channels * 8;
  25.102      
  25.103 @@ -467,7 +467,7 @@
  25.104      }
  25.105  
  25.106      /* Create the sound manager channel */
  25.107 -    channel = (SndChannelPtr)malloc(sizeof(*channel));
  25.108 +    channel = (SndChannelPtr)SDL_malloc(sizeof(*channel));
  25.109      if ( channel == NULL ) {
  25.110          SDL_OutOfMemory();
  25.111          return(-1);
  25.112 @@ -481,7 +481,7 @@
  25.113      channel->qLength = 128;
  25.114      if ( SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr ) {
  25.115          SDL_SetError("Unable to create audio channel");
  25.116 -        free(channel);
  25.117 +        SDL_free(channel);
  25.118          channel = NULL;
  25.119          return(-1);
  25.120      }
    26.1 --- a/src/audio/mint/SDL_mintaudio.c	Mon Feb 06 17:28:04 2006 +0000
    26.2 +++ b/src/audio/mint/SDL_mintaudio.c	Tue Feb 07 06:59:48 2006 +0000
    26.3 @@ -63,7 +63,7 @@
    26.4  	SDL_AudioDevice *audio = SDL_MintAudio_device;
    26.5  
    26.6   	buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
    26.7 -	memset(buffer, audio->spec.silence, audio->spec.size);
    26.8 +	SDL_memset(buffer, audio->spec.silence, audio->spec.size);
    26.9  
   26.10  	if (audio->paused)
   26.11  		return;
   26.12 @@ -76,11 +76,11 @@
   26.13  		} else {
   26.14  			silence = 0;
   26.15  		}
   26.16 -		memset(audio->convert.buf, silence, audio->convert.len);
   26.17 +		SDL_memset(audio->convert.buf, silence, audio->convert.len);
   26.18  		audio->spec.callback(audio->spec.userdata,
   26.19  			(Uint8 *)audio->convert.buf,audio->convert.len);
   26.20  		SDL_ConvertAudio(&audio->convert);
   26.21 -		memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
   26.22 +		SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
   26.23  	} else {
   26.24  		audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
   26.25  	}
   26.26 @@ -106,7 +106,7 @@
   26.27  	/* Put all following ones farer */
   26.28  	if (MINTAUDIO_freqcount>0) {
   26.29  		for (i=MINTAUDIO_freqcount; i>p; i--) {
   26.30 -			memcpy(&MINTAUDIO_frequencies[i], &MINTAUDIO_frequencies[i-1], sizeof(mint_frequency_t));
   26.31 +			SDL_memcpy(&MINTAUDIO_frequencies[i], &MINTAUDIO_frequencies[i-1], sizeof(mint_frequency_t));
   26.32  		}
   26.33  	}
   26.34  
    27.1 --- a/src/audio/mint/SDL_mintaudio_dma8.c	Mon Feb 06 17:28:04 2006 +0000
    27.2 +++ b/src/audio/mint/SDL_mintaudio_dma8.c	Tue Feb 07 06:59:48 2006 +0000
    27.3 @@ -81,10 +81,10 @@
    27.4  
    27.5  static int Audio_Available(void)
    27.6  {
    27.7 -	const char *envr = getenv("SDL_AUDIODRIVER");
    27.8 +	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
    27.9  
   27.10  	/* Check if user asked a different audio driver */
   27.11 -	if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   27.12 +	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   27.13  		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
   27.14  		return 0;
   27.15  	}
   27.16 @@ -121,8 +121,8 @@
   27.17  
   27.18  static void Audio_DeleteDevice(SDL_AudioDevice *device)
   27.19  {
   27.20 -    free(device->hidden);
   27.21 -    free(device);
   27.22 +    SDL_free(device->hidden);
   27.23 +    SDL_free(device);
   27.24  }
   27.25  
   27.26  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   27.27 @@ -130,20 +130,20 @@
   27.28  	SDL_AudioDevice *this;
   27.29  
   27.30  	/* Initialize all variables that we clean on shutdown */
   27.31 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   27.32 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   27.33      if ( this ) {
   27.34 -        memset(this, 0, (sizeof *this));
   27.35 +        SDL_memset(this, 0, (sizeof *this));
   27.36          this->hidden = (struct SDL_PrivateAudioData *)
   27.37 -                malloc((sizeof *this->hidden));
   27.38 +                SDL_malloc((sizeof *this->hidden));
   27.39      }
   27.40      if ( (this == NULL) || (this->hidden == NULL) ) {
   27.41          SDL_OutOfMemory();
   27.42          if ( this ) {
   27.43 -            free(this);
   27.44 +            SDL_free(this);
   27.45          }
   27.46          return(0);
   27.47      }
   27.48 -    memset(this->hidden, 0, (sizeof *this->hidden));
   27.49 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   27.50  
   27.51      /* Set the function pointers */
   27.52      this->OpenAudio   = Mint_OpenAudio;
   27.53 @@ -347,7 +347,7 @@
   27.54  	}
   27.55  	SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
   27.56  	SDL_MintAudio_numbuf=0;
   27.57 -	memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   27.58 +	SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   27.59  	SDL_MintAudio_audiosize = spec->size;
   27.60  	SDL_MintAudio_mutex = 0;
   27.61  
    28.1 --- a/src/audio/mint/SDL_mintaudio_gsxb.c	Mon Feb 06 17:28:04 2006 +0000
    28.2 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c	Tue Feb 07 06:59:48 2006 +0000
    28.3 @@ -85,10 +85,10 @@
    28.4  
    28.5  static int Audio_Available(void)
    28.6  {
    28.7 -	const char *envr = getenv("SDL_AUDIODRIVER");
    28.8 +	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
    28.9  
   28.10  	/* Check if user asked a different audio driver */
   28.11 -	if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   28.12 +	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   28.13  		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
   28.14  		return(0);
   28.15  	}
   28.16 @@ -127,8 +127,8 @@
   28.17  
   28.18  static void Audio_DeleteDevice(SDL_AudioDevice *device)
   28.19  {
   28.20 -    free(device->hidden);
   28.21 -    free(device);
   28.22 +    SDL_free(device->hidden);
   28.23 +    SDL_free(device);
   28.24  }
   28.25  
   28.26  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   28.27 @@ -136,20 +136,20 @@
   28.28  	SDL_AudioDevice *this;
   28.29  
   28.30  	/* Initialize all variables that we clean on shutdown */
   28.31 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   28.32 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   28.33      if ( this ) {
   28.34 -        memset(this, 0, (sizeof *this));
   28.35 +        SDL_memset(this, 0, (sizeof *this));
   28.36          this->hidden = (struct SDL_PrivateAudioData *)
   28.37 -                malloc((sizeof *this->hidden));
   28.38 +                SDL_malloc((sizeof *this->hidden));
   28.39      }
   28.40      if ( (this == NULL) || (this->hidden == NULL) ) {
   28.41          SDL_OutOfMemory();
   28.42          if ( this ) {
   28.43 -            free(this);
   28.44 +            SDL_free(this);
   28.45          }
   28.46          return(0);
   28.47      }
   28.48 -    memset(this->hidden, 0, (sizeof *this->hidden));
   28.49 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   28.50  
   28.51      /* Set the function pointers */
   28.52      this->OpenAudio   = Mint_OpenAudio;
   28.53 @@ -384,7 +384,7 @@
   28.54  	}
   28.55  	SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
   28.56  	SDL_MintAudio_numbuf=0;
   28.57 -	memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   28.58 +	SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   28.59  	SDL_MintAudio_audiosize = spec->size;
   28.60  	SDL_MintAudio_mutex = 0;
   28.61  
    29.1 --- a/src/audio/mint/SDL_mintaudio_mcsn.c	Mon Feb 06 17:28:04 2006 +0000
    29.2 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c	Tue Feb 07 06:59:48 2006 +0000
    29.3 @@ -84,7 +84,7 @@
    29.4  static int Audio_Available(void)
    29.5  {
    29.6  	unsigned long dummy;
    29.7 -	const char *envr = getenv("SDL_AUDIODRIVER");
    29.8 +	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
    29.9  
   29.10  	SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
   29.11  
   29.12 @@ -94,7 +94,7 @@
   29.13  	}
   29.14  
   29.15  	/* Check if user asked a different audio driver */
   29.16 -	if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   29.17 +	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   29.18  		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
   29.19  		return(0);
   29.20  	}
   29.21 @@ -141,8 +141,8 @@
   29.22  
   29.23  static void Audio_DeleteDevice(SDL_AudioDevice *device)
   29.24  {
   29.25 -    free(device->hidden);
   29.26 -    free(device);
   29.27 +    SDL_free(device->hidden);
   29.28 +    SDL_free(device);
   29.29  }
   29.30  
   29.31  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   29.32 @@ -150,20 +150,20 @@
   29.33  	SDL_AudioDevice *this;
   29.34  
   29.35  	/* Initialize all variables that we clean on shutdown */
   29.36 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   29.37 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   29.38      if ( this ) {
   29.39 -        memset(this, 0, (sizeof *this));
   29.40 +        SDL_memset(this, 0, (sizeof *this));
   29.41          this->hidden = (struct SDL_PrivateAudioData *)
   29.42 -                malloc((sizeof *this->hidden));
   29.43 +                SDL_malloc((sizeof *this->hidden));
   29.44      }
   29.45      if ( (this == NULL) || (this->hidden == NULL) ) {
   29.46          SDL_OutOfMemory();
   29.47          if ( this ) {
   29.48 -            free(this);
   29.49 +            SDL_free(this);
   29.50          }
   29.51          return(0);
   29.52      }
   29.53 -    memset(this->hidden, 0, (sizeof *this->hidden));
   29.54 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   29.55  
   29.56      /* Set the function pointers */
   29.57      this->OpenAudio   = Mint_OpenAudio;
   29.58 @@ -388,7 +388,7 @@
   29.59  	}
   29.60  	SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
   29.61  	SDL_MintAudio_numbuf=0;
   29.62 -	memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   29.63 +	SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   29.64  	SDL_MintAudio_audiosize = spec->size;
   29.65  	SDL_MintAudio_mutex = 0;
   29.66  
    30.1 --- a/src/audio/mint/SDL_mintaudio_stfa.c	Mon Feb 06 17:28:04 2006 +0000
    30.2 +++ b/src/audio/mint/SDL_mintaudio_stfa.c	Tue Feb 07 06:59:48 2006 +0000
    30.3 @@ -89,10 +89,10 @@
    30.4  
    30.5  static int Audio_Available(void)
    30.6  {
    30.7 -	const char *envr = getenv("SDL_AUDIODRIVER");
    30.8 +	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
    30.9  
   30.10  	/* Check if user asked a different audio driver */
   30.11 -	if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   30.12 +	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   30.13  		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
   30.14  		return(0);
   30.15  	}
   30.16 @@ -121,8 +121,8 @@
   30.17  
   30.18  static void Audio_DeleteDevice(SDL_AudioDevice *device)
   30.19  {
   30.20 -    free(device->hidden);
   30.21 -    free(device);
   30.22 +    SDL_free(device->hidden);
   30.23 +    SDL_free(device);
   30.24  }
   30.25  
   30.26  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   30.27 @@ -130,20 +130,20 @@
   30.28  	SDL_AudioDevice *this;
   30.29  
   30.30  	/* Initialize all variables that we clean on shutdown */
   30.31 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   30.32 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   30.33      if ( this ) {
   30.34 -        memset(this, 0, (sizeof *this));
   30.35 +        SDL_memset(this, 0, (sizeof *this));
   30.36          this->hidden = (struct SDL_PrivateAudioData *)
   30.37 -                malloc((sizeof *this->hidden));
   30.38 +                SDL_malloc((sizeof *this->hidden));
   30.39      }
   30.40      if ( (this == NULL) || (this->hidden == NULL) ) {
   30.41          SDL_OutOfMemory();
   30.42          if ( this ) {
   30.43 -            free(this);
   30.44 +            SDL_free(this);
   30.45          }
   30.46          return(0);
   30.47      }
   30.48 -    memset(this->hidden, 0, (sizeof *this->hidden));
   30.49 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   30.50  
   30.51      /* Set the function pointers */
   30.52      this->OpenAudio   = Mint_OpenAudio;
   30.53 @@ -308,7 +308,7 @@
   30.54  	}
   30.55  	SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
   30.56  	SDL_MintAudio_numbuf=0;
   30.57 -	memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   30.58 +	SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   30.59  	SDL_MintAudio_audiosize = spec->size;
   30.60  	SDL_MintAudio_mutex = 0;
   30.61  
    31.1 --- a/src/audio/mint/SDL_mintaudio_xbios.c	Mon Feb 06 17:28:04 2006 +0000
    31.2 +++ b/src/audio/mint/SDL_mintaudio_xbios.c	Tue Feb 07 06:59:48 2006 +0000
    31.3 @@ -84,7 +84,7 @@
    31.4  static int Audio_Available(void)
    31.5  {
    31.6  	unsigned long dummy;
    31.7 -	const char *envr = getenv("SDL_AUDIODRIVER");
    31.8 +	const char *envr = SDL_getenv("SDL_AUDIODRIVER");
    31.9  
   31.10  	SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
   31.11  
   31.12 @@ -94,7 +94,7 @@
   31.13  	}
   31.14  
   31.15  	/* Check if user asked a different audio driver */
   31.16 -	if ((envr) && (strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   31.17 +	if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME)!=0)) {
   31.18  		DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n"));
   31.19  		return(0);
   31.20  	}
   31.21 @@ -124,8 +124,8 @@
   31.22  
   31.23  static void Audio_DeleteDevice(SDL_AudioDevice *device)
   31.24  {
   31.25 -    free(device->hidden);
   31.26 -    free(device);
   31.27 +    SDL_free(device->hidden);
   31.28 +    SDL_free(device);
   31.29  }
   31.30  
   31.31  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   31.32 @@ -133,20 +133,20 @@
   31.33  	SDL_AudioDevice *this;
   31.34  
   31.35  	/* Initialize all variables that we clean on shutdown */
   31.36 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   31.37 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   31.38      if ( this ) {
   31.39 -        memset(this, 0, (sizeof *this));
   31.40 +        SDL_memset(this, 0, (sizeof *this));
   31.41          this->hidden = (struct SDL_PrivateAudioData *)
   31.42 -                malloc((sizeof *this->hidden));
   31.43 +                SDL_malloc((sizeof *this->hidden));
   31.44      }
   31.45      if ( (this == NULL) || (this->hidden == NULL) ) {
   31.46          SDL_OutOfMemory();
   31.47          if ( this ) {
   31.48 -            free(this);
   31.49 +            SDL_free(this);
   31.50          }
   31.51          return(0);
   31.52      }
   31.53 -    memset(this->hidden, 0, (sizeof *this->hidden));
   31.54 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   31.55  
   31.56      /* Set the function pointers */
   31.57      this->OpenAudio   = Mint_OpenAudio;
   31.58 @@ -285,7 +285,7 @@
   31.59  		DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n"));
   31.60  		return;
   31.61  	}
   31.62 -	memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE);
   31.63 +	SDL_memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE);
   31.64  
   31.65  	Buffoper(0);
   31.66  	Settracks(0,0);
   31.67 @@ -477,7 +477,7 @@
   31.68  	}
   31.69  	SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size ;
   31.70  	SDL_MintAudio_numbuf=0;
   31.71 -	memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   31.72 +	SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size *2);
   31.73  	SDL_MintAudio_audiosize = spec->size;
   31.74  	SDL_MintAudio_mutex = 0;
   31.75  
    32.1 --- a/src/audio/mme/SDL_mmeaudio.c	Mon Feb 06 17:28:04 2006 +0000
    32.2 +++ b/src/audio/mme/SDL_mmeaudio.c	Tue Feb 07 06:59:48 2006 +0000
    32.3 @@ -43,10 +43,10 @@
    32.4  {
    32.5      if ( device ) {
    32.6  	if ( device->hidden ) {
    32.7 -	    free(device->hidden);
    32.8 +	    SDL_free(device->hidden);
    32.9  	    device->hidden = NULL;
   32.10  	}
   32.11 -	free(device);
   32.12 +	SDL_free(device);
   32.13  	device = NULL;
   32.14      }
   32.15  }
   32.16 @@ -56,19 +56,19 @@
   32.17      SDL_AudioDevice *this;
   32.18  
   32.19  /* Initialize all variables that we clean on shutdown */
   32.20 -    this = malloc(sizeof(SDL_AudioDevice));
   32.21 +    this = SDL_malloc(sizeof(SDL_AudioDevice));
   32.22      if ( this ) {
   32.23 -	memset(this, 0, (sizeof *this));
   32.24 -	this->hidden = malloc((sizeof *this->hidden));
   32.25 +	SDL_memset(this, 0, (sizeof *this));
   32.26 +	this->hidden = SDL_malloc((sizeof *this->hidden));
   32.27      }
   32.28      if ( (this == NULL) || (this->hidden == NULL) ) {
   32.29  	SDL_OutOfMemory();
   32.30  	if ( this ) {
   32.31 -	    free(this);
   32.32 +	    SDL_free(this);
   32.33  	}
   32.34  	return(0);
   32.35      }
   32.36 -    memset(this->hidden, 0, (sizeof *this->hidden));
   32.37 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   32.38      /* Set the function pointers */
   32.39      this->OpenAudio       =       MME_OpenAudio;
   32.40      this->WaitAudio       =       MME_WaitAudio;
   32.41 @@ -92,7 +92,7 @@
   32.42      char errbuf[MAXERRORLENGTH];
   32.43  
   32.44      sprintf(errbuf, "%s: ", function);
   32.45 -    len = strlen(errbuf);
   32.46 +    len = SDL_strlen(errbuf);
   32.47      waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len);
   32.48      SDL_SetError("%s",errbuf);
   32.49  }
    33.1 --- a/src/audio/nas/SDL_nasaudio.c	Mon Feb 06 17:28:04 2006 +0000
    33.2 +++ b/src/audio/nas/SDL_nasaudio.c	Tue Feb 07 06:59:48 2006 +0000
    33.3 @@ -66,8 +66,8 @@
    33.4  
    33.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    33.6  {
    33.7 -	free(device->hidden);
    33.8 -	free(device);
    33.9 +	SDL_free(device->hidden);
   33.10 +	SDL_free(device);
   33.11  }
   33.12  
   33.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   33.14 @@ -75,20 +75,20 @@
   33.15  	SDL_AudioDevice *this;
   33.16  
   33.17  	/* Initialize all variables that we clean on shutdown */
   33.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   33.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   33.20  	if ( this ) {
   33.21 -		memset(this, 0, (sizeof *this));
   33.22 +		SDL_memset(this, 0, (sizeof *this));
   33.23  		this->hidden = (struct SDL_PrivateAudioData *)
   33.24 -				malloc((sizeof *this->hidden));
   33.25 +				SDL_malloc((sizeof *this->hidden));
   33.26  	}
   33.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   33.28  		SDL_OutOfMemory();
   33.29  		if ( this ) {
   33.30 -			free(this);
   33.31 +			SDL_free(this);
   33.32  		}
   33.33  		return(0);
   33.34  	}
   33.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   33.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   33.37  
   33.38  	/* Set the function pointers */
   33.39  	this->OpenAudio = NAS_OpenAudio;
   33.40 @@ -293,7 +293,7 @@
   33.41  	if ( this->hidden->mixbuf == NULL ) {
   33.42  		return(-1);
   33.43  	}
   33.44 -	memset(this->hidden->mixbuf, spec->silence, spec->size);
   33.45 +	SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
   33.46  
   33.47  	/* Get the parent process id (we're the parent of the audio thread) */
   33.48  	this->hidden->parent = getpid();
    34.1 --- a/src/audio/nto/SDL_nto_audio.c	Mon Feb 06 17:28:04 2006 +0000
    34.2 +++ b/src/audio/nto/SDL_nto_audio.c	Tue Feb 07 06:59:48 2006 +0000
    34.3 @@ -94,7 +94,7 @@
    34.4  
    34.5      for (it=0; it<QSA_WA_CARDS; it++)
    34.6      {
    34.7 -       if (strcmp(buggycards[it].cardname, scardname)==0)
    34.8 +       if (SDL_strcmp(buggycards[it].cardname, scardname)==0)
    34.9         {
   34.10            if (buggycards[it].bugtype==checkfor)
   34.11            {
   34.12 @@ -120,7 +120,7 @@
   34.13  /* PCM transfer channel parameters initialize function */
   34.14  static void NTO_InitAudioParams(snd_pcm_channel_params_t* cpars)
   34.15  {
   34.16 -    memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
   34.17 +    SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
   34.18  
   34.19      cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
   34.20      cpars->mode = SND_PCM_MODE_BLOCK;
   34.21 @@ -172,11 +172,11 @@
   34.22  {
   34.23      if ((device)&&(device->hidden))
   34.24      {
   34.25 -        free(device->hidden);
   34.26 +        SDL_free(device->hidden);
   34.27      }
   34.28      if (device)
   34.29      {
   34.30 -        free(device);
   34.31 +        SDL_free(device);
   34.32      }
   34.33  }
   34.34  
   34.35 @@ -185,22 +185,22 @@
   34.36      SDL_AudioDevice *this;
   34.37  
   34.38      /* Initialize all variables that we clean on shutdown */
   34.39 -    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   34.40 +    this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   34.41      if (this)
   34.42      {
   34.43 -        memset(this, 0, sizeof(SDL_AudioDevice));
   34.44 -        this->hidden = (struct SDL_PrivateAudioData *)malloc(sizeof(struct SDL_PrivateAudioData));
   34.45 +        SDL_memset(this, 0, sizeof(SDL_AudioDevice));
   34.46 +        this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(struct SDL_PrivateAudioData));
   34.47      }
   34.48      if ((this == NULL) || (this->hidden == NULL))
   34.49      {
   34.50          SDL_OutOfMemory();
   34.51          if (this)
   34.52          {
   34.53 -            free(this);
   34.54 +            SDL_free(this);
   34.55  	}
   34.56          return (0);
   34.57      }
   34.58 -    memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
   34.59 +    SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
   34.60      audio_handle = NULL;
   34.61  
   34.62      /* Set the function pointers */
   34.63 @@ -280,7 +280,7 @@
   34.64              {
   34.65                  if ((errno == EINVAL) || (errno == EIO))
   34.66                  {
   34.67 -                    memset(&cstatus, 0, sizeof(cstatus));
   34.68 +                    SDL_memset(&cstatus, 0, sizeof(cstatus));
   34.69                      cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
   34.70                      if ((rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0)
   34.71                      {
   34.72 @@ -455,7 +455,7 @@
   34.73      }
   34.74  
   34.75      /* Make sure channel is setup right one last time */
   34.76 -    memset(&csetup, 0x00, sizeof(csetup));
   34.77 +    SDL_memset(&csetup, 0x00, sizeof(csetup));
   34.78      csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
   34.79      if (snd_pcm_plugin_setup(audio_handle, &csetup) < 0)
   34.80      {
   34.81 @@ -483,7 +483,7 @@
   34.82          SDL_SetError("NTO_OpenAudio(): pcm buffer allocation failed\n");
   34.83          return (-1);
   34.84      }
   34.85 -    memset(pcm_buf, spec->silence, pcm_len);
   34.86 +    SDL_memset(pcm_buf, spec->silence, pcm_len);
   34.87  
   34.88      /* get the file descriptor */
   34.89      if ((audio_fd = snd_pcm_file_descriptor(audio_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0)
    35.1 --- a/src/audio/openbsd/SDL_openbsdaudio.c	Mon Feb 06 17:28:04 2006 +0000
    35.2 +++ b/src/audio/openbsd/SDL_openbsdaudio.c	Tue Feb 07 06:59:48 2006 +0000
    35.3 @@ -95,8 +95,8 @@
    35.4  static void
    35.5  Audio_DeleteDevice(SDL_AudioDevice *device)
    35.6  {
    35.7 -    free(device->hidden);
    35.8 -    free(device);
    35.9 +    SDL_free(device->hidden);
   35.10 +    SDL_free(device);
   35.11  }
   35.12  
   35.13  static SDL_AudioDevice
   35.14 @@ -105,18 +105,18 @@
   35.15      SDL_AudioDevice *this;
   35.16  
   35.17      /* Initialize all variables that we clean on shutdown */
   35.18 -    this = (SDL_AudioDevice*)malloc(sizeof(SDL_AudioDevice));
   35.19 +    this = (SDL_AudioDevice*)SDL_malloc(sizeof(SDL_AudioDevice));
   35.20      if(this) {
   35.21 -	memset(this, 0, (sizeof *this));
   35.22 +	SDL_memset(this, 0, (sizeof *this));
   35.23  	this->hidden =
   35.24 -	    (struct SDL_PrivateAudioData*)malloc((sizeof *this->hidden));
   35.25 +	    (struct SDL_PrivateAudioData*)SDL_malloc((sizeof *this->hidden));
   35.26      }
   35.27      if((this == NULL) || (this->hidden == NULL)) {
   35.28  	SDL_OutOfMemory();
   35.29 -	if(this) free(this);
   35.30 +	if(this) SDL_free(this);
   35.31  	return(0);
   35.32      }
   35.33 -    memset(this->hidden, 0, (sizeof *this->hidden));
   35.34 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   35.35      audio_fd = -1;
   35.36  
   35.37      /* Set the function pointers */
   35.38 @@ -397,7 +397,7 @@
   35.39      if(mixbuf == NULL) {
   35.40  	return(-1);
   35.41      }
   35.42 -    memset(mixbuf, spec->silence, spec->size);
   35.43 +    SDL_memset(mixbuf, spec->silence, spec->size);
   35.44      
   35.45      /* Get the parent process id (we're the parent of the audio thread) */
   35.46      parent = getpid();
    36.1 --- a/src/audio/paudio/SDL_paudio.c	Mon Feb 06 17:28:04 2006 +0000
    36.2 +++ b/src/audio/paudio/SDL_paudio.c	Tue Feb 07 06:59:48 2006 +0000
    36.3 @@ -82,8 +82,8 @@
    36.4  
    36.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    36.6  {
    36.7 -	free(device->hidden);
    36.8 -	free(device);
    36.9 +	SDL_free(device->hidden);
   36.10 +	SDL_free(device);
   36.11  }
   36.12  
   36.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   36.14 @@ -91,20 +91,20 @@
   36.15  	SDL_AudioDevice *this;
   36.16  
   36.17  	/* Initialize all variables that we clean on shutdown */
   36.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   36.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   36.20  	if ( this ) {
   36.21 -		memset(this, 0, (sizeof *this));
   36.22 +		SDL_memset(this, 0, (sizeof *this));
   36.23  		this->hidden = (struct SDL_PrivateAudioData *)
   36.24 -				malloc((sizeof *this->hidden));
   36.25 +				SDL_malloc((sizeof *this->hidden));
   36.26  	}
   36.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   36.28  		SDL_OutOfMemory();
   36.29  		if ( this ) {
   36.30 -			free(this);
   36.31 +			SDL_free(this);
   36.32  		}
   36.33  		return(0);
   36.34  	}
   36.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   36.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   36.37  	audio_fd = -1;
   36.38  
   36.39  	/* Set the function pointers */
   36.40 @@ -457,7 +457,7 @@
   36.41  	if ( mixbuf == NULL ) {
   36.42  		return -1;
   36.43  	}
   36.44 -	memset(mixbuf, spec->silence, spec->size);
   36.45 +	SDL_memset(mixbuf, spec->silence, spec->size);
   36.46  
   36.47  	/*
   36.48  	 * Set some paramters: full volume, first speaker that we can find.
   36.49 @@ -498,7 +498,7 @@
   36.50  
   36.51          /* Check to see if we need to use select() workaround */
   36.52          { char *workaround;
   36.53 -                workaround = getenv("SDL_DSP_NOSELECT");
   36.54 +                workaround = SDL_getenv("SDL_DSP_NOSELECT");
   36.55                  if ( workaround ) {
   36.56                          frame_ticks = (float)(spec->samples*1000)/spec->freq;
   36.57                          next_frame = SDL_GetTicks()+frame_ticks;
    37.1 --- a/src/audio/sun/SDL_sunaudio.c	Mon Feb 06 17:28:04 2006 +0000
    37.2 +++ b/src/audio/sun/SDL_sunaudio.c	Tue Feb 07 06:59:48 2006 +0000
    37.3 @@ -75,8 +75,8 @@
    37.4  
    37.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    37.6  {
    37.7 -	free(device->hidden);
    37.8 -	free(device);
    37.9 +	SDL_free(device->hidden);
   37.10 +	SDL_free(device);
   37.11  }
   37.12  
   37.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   37.14 @@ -84,20 +84,20 @@
   37.15  	SDL_AudioDevice *this;
   37.16  
   37.17  	/* Initialize all variables that we clean on shutdown */
   37.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   37.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   37.20  	if ( this ) {
   37.21 -		memset(this, 0, (sizeof *this));
   37.22 +		SDL_memset(this, 0, (sizeof *this));
   37.23  		this->hidden = (struct SDL_PrivateAudioData *)
   37.24 -				malloc((sizeof *this->hidden));
   37.25 +				SDL_malloc((sizeof *this->hidden));
   37.26  	}
   37.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   37.28  		SDL_OutOfMemory();
   37.29  		if ( this ) {
   37.30 -			free(this);
   37.31 +			SDL_free(this);
   37.32  		}
   37.33  		return(0);
   37.34  	}
   37.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   37.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   37.37  	audio_fd = -1;
   37.38  
   37.39  	/* Set the function pointers */
   37.40 @@ -236,7 +236,7 @@
   37.41  		mixbuf = NULL;
   37.42  	}
   37.43  	if ( ulaw_buf != NULL ) {
   37.44 -		free(ulaw_buf);
   37.45 +		SDL_free(ulaw_buf);
   37.46  		ulaw_buf = NULL;
   37.47  	}
   37.48  	close(audio_fd);
   37.49 @@ -349,7 +349,7 @@
   37.50  	        spec->freq = desired_freq;
   37.51  		fragsize = (spec->samples*1000)/(spec->freq/8);
   37.52  		frequency = 8;
   37.53 -		ulaw_buf = (Uint8 *)malloc(fragsize);
   37.54 +		ulaw_buf = (Uint8 *)SDL_malloc(fragsize);
   37.55  		if ( ulaw_buf == NULL ) {
   37.56  			SDL_OutOfMemory();
   37.57  			return(-1);
   37.58 @@ -375,7 +375,7 @@
   37.59  		SDL_OutOfMemory();
   37.60  		return(-1);
   37.61  	}
   37.62 -	memset(mixbuf, spec->silence, spec->size);
   37.63 +	SDL_memset(mixbuf, spec->silence, spec->size);
   37.64  
   37.65  	/* We're ready to rock and roll. :-) */
   37.66  	return(0);
    38.1 --- a/src/audio/ums/SDL_umsaudio.c	Mon Feb 06 17:28:04 2006 +0000
    38.2 +++ b/src/audio/ums/SDL_umsaudio.c	Tue Feb 07 06:59:48 2006 +0000
    38.3 @@ -84,11 +84,11 @@
    38.4  
    38.5  static void Audio_DeleteDevice(_THIS)
    38.6  {
    38.7 -    if(this->hidden->playbuf._buffer) free(this->hidden->playbuf._buffer);
    38.8 -    if(this->hidden->fillbuf._buffer) free(this->hidden->fillbuf._buffer);
    38.9 +    if(this->hidden->playbuf._buffer) SDL_free(this->hidden->playbuf._buffer);
   38.10 +    if(this->hidden->fillbuf._buffer) SDL_free(this->hidden->fillbuf._buffer);
   38.11      _somFree( this->hidden->umsdev );
   38.12 -    free(this->hidden);
   38.13 -    free(this);
   38.14 +    SDL_free(this->hidden);
   38.15 +    SDL_free(this);
   38.16  }
   38.17  
   38.18  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   38.19 @@ -99,19 +99,19 @@
   38.20       * Allocate and initialize management storage and private management
   38.21       * storage for this SDL-using library.
   38.22       */
   38.23 -    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   38.24 +    this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   38.25      if ( this ) {
   38.26 -        memset(this, 0, (sizeof *this));
   38.27 -        this->hidden = (struct SDL_PrivateAudioData *)malloc((sizeof *this->hidden));
   38.28 +        SDL_memset(this, 0, (sizeof *this));
   38.29 +        this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc((sizeof *this->hidden));
   38.30      }
   38.31      if ( (this == NULL) || (this->hidden == NULL) ) {
   38.32          SDL_OutOfMemory();
   38.33          if ( this ) {
   38.34 -            free(this);
   38.35 +            SDL_free(this);
   38.36          }
   38.37          return(0);
   38.38      }
   38.39 -    memset(this->hidden, 0, (sizeof *this->hidden));
   38.40 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   38.41  #ifdef DEBUG_AUDIO
   38.42      fprintf(stderr, "Creating UMS Audio device\n");
   38.43  #endif
   38.44 @@ -204,9 +204,9 @@
   38.45      while(samplesToWrite>0);
   38.46  
   38.47      SDL_LockAudio();
   38.48 -    memcpy( &swpbuf,                &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer) );
   38.49 -    memcpy( &this->hidden->playbuf, &this->hidden->fillbuf, sizeof(UMSAudioTypes_Buffer) );
   38.50 -    memcpy( &this->hidden->fillbuf, &swpbuf,                sizeof(UMSAudioTypes_Buffer) );
   38.51 +    SDL_memcpy( &swpbuf,                &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer) );
   38.52 +    SDL_memcpy( &this->hidden->playbuf, &this->hidden->fillbuf, sizeof(UMSAudioTypes_Buffer) );
   38.53 +    SDL_memcpy( &this->hidden->fillbuf, &swpbuf,                sizeof(UMSAudioTypes_Buffer) );
   38.54      SDL_UnlockAudio();
   38.55  
   38.56  #ifdef DEBUG_AUDIO
   38.57 @@ -330,10 +330,10 @@
   38.58  
   38.59      this->hidden->playbuf._length  = 0;
   38.60      this->hidden->playbuf._maximum = spec->size;
   38.61 -    this->hidden->playbuf._buffer  = (unsigned char*)malloc(spec->size);
   38.62 +    this->hidden->playbuf._buffer  = (unsigned char*)SDL_malloc(spec->size);
   38.63      this->hidden->fillbuf._length  = 0;
   38.64      this->hidden->fillbuf._maximum = spec->size;
   38.65 -    this->hidden->fillbuf._buffer  = (unsigned char*)malloc(spec->size);
   38.66 +    this->hidden->fillbuf._buffer  = (unsigned char*)SDL_malloc(spec->size);
   38.67  
   38.68      rc = UADSetBitsPerSample(this,  bitsPerSample );
   38.69      rc = UADSetDMABufferSize(this,  frag_spec, &outBufSize );
    39.1 --- a/src/audio/windib/SDL_dibaudio.c	Mon Feb 06 17:28:04 2006 +0000
    39.2 +++ b/src/audio/windib/SDL_dibaudio.c	Tue Feb 07 06:59:48 2006 +0000
    39.3 @@ -55,8 +55,8 @@
    39.4  
    39.5  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    39.6  {
    39.7 -	free(device->hidden);
    39.8 -	free(device);
    39.9 +	SDL_free(device->hidden);
   39.10 +	SDL_free(device);
   39.11  }
   39.12  
   39.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   39.14 @@ -64,20 +64,20 @@
   39.15  	SDL_AudioDevice *this;
   39.16  
   39.17  	/* Initialize all variables that we clean on shutdown */
   39.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   39.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   39.20  	if ( this ) {
   39.21 -		memset(this, 0, (sizeof *this));
   39.22 +		SDL_memset(this, 0, (sizeof *this));
   39.23  		this->hidden = (struct SDL_PrivateAudioData *)
   39.24 -				malloc((sizeof *this->hidden));
   39.25 +				SDL_malloc((sizeof *this->hidden));
   39.26  	}
   39.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   39.28  		SDL_OutOfMemory();
   39.29  		if ( this ) {
   39.30 -			free(this);
   39.31 +			SDL_free(this);
   39.32  		}
   39.33  		return(0);
   39.34  	}
   39.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   39.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   39.37  
   39.38  	/* Set the function pointers */
   39.39  	this->OpenAudio = DIB_OpenAudio;
   39.40 @@ -125,8 +125,8 @@
   39.41  	wchar_t werrbuf[MAXERRORLENGTH];
   39.42  #endif
   39.43  
   39.44 -	snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
   39.45 -	len = strlen(errbuf);
   39.46 +	SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
   39.47 +	len = SDL_strlen(errbuf);
   39.48  
   39.49  #ifdef _WIN32_WCE
   39.50  	/* UNICODE version */
   39.51 @@ -213,7 +213,7 @@
   39.52  	}
   39.53  	/* Free raw mixing buffer */
   39.54  	if ( mixbuf != NULL ) {
   39.55 -		free(mixbuf);
   39.56 +		SDL_free(mixbuf);
   39.57  		mixbuf = NULL;
   39.58  	}
   39.59  }
   39.60 @@ -232,7 +232,7 @@
   39.61  	mixbuf = NULL;
   39.62  
   39.63  	/* Set basic WAVE format parameters */
   39.64 -	memset(&waveformat, 0, sizeof(waveformat));
   39.65 +	SDL_memset(&waveformat, 0, sizeof(waveformat));
   39.66  	waveformat.wFormatTag = WAVE_FORMAT_PCM;
   39.67  
   39.68  	/* Determine the audio parameters from the AudioSpec */
   39.69 @@ -299,13 +299,13 @@
   39.70  	}
   39.71  
   39.72  	/* Create the sound buffers */
   39.73 -	mixbuf = (Uint8 *)malloc(NUM_BUFFERS*spec->size);
   39.74 +	mixbuf = (Uint8 *)SDL_malloc(NUM_BUFFERS*spec->size);
   39.75  	if ( mixbuf == NULL ) {
   39.76  		SDL_SetError("Out of memory");
   39.77  		return(-1);
   39.78  	}
   39.79  	for ( i = 0; i < NUM_BUFFERS; ++i ) {
   39.80 -		memset(&wavebuf[i], 0, sizeof(wavebuf[i]));
   39.81 +		SDL_memset(&wavebuf[i], 0, sizeof(wavebuf[i]));
   39.82  		wavebuf[i].lpData = (LPSTR) &mixbuf[i*spec->size];
   39.83  		wavebuf[i].dwBufferLength = spec->size;
   39.84  		wavebuf[i].dwFlags = WHDR_DONE;
    40.1 --- a/src/audio/windx5/SDL_dx5audio.c	Mon Feb 06 17:28:04 2006 +0000
    40.2 +++ b/src/audio/windx5/SDL_dx5audio.c	Tue Feb 07 06:59:48 2006 +0000
    40.3 @@ -133,8 +133,8 @@
    40.4  static void Audio_DeleteDevice(SDL_AudioDevice *device)
    40.5  {
    40.6  	DX5_Unload();
    40.7 -	free(device->hidden);
    40.8 -	free(device);
    40.9 +	SDL_free(device->hidden);
   40.10 +	SDL_free(device);
   40.11  }
   40.12  
   40.13  static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   40.14 @@ -147,20 +147,20 @@
   40.15  	}
   40.16  
   40.17  	/* Initialize all variables that we clean on shutdown */
   40.18 -	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   40.19 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   40.20  	if ( this ) {
   40.21 -		memset(this, 0, (sizeof *this));
   40.22 +		SDL_memset(this, 0, (sizeof *this));
   40.23  		this->hidden = (struct SDL_PrivateAudioData *)
   40.24 -				malloc((sizeof *this->hidden));
   40.25 +				SDL_malloc((sizeof *this->hidden));
   40.26  	}
   40.27  	if ( (this == NULL) || (this->hidden == NULL) ) {
   40.28  		SDL_OutOfMemory();
   40.29  		if ( this ) {
   40.30 -			free(this);
   40.31 +			SDL_free(this);
   40.32  		}
   40.33  		return(0);
   40.34  	}
   40.35 -	memset(this->hidden, 0, (sizeof *this->hidden));
   40.36 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   40.37  
   40.38  	/* Set the function pointers */
   40.39  	this->OpenAudio = DX5_OpenAudio;
   40.40 @@ -223,13 +223,13 @@
   40.41  			error = "Function not supported";
   40.42  			break;
   40.43  		default:
   40.44 -			snprintf(errbuf, SDL_arraysize(errbuf),
   40.45 +			SDL_snprintf(errbuf, SDL_arraysize(errbuf),
   40.46  			         "%s: Unknown DirectSound error: 0x%x",
   40.47  								function, code);
   40.48  			break;
   40.49  	}
   40.50  	if ( ! errbuf[0] ) {
   40.51 -		snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
   40.52 +		SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
   40.53  	}
   40.54  	SDL_SetError("%s", errbuf);
   40.55  	return;
   40.56 @@ -386,7 +386,7 @@
   40.57  	/* Wait for the playing chunk to finish */
   40.58  	stream = this->GetAudioBuf(this);
   40.59  	if ( stream != NULL ) {
   40.60 -		memset(stream, silence, mixlen);
   40.61 +		SDL_memset(stream, silence, mixlen);
   40.62  		this->PlayAudio(this);
   40.63  	}
   40.64  	this->WaitAudio(this);
   40.65 @@ -435,7 +435,7 @@
   40.66  	}
   40.67  
   40.68  	/* Try to create the primary buffer */
   40.69 -	memset(&format, 0, sizeof(format));
   40.70 +	SDL_memset(&format, 0, sizeof(format));
   40.71  	format.dwSize = sizeof(format);
   40.72  	format.dwFlags=(DSBCAPS_PRIMARYBUFFER|DSBCAPS_GETCURRENTPOSITION2);
   40.73  	format.dwFlags |= DSBCAPS_STICKYFOCUS;
   40.74 @@ -451,7 +451,7 @@
   40.75  	}
   40.76  
   40.77  	/* Check the size of the fragment buffer */
   40.78 -	memset(&caps, 0, sizeof(caps));
   40.79 +	SDL_memset(&caps, 0, sizeof(caps));
   40.80  	caps.dwSize = sizeof(caps);
   40.81  	result = IDirectSoundBuffer_GetCaps(*sndbuf, &caps);
   40.82  	if ( result != DS_OK ) {
   40.83 @@ -516,7 +516,7 @@
   40.84  	}
   40.85  
   40.86  	/* Try to create the secondary buffer */
   40.87 -	memset(&format, 0, sizeof(format));
   40.88 +	SDL_memset(&format, 0, sizeof(format));
   40.89  	format.dwSize = sizeof(format);
   40.90  	format.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
   40.91  #ifdef USE_POSITION_NOTIFY
   40.92 @@ -550,9 +550,9 @@
   40.93  	                                 DSBLOCK_ENTIREBUFFER);
   40.94  	if ( result == DS_OK ) {
   40.95  		if ( wavefmt->wBitsPerSample == 8 ) {
   40.96 -			memset(pvAudioPtr1, 0x80, dwAudioBytes1);
   40.97 +			SDL_memset(pvAudioPtr1, 0x80, dwAudioBytes1);
   40.98  		} else {
   40.99 -			memset(pvAudioPtr1, 0x00, dwAudioBytes1);
  40.100 +			SDL_memset(pvAudioPtr1, 0x00, dwAudioBytes1);
  40.101  		}
  40.102  		IDirectSoundBuffer_Unlock(*sndbuf,
  40.103  		                          (LPVOID)pvAudioPtr1, dwAudioBytes1,
  40.104 @@ -584,7 +584,7 @@
  40.105  	}
  40.106  
  40.107  	/* Allocate the notify structures */
  40.108 -	notify_positions = (DSBPOSITIONNOTIFY *)malloc(NUM_BUFFERS*
  40.109 +	notify_positions = (DSBPOSITIONNOTIFY *)SDL_malloc(NUM_BUFFERS*
  40.110  					sizeof(*notify_positions));
  40.111  	if ( notify_positions == NULL ) {
  40.112  		goto done;
  40.113 @@ -620,7 +620,7 @@
  40.114  	WAVEFORMATEX waveformat;
  40.115  
  40.116  	/* Set basic WAVE format parameters */
  40.117 -	memset(&waveformat, 0, sizeof(waveformat));
  40.118 +	SDL_memset(&waveformat, 0, sizeof(waveformat));
  40.119  	waveformat.wFormatTag = WAVE_FORMAT_PCM;
  40.120  
  40.121  	/* Determine the audio parameters from the AudioSpec */
    41.1 --- a/src/cdrom/SDL_cdrom.c	Mon Feb 06 17:28:04 2006 +0000
    41.2 +++ b/src/cdrom/SDL_cdrom.c	Tue Feb 07 06:59:48 2006 +0000
    41.3 @@ -117,15 +117,15 @@
    41.4  		SDL_SetError("Invalid CD-ROM drive index");
    41.5  		return(NULL);
    41.6  	}
    41.7 -	cdrom = (SDL_CD *)malloc(sizeof(*cdrom));
    41.8 +	cdrom = (SDL_CD *)SDL_malloc(sizeof(*cdrom));
    41.9  	if ( cdrom == NULL ) {
   41.10  		SDL_OutOfMemory();
   41.11  		return(NULL);
   41.12  	}
   41.13 -	memset(cdrom, 0, sizeof(*cdrom));
   41.14 +	SDL_memset(cdrom, 0, sizeof(*cdrom));
   41.15  	cdrom->id = SDL_CDcaps.Open(drive);
   41.16  	if ( cdrom->id < 0 ) {
   41.17 -		free(cdrom);
   41.18 +		SDL_free(cdrom);
   41.19  		return(NULL);
   41.20  	}
   41.21  	default_cdrom = cdrom;
   41.22 @@ -332,7 +332,7 @@
   41.23  		return;
   41.24  	}
   41.25  	SDL_CDcaps.Close(cdrom);
   41.26 -	free(cdrom);
   41.27 +	SDL_free(cdrom);
   41.28  	default_cdrom = NULL;
   41.29  }
   41.30  
    42.1 --- a/src/cdrom/SDL_syscdrom.h	Mon Feb 06 17:28:04 2006 +0000
    42.2 +++ b/src/cdrom/SDL_syscdrom.h	Tue Feb 07 06:59:48 2006 +0000
    42.3 @@ -2,7 +2,7 @@
    42.4      SDL - Simple DirectMedia Layer
    42.5      Copyright (C) 1997-2006 Sam Lantinga
    42.6  
    42.7 -    This library is free software; you can redistribute it and/or
    42.8 +    This library is SDL_free software; you can redistribute it and/or
    42.9      modify it under the terms of the GNU Lesser General Public
   42.10      License as published by the Free Software Foundation; either
   42.11      version 2.1 of the License, or (at your option) any later version.
    43.1 --- a/src/cdrom/aix/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    43.2 +++ b/src/cdrom/aix/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    43.3 @@ -128,12 +128,12 @@
    43.4  
    43.5  		/* Add this drive to our list */
    43.6  		i = SDL_numcds;
    43.7 -		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    43.8 +		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    43.9  		if ( SDL_cdlist[i] == NULL ) {
   43.10  			SDL_OutOfMemory();
   43.11  			return;
   43.12  		}
   43.13 -		strcpy(SDL_cdlist[i], drive);
   43.14 +		SDL_strcpy(SDL_cdlist[i], drive);
   43.15  		SDL_cdmode[i] = stbuf->st_rdev;
   43.16  		++SDL_numcds;
   43.17  #ifdef DEBUG_CDROM
   43.18 @@ -149,7 +149,7 @@
   43.19      struct vmount* ptr;
   43.20      int            ret;
   43.21  
   43.22 -    buffer = (char*)malloc(10);
   43.23 +    buffer = (char*)SDL_malloc(10);
   43.24      bufsz  = 10;
   43.25      if ( buffer==NULL )
   43.26      {
   43.27 @@ -167,8 +167,8 @@
   43.28              bufsz = *(int*)buffer; /* Required size is in first word.   */
   43.29  				   /* (whatever a word is in AIX 4.3.3) */
   43.30  				   /* int seems to be OK in 32bit mode. */
   43.31 -            free(buffer);
   43.32 -            buffer = (char*)malloc(bufsz);
   43.33 +            SDL_free(buffer);
   43.34 +            buffer = (char*)SDL_malloc(bufsz);
   43.35              if ( buffer==NULL )
   43.36              {
   43.37                  fprintf(stderr,
   43.38 @@ -237,9 +237,9 @@
   43.39      {
   43.40          ret = getfsent_r ( &entry, &fsFile, &passNo );
   43.41          if ( ret == 0 ) {
   43.42 -            char* l = strrchr(entry.fs_spec,'/');
   43.43 +            char* l = SDL_strrchr(entry.fs_spec,'/');
   43.44              if ( l != NULL ) {
   43.45 -                if ( !strncmp("cd",++l,2) ) {
   43.46 +                if ( !SDL_strncmp("cd",++l,2) ) {
   43.47  #ifdef DEBUG_CDROM
   43.48                      fprintf(stderr,
   43.49  			    "Found unmounted CD ROM drive with device name %s\n",
   43.50 @@ -266,9 +266,9 @@
   43.51      {
   43.52          entry = getfsent();
   43.53          if ( entry != NULL ) {
   43.54 -            char* l = strrchr(entry->fs_spec,'/');
   43.55 +            char* l = SDL_strrchr(entry->fs_spec,'/');
   43.56              if ( l != NULL ) {
   43.57 -                if ( !strncmp("cd",++l,2) ) {
   43.58 +                if ( !SDL_strncmp("cd",++l,2) ) {
   43.59  #ifdef DEBUG_CDROM
   43.60                      fprintf(stderr,"Found unmounted CD ROM drive with device name %s", entry->fs_spec);
   43.61  #endif
   43.62 @@ -303,15 +303,15 @@
   43.63  	SDL_CDcaps.Close = SDL_SYS_CDClose;
   43.64  
   43.65  	/* Look in the environment for our CD-ROM drive list */
   43.66 -	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
   43.67 +	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   43.68  	if ( SDLcdrom != NULL ) {
   43.69  		char *cdpath, *delim;
   43.70 -		cdpath = malloc(strlen(SDLcdrom)+1);
   43.71 +		cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
   43.72  		if ( cdpath != NULL ) {
   43.73 -			strcpy(cdpath, SDLcdrom);
   43.74 +			SDL_strcpy(cdpath, SDLcdrom);
   43.75  			SDLcdrom = cdpath;
   43.76  			do {
   43.77 -				delim = strchr(SDLcdrom, ':');
   43.78 +				delim = SDL_strchr(SDLcdrom, ':');
   43.79  				if ( delim ) {
   43.80  					*delim++ = '\0';
   43.81  				}
   43.82 @@ -327,7 +327,7 @@
   43.83  					SDLcdrom = NULL;
   43.84  				}
   43.85  			} while ( SDLcdrom );
   43.86 -			free(cdpath);
   43.87 +			SDL_free(cdpath);
   43.88  		}
   43.89  
   43.90  		/* If we found our drives, there's nothing left to do */
   43.91 @@ -369,13 +369,13 @@
   43.92       * We found /dev/cd? drives and that is in our list. But we can
   43.93       * open only the /dev/rcd? versions of those devices for Audio CD.
   43.94       */
   43.95 -    cdromname = (char*)malloc( strlen(SDL_cdlist[drive]+2) );
   43.96 -    strcpy(cdromname,SDL_cdlist[drive]);
   43.97 -    lastsl = strrchr(cdromname,'/');
   43.98 +    cdromname = (char*)SDL_malloc( SDL_strlen(SDL_cdlist[drive]+2) );
   43.99 +    SDL_strcpy(cdromname,SDL_cdlist[drive]);
  43.100 +    lastsl = SDL_strrchr(cdromname,'/');
  43.101      if (lastsl) {
  43.102  	*lastsl = 0;
  43.103  	strcat(cdromname,"/r");
  43.104 -	lastsl = strrchr(SDL_cdlist[drive],'/');
  43.105 +	lastsl = SDL_strrchr(SDL_cdlist[drive],'/');
  43.106  	if (lastsl) {
  43.107  	    lastsl++;
  43.108  	    strcat(cdromname,lastsl);
  43.109 @@ -459,7 +459,7 @@
  43.110  #endif
  43.111  	}
  43.112      }
  43.113 -    free(cdromname);
  43.114 +    SDL_free(cdromname);
  43.115      return fd;
  43.116  }
  43.117  
  43.118 @@ -650,7 +650,7 @@
  43.119  
  43.120  	if ( SDL_numcds > 0 ) {
  43.121  		for ( i=0; i<SDL_numcds; ++i ) {
  43.122 -			free(SDL_cdlist[i]);
  43.123 +			SDL_free(SDL_cdlist[i]);
  43.124  		}
  43.125  		SDL_numcds = 0;
  43.126  	}
    44.1 --- a/src/cdrom/beos/SDL_syscdrom.cc	Mon Feb 06 17:28:04 2006 +0000
    44.2 +++ b/src/cdrom/beos/SDL_syscdrom.cc	Tue Feb 07 06:59:48 2006 +0000
    44.3 @@ -116,12 +116,12 @@
    44.4  	if ( SDL_numcds < MAX_DRIVES ) {
    44.5  		/* Add this drive to our list */
    44.6  		i = SDL_numcds;
    44.7 -		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    44.8 +		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    44.9  		if ( SDL_cdlist[i] == NULL ) {
   44.10  			SDL_OutOfMemory();
   44.11  			return;
   44.12  		}
   44.13 -		strcpy(SDL_cdlist[i], drive);
   44.14 +		SDL_strcpy(SDL_cdlist[i], drive);
   44.15  		++SDL_numcds;
   44.16  #ifdef CDROM_DEBUG
   44.17    fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
   44.18 @@ -165,15 +165,15 @@
   44.19  	SDL_CDcaps.Close = SDL_SYS_CDClose;
   44.20  
   44.21  	/* Look in the environment for our CD-ROM drive list */
   44.22 -	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
   44.23 +	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   44.24  	if ( SDLcdrom != NULL ) {
   44.25  		char *cdpath, *delim;
   44.26 -		cdpath = (char *)malloc(strlen(SDLcdrom)+1);
   44.27 +		cdpath = (char *)SDL_malloc(SDL_strlen(SDLcdrom)+1);
   44.28  		if ( cdpath != NULL ) {
   44.29 -			strcpy(cdpath, SDLcdrom);
   44.30 +			SDL_strcpy(cdpath, SDLcdrom);
   44.31  			SDLcdrom = cdpath;
   44.32  			do {
   44.33 -				delim = strchr(SDLcdrom, ':');
   44.34 +				delim = SDL_strchr(SDLcdrom, ':');
   44.35  				if ( delim ) {
   44.36  					*delim++ = '\0';
   44.37  				}
   44.38 @@ -186,7 +186,7 @@
   44.39  					SDLcdrom = NULL;
   44.40  				}
   44.41  			} while ( SDLcdrom );
   44.42 -			free(cdpath);
   44.43 +			SDL_free(cdpath);
   44.44  		}
   44.45  
   44.46  		/* If we found our drives, there's nothing left to do */
   44.47 @@ -223,7 +223,7 @@
   44.48  			continue; 
   44.49  
   44.50  		if(entry.IsDirectory()) { 
   44.51 -			if(strcmp(e.name, "floppy") == 0) 
   44.52 +			if(SDL_strcmp(e.name, "floppy") == 0) 
   44.53  				continue; /* ignore floppy (it is not silent)  */
   44.54  			int devfd = try_dir(name);
   44.55  			if(devfd >= 0)
   44.56 @@ -233,7 +233,7 @@
   44.57  			int devfd; 
   44.58  			device_geometry g; 
   44.59  
   44.60 -			if(strcmp(e.name, "raw") != 0) 
   44.61 +			if(SDL_strcmp(e.name, "raw") != 0) 
   44.62  				continue; /* ignore partitions */
   44.63  
   44.64  			devfd = open(name, O_RDONLY); 
   44.65 @@ -401,7 +401,7 @@
   44.66  
   44.67  	if ( SDL_numcds > 0 ) {
   44.68  		for ( i=0; i<SDL_numcds; ++i ) {
   44.69 -			free(SDL_cdlist[i]);
   44.70 +			SDL_free(SDL_cdlist[i]);
   44.71  		}
   44.72  		SDL_numcds = 0;
   44.73  	}
    45.1 --- a/src/cdrom/bsdi/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    45.2 +++ b/src/cdrom/bsdi/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    45.3 @@ -229,12 +229,12 @@
    45.4  
    45.5  		/* Add this drive to our list */
    45.6  		i = SDL_numcds;
    45.7 -		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    45.8 +		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    45.9  		if ( SDL_cdlist[i] == NULL ) {
   45.10  			SDL_OutOfMemory();
   45.11  			return;
   45.12  		}
   45.13 -		strcpy(SDL_cdlist[i], drive);
   45.14 +		SDL_strcpy(SDL_cdlist[i], drive);
   45.15  		SDL_cdmode[i] = stbuf->st_rdev;
   45.16  		++SDL_numcds;
   45.17  #ifdef DEBUG_CDROM
   45.18 @@ -267,15 +267,15 @@
   45.19  	SDL_CDcaps.Close = SDL_SYS_CDClose;
   45.20  
   45.21  	/* Look in the environment for our CD-ROM drive list */
   45.22 -	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
   45.23 +	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   45.24  	if ( SDLcdrom != NULL ) {
   45.25  		char *cdpath, *delim;
   45.26 -		cdpath = malloc(strlen(SDLcdrom)+1);
   45.27 +		cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
   45.28  		if ( cdpath != NULL ) {
   45.29 -			strcpy(cdpath, SDLcdrom);
   45.30 +			SDL_strcpy(cdpath, SDLcdrom);
   45.31  			SDLcdrom = cdpath;
   45.32  			do {
   45.33 -				delim = strchr(SDLcdrom, ':');
   45.34 +				delim = SDL_strchr(SDLcdrom, ':');
   45.35  				if ( delim ) {
   45.36  					*delim++ = '\0';
   45.37  				}
   45.38 @@ -288,7 +288,7 @@
   45.39  					SDLcdrom = NULL;
   45.40  				}
   45.41  			} while ( SDLcdrom );
   45.42 -			free(cdpath);
   45.43 +			SDL_free(cdpath);
   45.44  		}
   45.45  
   45.46  		/* If we found our drives, there's nothing left to do */
   45.47 @@ -304,7 +304,7 @@
   45.48  			exists = 1;
   45.49  			for ( j=checklist[i][1]; exists; ++j ) {
   45.50  				sprintf(drive, "/dev/%sc", &checklist[i][3]);
   45.51 -				insert = strchr(drive, '?');
   45.52 +				insert = SDL_strchr(drive, '?');
   45.53  				if ( insert != NULL ) {
   45.54  					*insert = j;
   45.55  				}
   45.56 @@ -360,7 +360,7 @@
   45.57  	ntracks = last_track - first_track + 1;
   45.58  	cdrom->numtracks = ntracks;
   45.59  	toc_size = 4 + (ntracks + 1) * 8;
   45.60 -	toc = (u_char *)malloc(toc_size);
   45.61 +	toc = (u_char *)SDL_malloc(toc_size);
   45.62  	if	(toc == NULL)
   45.63  		return(-1);
   45.64  	bzero(cdb, sizeof (cdb));
   45.65 @@ -373,7 +373,7 @@
   45.66  			&sus);
   45.67  	if	(sts < 0)
   45.68  		{
   45.69 -		free(toc);
   45.70 +		SDL_free(toc);
   45.71  		return(-1);
   45.72  		}
   45.73  
   45.74 @@ -393,7 +393,7 @@
   45.75  			cdrom->track[i-1].length = cdrom->track[i].offset -
   45.76  						   cdrom->track[i-1].offset;
   45.77  		}
   45.78 -	free(toc);
   45.79 +	SDL_free(toc);
   45.80  	return(0);
   45.81  	}
   45.82  
   45.83 @@ -535,7 +535,7 @@
   45.84  
   45.85  	if ( SDL_numcds > 0 ) {
   45.86  		for ( i=0; i<SDL_numcds; ++i ) {
   45.87 -			free(SDL_cdlist[i]);
   45.88 +			SDL_free(SDL_cdlist[i]);
   45.89  			}
   45.90  		}
   45.91  	SDL_numcds = 0;
    46.1 --- a/src/cdrom/freebsd/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    46.2 +++ b/src/cdrom/freebsd/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    46.3 @@ -114,12 +114,12 @@
    46.4  
    46.5  		/* Add this drive to our list */
    46.6  		i = SDL_numcds;
    46.7 -		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    46.8 +		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    46.9  		if ( SDL_cdlist[i] == NULL ) {
   46.10  			SDL_OutOfMemory();
   46.11  			return;
   46.12  		}
   46.13 -		strcpy(SDL_cdlist[i], drive);
   46.14 +		SDL_strcpy(SDL_cdlist[i], drive);
   46.15  		SDL_cdmode[i] = stbuf->st_rdev;
   46.16  		++SDL_numcds;
   46.17  #ifdef DEBUG_CDROM
   46.18 @@ -153,15 +153,15 @@
   46.19  	SDL_CDcaps.Close = SDL_SYS_CDClose;
   46.20  
   46.21  	/* Look in the environment for our CD-ROM drive list */
   46.22 -	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
   46.23 +	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   46.24  	if ( SDLcdrom != NULL ) {
   46.25  		char *cdpath, *delim;
   46.26 -		cdpath = malloc(strlen(SDLcdrom)+1);
   46.27 +		cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
   46.28  		if ( cdpath != NULL ) {
   46.29 -			strcpy(cdpath, SDLcdrom);
   46.30 +			SDL_strcpy(cdpath, SDLcdrom);
   46.31  			SDLcdrom = cdpath;
   46.32  			do {
   46.33 -				delim = strchr(SDLcdrom, ':');
   46.34 +				delim = SDL_strchr(SDLcdrom, ':');
   46.35  				if ( delim ) {
   46.36  					*delim++ = '\0';
   46.37  				}
   46.38 @@ -174,7 +174,7 @@
   46.39  					SDLcdrom = NULL;
   46.40  				}
   46.41  			} while ( SDLcdrom );
   46.42 -			free(cdpath);
   46.43 +			SDL_free(cdpath);
   46.44  		}
   46.45  
   46.46  		/* If we found our drives, there's nothing left to do */
   46.47 @@ -190,7 +190,7 @@
   46.48  			exists = 1;
   46.49  			for ( j=checklist[i][1]; exists; ++j ) {
   46.50  				sprintf(drive, "/dev/%sc", &checklist[i][3]);
   46.51 -				insert = strchr(drive, '?');
   46.52 +				insert = SDL_strchr(drive, '?');
   46.53  				if ( insert != NULL ) {
   46.54  					*insert = j;
   46.55  				}
   46.56 @@ -398,7 +398,7 @@
   46.57  
   46.58  	if ( SDL_numcds > 0 ) {
   46.59  		for ( i=0; i<SDL_numcds; ++i ) {
   46.60 -			free(SDL_cdlist[i]);
   46.61 +			SDL_free(SDL_cdlist[i]);
   46.62  		}
   46.63  		SDL_numcds = 0;
   46.64  	}
    47.1 --- a/src/cdrom/linux/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    47.2 +++ b/src/cdrom/linux/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    47.3 @@ -142,7 +142,7 @@
    47.4  		}
    47.5  #ifdef USE_MNTENT
    47.6  		/* Even if we can't read it, it might be mounted */
    47.7 -		else if ( mnttype && (strcmp(mnttype, MNTTYPE_CDROM) == 0) ) {
    47.8 +		else if ( mnttype && (SDL_strcmp(mnttype, MNTTYPE_CDROM) == 0) ) {
    47.9  			is_cd = 1;
   47.10  		}
   47.11  #endif
   47.12 @@ -170,12 +170,12 @@
   47.13  
   47.14  		/* Add this drive to our list */
   47.15  		i = SDL_numcds;
   47.16 -		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
   47.17 +		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
   47.18  		if ( SDL_cdlist[i] == NULL ) {
   47.19  			SDL_OutOfMemory();
   47.20  			return;
   47.21  		}
   47.22 -		strcpy(SDL_cdlist[i], drive);
   47.23 +		SDL_strcpy(SDL_cdlist[i], drive);
   47.24  		SDL_cdmode[i] = stbuf->st_rdev;
   47.25  		++SDL_numcds;
   47.26  #ifdef DEBUG_CDROM
   47.27 @@ -198,45 +198,45 @@
   47.28  		char *mnt_dev;
   47.29  
   47.30  		while ( (mntent=getmntent(mntfp)) != NULL ) {
   47.31 -			mnt_type = malloc(strlen(mntent->mnt_type) + 1);
   47.32 +			mnt_type = SDL_malloc(SDL_strlen(mntent->mnt_type) + 1);
   47.33  			if (mnt_type == NULL)
   47.34  				continue;  /* maybe you'll get lucky next time. */
   47.35  
   47.36 -			mnt_dev = malloc(strlen(mntent->mnt_fsname) + 1);
   47.37 +			mnt_dev = SDL_malloc(SDL_strlen(mntent->mnt_fsname) + 1);
   47.38  			if (mnt_dev == NULL) {
   47.39 -				free(mnt_type);
   47.40 +				SDL_free(mnt_type);
   47.41  				continue;
   47.42  			}
   47.43  
   47.44 -			strcpy(mnt_type, mntent->mnt_type);
   47.45 -			strcpy(mnt_dev, mntent->mnt_fsname);
   47.46 +			SDL_strcpy(mnt_type, mntent->mnt_type);
   47.47 +			SDL_strcpy(mnt_dev, mntent->mnt_fsname);
   47.48  
   47.49  			/* Handle "supermount" filesystem mounts */
   47.50 -			if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
   47.51 -				tmp = strstr(mntent->mnt_opts, "fs=");
   47.52 +			if ( SDL_strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
   47.53 +				tmp = SDL_strstr(mntent->mnt_opts, "fs=");
   47.54  				if ( tmp ) {
   47.55 -					free(mnt_type);
   47.56 -					mnt_type = strdup(tmp + strlen("fs="));
   47.57 +					SDL_free(mnt_type);
   47.58 +					mnt_type = strdup(tmp + SDL_strlen("fs="));
   47.59  					if ( mnt_type ) {
   47.60 -						tmp = strchr(mnt_type, ',');
   47.61 +						tmp = SDL_strchr(mnt_type, ',');
   47.62  						if ( tmp ) {
   47.63  							*tmp = '\0';
   47.64  						}
   47.65  					}
   47.66  				}
   47.67 -				tmp = strstr(mntent->mnt_opts, "dev=");
   47.68 +				tmp = SDL_strstr(mntent->mnt_opts, "dev=");
   47.69  				if ( tmp ) {
   47.70 -					free(mnt_dev);
   47.71 -					mnt_dev = strdup(tmp + strlen("dev="));
   47.72 +					SDL_free(mnt_dev);
   47.73 +					mnt_dev = strdup(tmp + SDL_strlen("dev="));
   47.74  					if ( mnt_dev ) {
   47.75 -						tmp = strchr(mnt_dev, ',');
   47.76 +						tmp = SDL_strchr(mnt_dev, ',');
   47.77  						if ( tmp ) {
   47.78  							*tmp = '\0';
   47.79  						}
   47.80  					}
   47.81  				}
   47.82  			}
   47.83 -			if ( strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) {
   47.84 +			if ( SDL_strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) {
   47.85  #ifdef DEBUG_CDROM
   47.86    fprintf(stderr, "Checking mount path from %s: %s mounted on %s of %s\n",
   47.87  	mtab, mnt_dev, mntent->mnt_dir, mnt_type);
   47.88 @@ -245,8 +245,8 @@
   47.89  					AddDrive(mnt_dev, &stbuf);
   47.90  				}
   47.91  			}
   47.92 -			free(mnt_dev);
   47.93 -			free(mnt_type);
   47.94 +			SDL_free(mnt_dev);
   47.95 +			SDL_free(mnt_type);
   47.96  		}
   47.97  		endmntent(mntfp);
   47.98  	}
   47.99 @@ -277,15 +277,15 @@
  47.100  	SDL_CDcaps.Close = SDL_SYS_CDClose;
  47.101  
  47.102  	/* Look in the environment for our CD-ROM drive list */
  47.103 -	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
  47.104 +	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
  47.105  	if ( SDLcdrom != NULL ) {
  47.106  		char *cdpath, *delim;
  47.107 -		cdpath = malloc(strlen(SDLcdrom)+1);
  47.108 +		cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
  47.109  		if ( cdpath != NULL ) {
  47.110 -			strcpy(cdpath, SDLcdrom);
  47.111 +			SDL_strcpy(cdpath, SDLcdrom);
  47.112  			SDLcdrom = cdpath;
  47.113  			do {
  47.114 -				delim = strchr(SDLcdrom, ':');
  47.115 +				delim = SDL_strchr(SDLcdrom, ':');
  47.116  				if ( delim ) {
  47.117  					*delim++ = '\0';
  47.118  				}
  47.119 @@ -301,7 +301,7 @@
  47.120  					SDLcdrom = NULL;
  47.121  				}
  47.122  			} while ( SDLcdrom );
  47.123 -			free(cdpath);
  47.124 +			SDL_free(cdpath);
  47.125  		}
  47.126  
  47.127  		/* If we found our drives, there's nothing left to do */
  47.128 @@ -337,7 +337,7 @@
  47.129  			exists = 1;
  47.130  			for ( j=checklist[i][1]; exists; ++j ) {
  47.131  				sprintf(drive, "/dev/%s", &checklist[i][3]);
  47.132 -				insert = strchr(drive, '?');
  47.133 +				insert = SDL_strchr(drive, '?');
  47.134  				if ( insert != NULL ) {
  47.135  					*insert = j;
  47.136  				}
  47.137 @@ -551,7 +551,7 @@
  47.138  
  47.139  	if ( SDL_numcds > 0 ) {
  47.140  		for ( i=0; i<SDL_numcds; ++i ) {
  47.141 -			free(SDL_cdlist[i]);
  47.142 +			SDL_free(SDL_cdlist[i]);
  47.143  		}
  47.144  		SDL_numcds = 0;
  47.145  	}
    48.1 --- a/src/cdrom/macos/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    48.2 +++ b/src/cdrom/macos/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    48.3 @@ -160,7 +160,7 @@
    48.4  	long				i, leadout;
    48.5  
    48.6  	/* Get the number of tracks on the CD by examining the TOC */
    48.7 -	memset(&cdpb, 0, sizeof(cdpb));
    48.8 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
    48.9  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.10  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.11  	cdpb.csCode = kReadTOC;
   48.12 @@ -181,7 +181,7 @@
   48.13  
   48.14  
   48.15  	/* Get the lead out area of the CD by examining the TOC */
   48.16 -	memset(&cdpb, 0, sizeof(cdpb));
   48.17 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.18  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.19  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.20  	cdpb.csCode = kReadTOC;
   48.21 @@ -197,8 +197,8 @@
   48.22  			SDL_SYS_BCDToShort(cdpb.csParam.bytes[2]));
   48.23  
   48.24  	/* Get an array of track locations by examining the TOC */
   48.25 -	memset(tracks, 0, sizeof(tracks));
   48.26 -	memset(&cdpb, 0, sizeof(cdpb));
   48.27 +	SDL_memset(tracks, 0, sizeof(tracks));
   48.28 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.29  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.30  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.31  	cdpb.csCode = kReadTOC;
   48.32 @@ -255,7 +255,7 @@
   48.33  	if ( ! get_drivenum(cdrom->id) ) {
   48.34  		return(CD_TRAYEMPTY);
   48.35  	}
   48.36 -	memset(&cdpb, 0, sizeof(cdpb));
   48.37 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.38  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.39  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.40  	cdpb.csCode = kReadTOC;
   48.41 @@ -276,7 +276,7 @@
   48.42  
   48.43  	if (1 || SDL_cdlist[cdrom->id].hasAudio) {
   48.44  		/* Get the current playback status */
   48.45 -		memset(&cdpb, 0, sizeof(cdpb));
   48.46 +		SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.47  		cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.48  		cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.49  		cdpb.csCode = kAudioStatus;
   48.50 @@ -335,7 +335,7 @@
   48.51  	}
   48.52  
   48.53  	/* Specify the AudioCD playback mode */
   48.54 -	memset(&cdpb, 0, sizeof(cdpb));
   48.55 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.56  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.57  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.58  	cdpb.csCode = kSetPlayMode;
   48.59 @@ -346,7 +346,7 @@
   48.60  
   48.61  #if 1
   48.62  	/* Specify the end of audio playback */
   48.63 -	memset(&cdpb, 0, sizeof(cdpb));
   48.64 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.65  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.66  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.67  	cdpb.csCode = kAudioStop;
   48.68 @@ -358,7 +358,7 @@
   48.69  	}
   48.70  
   48.71  	/* Specify the start of audio playback, and start it */
   48.72 -	memset(&cdpb, 0, sizeof(cdpb));
   48.73 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.74  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.75  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.76  	cdpb.csCode = kAudioPlay;
   48.77 @@ -373,7 +373,7 @@
   48.78  #else
   48.79  	/* Specify the end of audio playback */
   48.80  	FRAMES_TO_MSF(start+length, &m, &s, &f);
   48.81 -	memset(&cdpb, 0, sizeof(cdpb));
   48.82 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.83  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.84  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.85  	cdpb.csCode = kAudioStop;
   48.86 @@ -388,7 +388,7 @@
   48.87  
   48.88  	/* Specify the start of audio playback, and start it */
   48.89  	FRAMES_TO_MSF(start, &m, &s, &f);
   48.90 -	memset(&cdpb, 0, sizeof(cdpb));
   48.91 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
   48.92  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
   48.93  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
   48.94  	cdpb.csCode = kAudioPlay;
   48.95 @@ -411,7 +411,7 @@
   48.96  {
   48.97  	CDCntrlParam cdpb;
   48.98  
   48.99 -	memset(&cdpb, 0, sizeof(cdpb));
  48.100 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
  48.101  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  48.102  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  48.103  	cdpb.csCode = kAudioPause;
  48.104 @@ -429,7 +429,7 @@
  48.105  {
  48.106  	CDCntrlParam cdpb;
  48.107  
  48.108 -	memset(&cdpb, 0, sizeof(cdpb));
  48.109 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
  48.110  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  48.111  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  48.112  	cdpb.csCode = kAudioPause;
  48.113 @@ -447,7 +447,7 @@
  48.114  {
  48.115  	CDCntrlParam cdpb;
  48.116  
  48.117 -	memset(&cdpb, 0, sizeof(cdpb));
  48.118 +	SDL_memset(&cdpb, 0, sizeof(cdpb));
  48.119  	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
  48.120  	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  48.121  	cdpb.csCode = kAudioStop;
  48.122 @@ -481,7 +481,7 @@
  48.123  		}
  48.124  	
  48.125  		/* Does drive contain mounted volume? If not, skip */
  48.126 -		memset(&hpb, 0, sizeof(hpb));
  48.127 +		SDL_memset(&hpb, 0, sizeof(hpb));
  48.128  		hpb.volumeParam.ioVRefNum = driveElem->dQDrive;
  48.129  		if ( PBHGetVInfoSync(&hpb) != noErr ) {
  48.130  			continue;
  48.131 @@ -495,7 +495,7 @@
  48.132  
  48.133  	/* If no disk is present, just eject the tray */
  48.134  	if (! disk) {
  48.135 -		memset(&cpb, 0, sizeof(cpb));
  48.136 +		SDL_memset(&cpb, 0, sizeof(cpb));
  48.137  		cpb.cntrlParam.ioVRefNum = 0; /* No Drive */
  48.138  		cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
  48.139  		cpb.cntrlParam.csCode = kEjectTheDisc;
  48.140 @@ -516,6 +516,6 @@
  48.141  void SDL_SYS_CDQuit(void)
  48.142  {
  48.143  	while(SDL_numcds--) 
  48.144 -		memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0]));
  48.145 +		SDL_memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0]));
  48.146  }
  48.147  
    49.1 --- a/src/cdrom/macosx/AudioFilePlayer.c	Mon Feb 06 17:28:04 2006 +0000
    49.2 +++ b/src/cdrom/macosx/AudioFilePlayer.c	Tue Feb 07 06:59:48 2006 +0000
    49.3 @@ -64,7 +64,7 @@
    49.4      if (afp->mConnected)
    49.5          return 0 ;
    49.6  
    49.7 -    memcpy(&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit));
    49.8 +    SDL_memcpy(&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit));
    49.9  
   49.10      OSStatus result = noErr;
   49.11      
   49.12 @@ -155,7 +155,7 @@
   49.13              FSClose (afp->mForkRefNum);
   49.14              afp->mForkRefNum = 0;
   49.15          }
   49.16 -        free(afp);
   49.17 +        SDL_free(afp);
   49.18      }
   49.19  }
   49.20  
   49.21 @@ -304,10 +304,10 @@
   49.22  {
   49.23      SInt64 fileDataSize  = 0;
   49.24  
   49.25 -    AudioFilePlayer *afp = (AudioFilePlayer *) malloc(sizeof (AudioFilePlayer));
   49.26 +    AudioFilePlayer *afp = (AudioFilePlayer *) SDL_malloc(sizeof (AudioFilePlayer));
   49.27      if (afp == NULL)
   49.28          return NULL;
   49.29 -    memset(afp, '\0', sizeof (*afp));
   49.30 +    SDL_memset(afp, '\0', sizeof (*afp));
   49.31  
   49.32      #define SET_AUDIOFILEPLAYER_METHOD(m) afp->m = AudioFilePlayer_##m
   49.33      SET_AUDIOFILEPLAYER_METHOD(SetDestination);
   49.34 @@ -326,7 +326,7 @@
   49.35  
   49.36      if (!afp->OpenFile (afp, inFileRef, &fileDataSize))
   49.37      {
   49.38 -        free(afp);
   49.39 +        SDL_free(afp);
   49.40          return NULL;
   49.41      }
   49.42          
    50.1 --- a/src/cdrom/macosx/AudioFileReaderThread.c	Mon Feb 06 17:28:04 2006 +0000
    50.2 +++ b/src/cdrom/macosx/AudioFileReaderThread.c	Tue Feb 07 06:59:48 2006 +0000
    50.3 @@ -86,7 +86,7 @@
    50.4          FileData *i = frt->mFileData;
    50.5          FileData *prev = NULL;
    50.6  
    50.7 -        FileData *newfd = (FileData *) malloc(sizeof (FileData));
    50.8 +        FileData *newfd = (FileData *) SDL_malloc(sizeof (FileData));
    50.9          newfd->obj = inItem;
   50.10          newfd->next = NULL;
   50.11  
   50.12 @@ -136,7 +136,7 @@
   50.13                      frt->mFileData = next;
   50.14                  else
   50.15                      prev->next = next;
   50.16 -                free(i);
   50.17 +                SDL_free(i);
   50.18              }
   50.19              i = next;
   50.20          }
   50.21 @@ -279,7 +279,7 @@
   50.22              {
   50.23                  FileData *next = frt->mFileData->next;
   50.24                  theItem = frt->mFileData->obj;
   50.25 -                free(frt->mFileData);
   50.26 +                SDL_free(frt->mFileData);
   50.27                  frt->mFileData = next;
   50.28              }
   50.29  
   50.30 @@ -330,21 +330,21 @@
   50.31      if (frt != NULL)
   50.32      {
   50.33          delete_SDLOSXCAGuard(frt->mGuard);
   50.34 -        free(frt);
   50.35 +        SDL_free(frt);
   50.36      }
   50.37  }
   50.38  
   50.39  FileReaderThread *new_FileReaderThread ()
   50.40  {
   50.41 -    FileReaderThread *frt = (FileReaderThread *) malloc(sizeof (FileReaderThread));
   50.42 +    FileReaderThread *frt = (FileReaderThread *) SDL_malloc(sizeof (FileReaderThread));
   50.43      if (frt == NULL)
   50.44          return NULL;
   50.45 -    memset(frt, '\0', sizeof (*frt));
   50.46 +    SDL_memset(frt, '\0', sizeof (*frt));
   50.47  
   50.48      frt->mGuard = new_SDLOSXCAGuard();
   50.49      if (frt->mGuard == NULL)
   50.50      {
   50.51 -        free(frt);
   50.52 +        SDL_free(frt);
   50.53          return NULL;
   50.54      }
   50.55  
   50.56 @@ -549,7 +549,7 @@
   50.57              free (afm->mFileBuffer);
   50.58          }
   50.59  
   50.60 -        free(afm);
   50.61 +        SDL_free(afm);
   50.62      }
   50.63  }
   50.64  
   50.65 @@ -568,10 +568,10 @@
   50.66              return NULL;
   50.67      }
   50.68  
   50.69 -    afm = (AudioFileManager *) malloc(sizeof (AudioFileManager));
   50.70 +    afm = (AudioFileManager *) SDL_malloc(sizeof (AudioFileManager));
   50.71      if (afm == NULL)
   50.72          return NULL;
   50.73 -    memset(afm, '\0', sizeof (*afm));
   50.74 +    SDL_memset(afm, '\0', sizeof (*afm));
   50.75  
   50.76      #define SET_AUDIOFILEMANAGER_METHOD(m) afm->m = AudioFileManager_##m
   50.77      SET_AUDIOFILEMANAGER_METHOD(Disconnect);
    51.1 --- a/src/cdrom/macosx/SDLOSXCAGuard.c	Mon Feb 06 17:28:04 2006 +0000
    51.2 +++ b/src/cdrom/macosx/SDLOSXCAGuard.c	Tue Feb 07 06:59:48 2006 +0000
    51.3 @@ -147,10 +147,10 @@
    51.4  
    51.5  SDLOSXCAGuard *new_SDLOSXCAGuard(void)
    51.6  {
    51.7 -    SDLOSXCAGuard *cag = (SDLOSXCAGuard *) malloc(sizeof (SDLOSXCAGuard));
    51.8 +    SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard));
    51.9      if (cag == NULL)
   51.10          return NULL;
   51.11 -    memset(cag, '\0', sizeof (*cag));
   51.12 +    SDL_memset(cag, '\0', sizeof (*cag));
   51.13  
   51.14      #define SET_SDLOSXCAGUARD_METHOD(m) cag->m = SDLOSXCAGuard_##m
   51.15      SET_SDLOSXCAGUARD_METHOD(Lock);
   51.16 @@ -176,7 +176,7 @@
   51.17      {
   51.18          pthread_mutex_destroy(&cag->mMutex);
   51.19          pthread_cond_destroy(&cag->mCondVar);
   51.20 -        free(cag);
   51.21 +        SDL_free(cag);
   51.22      }
   51.23  }
   51.24  
    52.1 --- a/src/cdrom/openbsd/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    52.2 +++ b/src/cdrom/openbsd/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    52.3 @@ -119,12 +119,12 @@
    52.4  
    52.5  		/* Add this drive to our list */
    52.6  		i = SDL_numcds;
    52.7 -		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    52.8 +		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    52.9  		if ( SDL_cdlist[i] == NULL ) {
   52.10  			SDL_OutOfMemory();
   52.11  			return;
   52.12  		}
   52.13 -		strcpy(SDL_cdlist[i], drive);
   52.14 +		SDL_strcpy(SDL_cdlist[i], drive);
   52.15  		SDL_cdmode[i] = stbuf->st_rdev;
   52.16  		++SDL_numcds;
   52.17  #ifdef DEBUG_CDROM
   52.18 @@ -162,15 +162,15 @@
   52.19  	SDL_CDcaps.Close = SDL_SYS_CDClose;
   52.20  
   52.21  	/* Look in the environment for our CD-ROM drive list */
   52.22 -	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
   52.23 +	SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   52.24  	if ( SDLcdrom != NULL ) {
   52.25  		char *cdpath, *delim;
   52.26 -		cdpath = malloc(strlen(SDLcdrom)+1);
   52.27 +		cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
   52.28  		if ( cdpath != NULL ) {
   52.29 -			strcpy(cdpath, SDLcdrom);
   52.30 +			SDL_strcpy(cdpath, SDLcdrom);
   52.31  			SDLcdrom = cdpath;
   52.32  			do {
   52.33 -				delim = strchr(SDLcdrom, ':');
   52.34 +				delim = SDL_strchr(SDLcdrom, ':');
   52.35  				if ( delim ) {
   52.36  					*delim++ = '\0';
   52.37  				}
   52.38 @@ -183,7 +183,7 @@
   52.39  					SDLcdrom = NULL;
   52.40  				}
   52.41  			} while ( SDLcdrom );
   52.42 -			free(cdpath);
   52.43 +			SDL_free(cdpath);
   52.44  		}
   52.45  
   52.46  		/* If we found our drives, there's nothing left to do */
   52.47 @@ -199,7 +199,7 @@
   52.48  			exists = 1;
   52.49  			for ( j=checklist[i][1]; exists; ++j ) {
   52.50  				sprintf(drive, "/dev/%s", &checklist[i][3]);
   52.51 -				insert = strchr(drive, '?');
   52.52 +				insert = SDL_strchr(drive, '?');
   52.53  				if ( insert != NULL ) {
   52.54  					*insert = j;
   52.55  				}
   52.56 @@ -407,7 +407,7 @@
   52.57  
   52.58  	if ( SDL_numcds > 0 ) {
   52.59  		for ( i=0; i<SDL_numcds; ++i ) {
   52.60 -			free(SDL_cdlist[i]);
   52.61 +			SDL_free(SDL_cdlist[i]);
   52.62  		}
   52.63  		SDL_numcds = 0;
   52.64  	}
    53.1 --- a/src/cdrom/os2/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    53.2 +++ b/src/cdrom/os2/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    53.3 @@ -81,7 +81,7 @@
    53.4  
    53.5  /* Get the number of CD ROMs in the System */
    53.6  /* Clean SysInfo structure */
    53.7 -memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS));
    53.8 +SDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS));
    53.9  /* Prepare structure to Ask Numer of Audio CDs */
   53.10  msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO;	/* CD Audio Type */
   53.11  msp.pszReturn = (PSZ)&SysInfoRet; 	/* Return Structure */
   53.12 @@ -98,13 +98,13 @@
   53.13  	{
   53.14  	msp.ulNumber = i+1;
   53.15  	mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0);
   53.16 -	SDL_cdlist[i] = (char *)malloc(strlen(SysInfoRet)+1);
   53.17 +	SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(SysInfoRet)+1);
   53.18  	if ( SDL_cdlist[i] == NULL )
   53.19  		{
   53.20  		SDL_OutOfMemory();
   53.21  		return(-1);
   53.22  		}
   53.23 -	strcpy(SDL_cdlist[i], SysInfoRet);
   53.24 +	SDL_strcpy(SDL_cdlist[i], SysInfoRet);
   53.25  	}
   53.26  return(0);
   53.27  }
   53.28 @@ -166,7 +166,7 @@
   53.29  	cdrom->numtracks = SDL_MAX_TRACKS;
   53.30  	}
   53.31  /* Alocate space for TOC data */
   53.32 -mtr = (MCI_TOC_REC *)malloc(cdrom->numtracks*sizeof(MCI_TOC_REC));
   53.33 +mtr = (MCI_TOC_REC *)SDL_malloc(cdrom->numtracks*sizeof(MCI_TOC_REC));
   53.34  if ( mtr == NULL )
   53.35  	{
   53.36  	SDL_OutOfMemory();
   53.37 @@ -178,7 +178,7 @@
   53.38  if (LOUSHORT(mciSendCommand(cdrom->id,MCI_GETTOC,MCI_WAIT,&mtp, 0)) != MCIERR_SUCCESS)
   53.39  	{
   53.40  	SDL_OutOfMemory();
   53.41 -	free(mtr);
   53.42 +	SDL_free(mtr);
   53.43  	return(CD_ERROR);
   53.44  	}
   53.45  /* Fill SDL Tracks Structure */
   53.46 @@ -193,7 +193,7 @@
   53.47  	msp.ulValue = (ULONG)((mtr+i)->TrackNum); /* Track Number? */
   53.48  	if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS)
   53.49  		{
   53.50 -		free(mtr);
   53.51 +		SDL_free(mtr);
   53.52  		return (CD_ERROR);
   53.53  		}
   53.54  	if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK;
   53.55 @@ -203,7 +203,7 @@
   53.56  	/* Set Track Offset */
   53.57  	cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr);
   53.58  	}
   53.59 -free(mtr);
   53.60 +SDL_free(mtr);
   53.61  return(0);
   53.62  }
   53.63  
   53.64 @@ -386,7 +386,7 @@
   53.65  	{
   53.66  	for ( i=0; i<SDL_numcds; ++i )
   53.67  		{
   53.68 -		free(SDL_cdlist[i]);
   53.69 +		SDL_free(SDL_cdlist[i]);
   53.70  		}
   53.71  	SDL_numcds = 0;
   53.72  	}
    54.1 --- a/src/cdrom/osf/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    54.2 +++ b/src/cdrom/osf/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    54.3 @@ -125,13 +125,13 @@
    54.4  
    54.5  	/* Add this drive to our list */
    54.6  	i = SDL_numcds;
    54.7 -	SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    54.8 +	SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    54.9  	if ( SDL_cdlist[i] == NULL ) {
   54.10  	    SDL_OutOfMemory();
   54.11  	    return;
   54.12  	}
   54.13  
   54.14 -	strcpy(SDL_cdlist[i], drive);
   54.15 +	SDL_strcpy(SDL_cdlist[i], drive);
   54.16  	SDL_cdmode[i] = stbuf->st_rdev;
   54.17  	++SDL_numcds;
   54.18  #ifdef DEBUG_CDROM
   54.19 @@ -177,15 +177,15 @@
   54.20  
   54.21  
   54.22      /* Look in the environment for our CD-ROM drive list */
   54.23 -    SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
   54.24 +    SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   54.25      if ( SDLcdrom != NULL ) {
   54.26  	char *cdpath, *delim;
   54.27 -	cdpath = malloc(strlen(SDLcdrom)+1);
   54.28 +	cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
   54.29  	if ( cdpath != NULL ) {
   54.30 -	    strcpy(cdpath, SDLcdrom);
   54.31 +	    SDL_strcpy(cdpath, SDLcdrom);
   54.32  	    SDLcdrom = cdpath;
   54.33  	    do {
   54.34 -		delim = strchr(SDLcdrom, ':');
   54.35 +		delim = SDL_strchr(SDLcdrom, ':');
   54.36  		if ( delim ) {
   54.37  		    *delim++ = '\0';
   54.38  		}
   54.39 @@ -198,7 +198,7 @@
   54.40  		    SDLcdrom = NULL;
   54.41  		}
   54.42  	    } while ( SDLcdrom );
   54.43 -	    free(cdpath);
   54.44 +	    SDL_free(cdpath);
   54.45  	}
   54.46  
   54.47  	/* If we found our drives, there's nothing left to do */
   54.48 @@ -214,9 +214,9 @@
   54.49  
   54.50  	devdir = opendir(checklist[i].dir);
   54.51  	if (devdir) {
   54.52 -	    name_len = strlen(checklist[i].name);
   54.53 +	    name_len = SDL_strlen(checklist[i].name);
   54.54  	    while (devent = readdir(devdir))
   54.55 -		if (memcmp(checklist[i].name, devent->d_name, name_len) == 0)
   54.56 +		if (SDL_memcmp(checklist[i].name, devent->d_name, name_len) == 0)
   54.57  		    if (devent->d_name[devent->d_namlen-1] == 'c') {
   54.58  			sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name);
   54.59  #ifdef DEBUG_CDROM
   54.60 @@ -234,8 +234,8 @@
   54.61      }
   54.62  
   54.63  /*
   54.64 -    SDLcdrom=malloc(sizeof(char) * 32);
   54.65 -    strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
   54.66 +    SDLcdrom=SDL_malloc(sizeof(char) * 32);
   54.67 +    SDL_strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");
   54.68      SDL_cdlist[0] = SDLcdrom;
   54.69      stat(SDLcdrom, &stbuf);
   54.70      SDL_cdmode[0] = stbuf.st_rdev;
   54.71 @@ -449,7 +449,7 @@
   54.72  
   54.73      if ( SDL_numcds > 0 ) {
   54.74  	for ( i=0; i<SDL_numcds; ++i ) {
   54.75 -	    free(SDL_cdlist[i]);
   54.76 +	    SDL_free(SDL_cdlist[i]);
   54.77  	}
   54.78  	SDL_numcds = 0;
   54.79      }
    55.1 --- a/src/cdrom/qnx/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    55.2 +++ b/src/cdrom/qnx/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    55.3 @@ -128,13 +128,13 @@
    55.4          /* Add this drive to our list */
    55.5  
    55.6          i = SDL_numcds;
    55.7 -        SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    55.8 +        SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    55.9          if (SDL_cdlist[i] == NULL)
   55.10          {
   55.11              SDL_OutOfMemory();
   55.12              return;
   55.13          }
   55.14 -        strcpy(SDL_cdlist[i], drive);
   55.15 +        SDL_strcpy(SDL_cdlist[i], drive);
   55.16          SDL_cdmode[i] = stbuf->st_rdev;
   55.17          ++SDL_numcds;
   55.18      }
   55.19 @@ -169,18 +169,18 @@
   55.20      }
   55.21  
   55.22      /* Look in the environment for our CD-ROM drive list */
   55.23 -    SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
   55.24 +    SDLcdrom = SDL_getenv("SDL_CDROM");	/* ':' separated list of devices */
   55.25      if ( SDLcdrom != NULL )
   55.26      {
   55.27          char *cdpath, *delim;
   55.28  
   55.29 -        cdpath = malloc(strlen(SDLcdrom)+1);
   55.30 +        cdpath = SDL_malloc(SDL_strlen(SDLcdrom)+1);
   55.31          if (cdpath != NULL)
   55.32          {
   55.33 -            strcpy(cdpath, SDLcdrom);
   55.34 +            SDL_strcpy(cdpath, SDLcdrom);
   55.35              SDLcdrom = cdpath;
   55.36              do {
   55.37 -                delim = strchr(SDLcdrom, ':');
   55.38 +                delim = SDL_strchr(SDLcdrom, ':');
   55.39                  if (delim)
   55.40                  {
   55.41                      *delim++ = '\0';
   55.42 @@ -198,7 +198,7 @@
   55.43                      SDLcdrom = NULL;
   55.44                  }
   55.45              } while (SDLcdrom);
   55.46 -            free(cdpath);
   55.47 +            SDL_free(cdpath);
   55.48          }
   55.49  
   55.50          /* If we found our drives, there's nothing left to do */
   55.51 @@ -219,7 +219,7 @@
   55.52              for ( j=checklist[i][1]; exists; ++j )
   55.53              {
   55.54                  sprintf(drive, "/dev/%s", &checklist[i][3]);
   55.55 -                insert = strchr(drive, '?');
   55.56 +                insert = SDL_strchr(drive, '?');
   55.57                  if (insert != NULL)
   55.58                  {
   55.59                      *insert = j;
   55.60 @@ -346,7 +346,7 @@
   55.61  
   55.62      /* if media exists, then do other stuff */
   55.63  
   55.64 -    memset(&info, 0x00, sizeof(info));
   55.65 +    SDL_memset(&info, 0x00, sizeof(info));
   55.66      info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION;
   55.67  
   55.68      do {
   55.69 @@ -544,7 +544,7 @@
   55.70      {
   55.71          for (i=0; i<SDL_numcds; ++i)
   55.72          {
   55.73 -            free(SDL_cdlist[i]);
   55.74 +            SDL_free(SDL_cdlist[i]);
   55.75          }
   55.76          SDL_numcds = 0;
   55.77      }
    56.1 --- a/src/cdrom/win32/SDL_syscdrom.c	Mon Feb 06 17:28:04 2006 +0000
    56.2 +++ b/src/cdrom/win32/SDL_syscdrom.c	Tue Feb 07 06:59:48 2006 +0000
    56.3 @@ -66,12 +66,12 @@
    56.4  	if ( SDL_numcds < MAX_DRIVES ) {
    56.5  		/* Add this drive to our list */
    56.6  		i = SDL_numcds;
    56.7 -		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
    56.8 +		SDL_cdlist[i] = (char *)SDL_malloc(SDL_strlen(drive)+1);
    56.9  		if ( SDL_cdlist[i] == NULL ) {
   56.10  			SDL_OutOfMemory();
   56.11  			return;
   56.12  		}
   56.13 -		strcpy(SDL_cdlist[i], drive);
   56.14 +		SDL_strcpy(SDL_cdlist[i], drive);
   56.15  		++SDL_numcds;
   56.16  #ifdef CDROM_DEBUG
   56.17    fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
   56.18 @@ -99,12 +99,12 @@
   56.19  
   56.20  	/* Scan the system for CD-ROM drives */
   56.21  	for ( i='A'; i<='Z'; ++i ) {
   56.22 -		snprintf(drive, SDL_arraysize(drive), "%c:\\", i);
   56.23 +		SDL_snprintf(drive, SDL_arraysize(drive), "%c:\\", i);
   56.24  		if ( GetDriveType(drive) == DRIVE_CDROM ) {
   56.25  			AddDrive(drive);
   56.26  		}
   56.27  	}
   56.28 -	memset(SDL_mciID, 0, sizeof(SDL_mciID));
   56.29 +	SDL_memset(SDL_mciID, 0, sizeof(SDL_mciID));
   56.30  	return(0);
   56.31  }
   56.32  
   56.33 @@ -377,7 +377,7 @@
   56.34  
   56.35  	if ( SDL_numcds > 0 ) {
   56.36  		for ( i=0; i<SDL_numcds; ++i ) {
   56.37 -			free(SDL_cdlist[i]);
   56.38 +			SDL_free(SDL_cdlist[i]);
   56.39  		}
   56.40  		SDL_numcds = 0;
   56.41  	}
    57.1 --- a/src/events/SDL_active.c	Mon Feb 06 17:28:04 2006 +0000
    57.2 +++ b/src/events/SDL_active.c	Tue Feb 07 06:59:48 2006 +0000
    57.3 @@ -73,7 +73,7 @@
    57.4  	posted = 0;
    57.5  	if ( SDL_ProcessEvents[SDL_ACTIVEEVENT] == SDL_ENABLE ) {
    57.6  		SDL_Event event;
    57.7 -		memset(&event, 0, sizeof(event));
    57.8 +		SDL_memset(&event, 0, sizeof(event));
    57.9  		event.type = SDL_ACTIVEEVENT;
   57.10  		event.active.gain = gain;
   57.11  		event.active.state = state;
    58.1 --- a/src/events/SDL_events.c	Mon Feb 06 17:28:04 2006 +0000
    58.2 +++ b/src/events/SDL_events.c	Tue Feb 07 06:59:48 2006 +0000
    58.3 @@ -151,7 +151,7 @@
    58.4  {
    58.5  	/* Reset everything to zero */
    58.6  	SDL_EventThread = NULL;
    58.7 -	memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
    58.8 +	SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
    58.9  
   58.10  	/* Create the lock and set ourselves active */
   58.11  #ifndef DISABLE_THREADS
   58.12 @@ -239,7 +239,7 @@
   58.13  
   58.14  	/* No filter to start with, process most event types */
   58.15  	SDL_EventOK = NULL;
   58.16 -	memset(SDL_ProcessEvents,SDL_ENABLE,sizeof(SDL_ProcessEvents));
   58.17 +	SDL_memset(SDL_ProcessEvents,SDL_ENABLE,sizeof(SDL_ProcessEvents));
   58.18  	SDL_eventstate = ~0;
   58.19  	/* It's not save to call SDL_EventState() yet */
   58.20  	SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT);
   58.21 @@ -306,7 +306,7 @@
   58.22  	{
   58.23  		int here, next;
   58.24  
   58.25 -		/* This can probably be optimized with memcpy() -- careful! */
   58.26 +		/* This can probably be optimized with SDL_memcpy() -- careful! */
   58.27  		if ( --SDL_EventQ.tail < 0 ) {
   58.28  			SDL_EventQ.tail = MAXEVENTS-1;
   58.29  		}
   58.30 @@ -493,7 +493,7 @@
   58.31  	posted = 0;
   58.32  	if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
   58.33  		SDL_Event event;
   58.34 -		memset(&event, 0, sizeof(event));
   58.35 +		SDL_memset(&event, 0, sizeof(event));
   58.36  		event.type = SDL_SYSWMEVENT;
   58.37  		event.syswm.msg = message;
   58.38  		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
    59.1 --- a/src/events/SDL_keyboard.c	Mon Feb 06 17:28:04 2006 +0000
    59.2 +++ b/src/events/SDL_keyboard.c	Tue Feb 07 06:59:48 2006 +0000
    59.3 @@ -60,8 +60,8 @@
    59.4  
    59.5  	/* Initialize the tables */
    59.6  	SDL_ModState = KMOD_NONE;
    59.7 -	memset(keynames, 0, sizeof(keynames));
    59.8 -	memset(SDL_KeyState, 0, sizeof(SDL_KeyState));
    59.9 +	SDL_memset(keynames, 0, sizeof(keynames));
   59.10 +	SDL_memset(SDL_KeyState, 0, sizeof(SDL_KeyState));
   59.11  	video->InitOSKeymap(this);
   59.12  
   59.13  	SDL_EnableKeyRepeat(0, 0);
   59.14 @@ -319,7 +319,7 @@
   59.15  	SDL_keysym keysym;
   59.16  	SDLKey key;
   59.17  
   59.18 -	memset(&keysym, 0, (sizeof keysym));
   59.19 +	SDL_memset(&keysym, 0, (sizeof keysym));
   59.20  	for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) {
   59.21  		if ( SDL_KeyState[key] == SDL_PRESSED ) {
   59.22  			keysym.sym = key;
   59.23 @@ -376,7 +376,7 @@
   59.24  	int posted, repeatable;
   59.25  	Uint16 modstate;
   59.26  
   59.27 -	memset(&event, 0, sizeof(event));
   59.28 +	SDL_memset(&event, 0, sizeof(event));
   59.29  
   59.30  #if 0
   59.31  printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym), 
    60.1 --- a/src/events/SDL_mouse.c	Mon Feb 06 17:28:04 2006 +0000
    60.2 +++ b/src/events/SDL_mouse.c	Tue Feb 07 06:59:48 2006 +0000
    60.3 @@ -182,7 +182,7 @@
    60.4  	posted = 0;
    60.5  	if ( SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE ) {
    60.6  		SDL_Event event;
    60.7 -		memset(&event, 0, sizeof(event));
    60.8 +		SDL_memset(&event, 0, sizeof(event));
    60.9  		event.type = SDL_MOUSEMOTION;
   60.10  		event.motion.state = buttonstate;
   60.11  		event.motion.x = X;
   60.12 @@ -204,7 +204,7 @@
   60.13  	int move_mouse;
   60.14  	Uint8 buttonstate;
   60.15  
   60.16 -	memset(&event, 0, sizeof(event));
   60.17 +	SDL_memset(&event, 0, sizeof(event));
   60.18  
   60.19  	/* Check parameters */
   60.20  	if ( x || y ) {
    61.1 --- a/src/events/SDL_sysevents.h	Mon Feb 06 17:28:04 2006 +0000
    61.2 +++ b/src/events/SDL_sysevents.h	Tue Feb 07 06:59:48 2006 +0000
    61.3 @@ -2,7 +2,7 @@
    61.4      SDL - Simple DirectMedia Layer
    61.5      Copyright (C) 1997-2006 Sam Lantinga
    61.6  
    61.7 -    This library is free software; you can redistribute it and/or
    61.8 +    This library is SDL_free software; you can redistribute it and/or
    61.9      modify it under the terms of the GNU Lesser General Public
   61.10      License as published by the Free Software Foundation; either
   61.11      version 2.1 of the License, or (at your option) any later version.
    62.1 --- a/src/file/SDL_rwops.c	Mon Feb 06 17:28:04 2006 +0000
    62.2 +++ b/src/file/SDL_rwops.c	Tue Feb 07 06:59:48 2006 +0000
    62.3 @@ -120,7 +120,7 @@
    62.4  		total_bytes = mem_available;
    62.5  	}
    62.6  
    62.7 -	memcpy(ptr, context->hidden.mem.here, total_bytes);
    62.8 +	SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
    62.9  	context->hidden.mem.here += total_bytes;
   62.10  
   62.11  	return (total_bytes / size);
   62.12 @@ -130,7 +130,7 @@
   62.13  	if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) {
   62.14  		num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
   62.15  	}
   62.16 -	memcpy(context->hidden.mem.here, ptr, num*size);
   62.17 +	SDL_memcpy(context->hidden.mem.here, ptr, num*size);
   62.18  	context->hidden.mem.here += num*size;
   62.19  	return(num);
   62.20  }
   62.21 @@ -162,8 +162,8 @@
   62.22   */
   62.23  static char *unix_to_mac(const char *file)
   62.24  {
   62.25 -	int flen = strlen(file);
   62.26 -	char *path = malloc(flen + 2);
   62.27 +	int flen = SDL_strlen(file);
   62.28 +	char *path = SDL_malloc(flen + 2);
   62.29  	const char *src = file;
   62.30  	char *dst = path;
   62.31  	if(*src == '/') {
   62.32 @@ -175,7 +175,7 @@
   62.33  			*dst++ = ':';   /* relative paths begin with ':' */
   62.34  	}
   62.35  	while(src < file + flen) {
   62.36 -		const char *end = strchr(src, '/');
   62.37 +		const char *end = SDL_strchr(src, '/');
   62.38  		int len;
   62.39  		if(!end)
   62.40  			end = file + flen; /* last component */
   62.41 @@ -186,7 +186,7 @@
   62.42  			if(len == 2 && src[0] == '.' && src[1] == '.') {
   62.43  				/* replace .. with the empty string */
   62.44  			} else {
   62.45 -				memcpy(dst, src, len);
   62.46 +				SDL_memcpy(dst, src, len);
   62.47  				dst += len;
   62.48  			}
   62.49  			if(end < file + flen)
   62.50 @@ -209,7 +209,7 @@
   62.51  	{
   62.52  		char *mpath = unix_to_mac(file);
   62.53  		fp = fopen(mpath, mode);
   62.54 -		free(mpath);
   62.55 +		SDL_free(mpath);
   62.56  	}
   62.57  #else
   62.58  	fp = fopen(file, mode);
   62.59 @@ -292,7 +292,7 @@
   62.60  {
   62.61  	SDL_RWops *area;
   62.62  
   62.63 -	area = (SDL_RWops *)malloc(sizeof *area);
   62.64 +	area = (SDL_RWops *)SDL_malloc(sizeof *area);
   62.65  	if ( area == NULL ) {
   62.66  		SDL_OutOfMemory();
   62.67  	}
   62.68 @@ -301,5 +301,5 @@
   62.69  
   62.70  void SDL_FreeRW(SDL_RWops *area)
   62.71  {
   62.72 -	free(area);
   62.73 +	SDL_free(area);
   62.74  }
    63.1 --- a/src/joystick/SDL_joystick.c	Mon Feb 06 17:28:04 2006 +0000
    63.2 +++ b/src/joystick/SDL_joystick.c	Tue Feb 07 06:59:48 2006 +0000
    63.3 @@ -51,11 +51,11 @@
    63.4  	status = SDL_SYS_JoystickInit();
    63.5  	if ( status >= 0 ) {
    63.6  		arraylen = (status+1)*sizeof(*SDL_joysticks);
    63.7 -		SDL_joysticks = (SDL_Joystick **)malloc(arraylen);
    63.8 +		SDL_joysticks = (SDL_Joystick **)SDL_malloc(arraylen);
    63.9  		if ( SDL_joysticks == NULL ) {
   63.10  			SDL_numjoysticks = 0;
   63.11  		} else {
   63.12 -			memset(SDL_joysticks, 0, arraylen);
   63.13 +			SDL_memset(SDL_joysticks, 0, arraylen);
   63.14  			SDL_numjoysticks = status;
   63.15  		}
   63.16  		status = 0;
   63.17 @@ -113,28 +113,28 @@
   63.18  	}
   63.19  
   63.20  	/* Create and initialize the joystick */
   63.21 -	joystick = (SDL_Joystick *)malloc((sizeof *joystick));
   63.22 +	joystick = (SDL_Joystick *)SDL_malloc((sizeof *joystick));
   63.23  	if ( joystick != NULL ) {
   63.24 -		memset(joystick, 0, (sizeof *joystick));
   63.25 +		SDL_memset(joystick, 0, (sizeof *joystick));
   63.26  		joystick->index = device_index;
   63.27  		if ( SDL_SYS_JoystickOpen(joystick) < 0 ) {
   63.28 -			free(joystick);
   63.29 +			SDL_free(joystick);
   63.30  			joystick = NULL;
   63.31  		} else {
   63.32  			if ( joystick->naxes > 0 ) {
   63.33 -				joystick->axes = (Sint16 *)malloc
   63.34 +				joystick->axes = (Sint16 *)SDL_malloc
   63.35  					(joystick->naxes*sizeof(Sint16));
   63.36  			}
   63.37  			if ( joystick->nhats > 0 ) {
   63.38 -				joystick->hats = (Uint8 *)malloc
   63.39 +				joystick->hats = (Uint8 *)SDL_malloc
   63.40  					(joystick->nhats*sizeof(Uint8));
   63.41  			}
   63.42  			if ( joystick->nballs > 0 ) {
   63.43 -				joystick->balls = (struct balldelta *)malloc
   63.44 +				joystick->balls = (struct balldelta *)SDL_malloc
   63.45  				  (joystick->nballs*sizeof(*joystick->balls));
   63.46  			}
   63.47  			if ( joystick->nbuttons > 0 ) {
   63.48 -				joystick->buttons = (Uint8 *)malloc
   63.49 +				joystick->buttons = (Uint8 *)SDL_malloc
   63.50  					(joystick->nbuttons*sizeof(Uint8));
   63.51  			}
   63.52  			if ( ((joystick->naxes > 0) && !joystick->axes)
   63.53 @@ -146,19 +146,19 @@
   63.54  				joystick = NULL;
   63.55  			}
   63.56  			if ( joystick->axes ) {
   63.57 -				memset(joystick->axes, 0,
   63.58 +				SDL_memset(joystick->axes, 0,
   63.59  					joystick->naxes*sizeof(Sint16));
   63.60  			}
   63.61  			if ( joystick->hats ) {
   63.62 -				memset(joystick->hats, 0,
   63.63 +				SDL_memset(joystick->hats, 0,
   63.64  					joystick->nhats*sizeof(Uint8));
   63.65  			}
   63.66  			if ( joystick->balls ) {
   63.67 -				memset(joystick->balls, 0,
   63.68 +				SDL_memset(joystick->balls, 0,
   63.69  				  joystick->nballs*sizeof(*joystick->balls));
   63.70  			}
   63.71  			if ( joystick->buttons ) {
   63.72 -				memset(joystick->buttons, 0,
   63.73 +				SDL_memset(joystick->buttons, 0,
   63.74  					joystick->nbuttons*sizeof(Uint8));
   63.75  			}
   63.76  		}
   63.77 @@ -375,7 +375,7 @@
   63.78  	/* Remove joystick from list */
   63.79  	for ( i=0; SDL_joysticks[i]; ++i ) {
   63.80  		if ( joystick == SDL_joysticks[i] ) {
   63.81 -			memcpy(&SDL_joysticks[i], &SDL_joysticks[i+1],
   63.82 +			SDL_memcpy(&SDL_joysticks[i], &SDL_joysticks[i+1],
   63.83  			       (SDL_numjoysticks-i)*sizeof(joystick));
   63.84  			break;
   63.85  		}
   63.86 @@ -386,18 +386,18 @@
   63.87  
   63.88  	/* Free the data associated with this joystick */
   63.89  	if ( joystick->axes ) {
   63.90 -		free(joystick->axes);
   63.91 +		SDL_free(joystick->axes);
   63.92  	}
   63.93  	if ( joystick->hats ) {
   63.94 -		free(joystick->hats);
   63.95 +		SDL_free(joystick->hats);
   63.96  	}
   63.97  	if ( joystick->balls ) {
   63.98 -		free(joystick->balls);
   63.99 +		SDL_free(joystick->balls);
  63.100  	}
  63.101  	if ( joystick->buttons ) {
  63.102 -		free(joystick->buttons);
  63.103 +		SDL_free(joystick->buttons);
  63.104  	}
  63.105 -	free(joystick);
  63.106 +	SDL_free(joystick);
  63.107  }
  63.108  
  63.109  void SDL_JoystickQuit(void)
  63.110 @@ -410,7 +410,7 @@
  63.111  	/* Quit the joystick setup */
  63.112  	SDL_SYS_JoystickQuit();
  63.113  	if ( SDL_joysticks ) {
  63.114 -		free(SDL_joysticks);
  63.115 +		SDL_free(SDL_joysticks);
  63.116  		SDL_joysticks = NULL;
  63.117  	}
  63.118  }
    64.1 --- a/src/joystick/SDL_sysjoystick.h	Mon Feb 06 17:28:04 2006 +0000
    64.2 +++ b/src/joystick/SDL_sysjoystick.h	Tue Feb 07 06:59:48 2006 +0000
    64.3 @@ -2,7 +2,7 @@
    64.4      SDL - Simple DirectMedia Layer
    64.5      Copyright (C) 1997-2006 Sam Lantinga
    64.6  
    64.7 -    This library is free software; you can redistribute it and/or
    64.8 +    This library is SDL_free software; you can redistribute it and/or
    64.9      modify it under the terms of the GNU Lesser General Public
   64.10      License as published by the Free Software Foundation; either
   64.11      version 2.1 of the License, or (at your option) any later version.
    65.1 --- a/src/joystick/amigaos/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    65.2 +++ b/src/joystick/amigaos/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    65.3 @@ -116,7 +116,7 @@
    65.4  	ULONG temp,i;
    65.5  	D(bug("Opening joystick %ld\n",joystick->index));
    65.6  
    65.7 -	if(!(joystick->hwdata=malloc(sizeof(struct joystick_hwdata))))
    65.8 +	if(!(joystick->hwdata=SDL_malloc(sizeof(struct joystick_hwdata))))
    65.9  		return -1;
   65.10  
   65.11  /* This loop is to check if the controller is a joypad */
   65.12 @@ -215,7 +215,7 @@
   65.13  void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
   65.14  {
   65.15  	if(joystick->hwdata)
   65.16 -		free(joystick->hwdata);
   65.17 +		SDL_free(joystick->hwdata);
   65.18  	return;
   65.19  }
   65.20  
    66.1 --- a/src/joystick/beos/SDL_bejoystick.cc	Mon Feb 06 17:28:04 2006 +0000
    66.2 +++ b/src/joystick/beos/SDL_bejoystick.cc	Tue Feb 07 06:59:48 2006 +0000
    66.3 @@ -67,8 +67,8 @@
    66.4  	/* Search for attached joysticks */
    66.5  	nports = joystick.CountDevices();
    66.6  	numjoysticks = 0;
    66.7 -	memset(SDL_joyport, 0, (sizeof SDL_joyport));
    66.8 -	memset(SDL_joyname, 0, (sizeof SDL_joyname));
    66.9 +	SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
   66.10 +	SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
   66.11  	for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) {
   66.12  		if ( joystick.GetDeviceName(i, name) == B_OK ) {
   66.13  			if ( joystick.Open(name) != B_ERROR ) {
   66.14 @@ -102,12 +102,12 @@
   66.15  
   66.16  	/* Create the joystick data structure */
   66.17  	joystick->hwdata = (struct joystick_hwdata *)
   66.18 -	                   malloc(sizeof(*joystick->hwdata));
   66.19 +	                   SDL_malloc(sizeof(*joystick->hwdata));
   66.20  	if ( joystick->hwdata == NULL ) {
   66.21  		SDL_OutOfMemory();
   66.22  		return(-1);
   66.23  	}
   66.24 -	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   66.25 +	SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   66.26  	stick = new BJoystick;
   66.27  	joystick->hwdata->stick = stick;
   66.28  
   66.29 @@ -127,9 +127,9 @@
   66.30  	joystick->nhats = stick->CountHats();
   66.31  
   66.32  	joystick->hwdata->new_axes = (int16 *)
   66.33 -	                  malloc(joystick->naxes*sizeof(int16));
   66.34 +	                  SDL_malloc(joystick->naxes*sizeof(int16));
   66.35  	joystick->hwdata->new_hats = (uint8 *)
   66.36 -	                  malloc(joystick->nhats*sizeof(uint8));
   66.37 +	                  SDL_malloc(joystick->nhats*sizeof(uint8));
   66.38  	if ( ! joystick->hwdata->new_hats || ! joystick->hwdata->new_axes ) {
   66.39  		SDL_OutOfMemory();
   66.40  		SDL_SYS_JoystickClose(joystick);
   66.41 @@ -208,12 +208,12 @@
   66.42  		joystick->hwdata->stick->Close();
   66.43  		delete joystick->hwdata->stick;
   66.44  		if ( joystick->hwdata->new_hats ) {
   66.45 -			free(joystick->hwdata->new_hats);
   66.46 +			SDL_free(joystick->hwdata->new_hats);
   66.47  		}
   66.48  		if ( joystick->hwdata->new_axes ) {
   66.49 -			free(joystick->hwdata->new_axes);
   66.50 +			SDL_free(joystick->hwdata->new_axes);
   66.51  		}
   66.52 -		free(joystick->hwdata);
   66.53 +		SDL_free(joystick->hwdata);
   66.54  		joystick->hwdata = NULL;
   66.55  	}
   66.56  }
   66.57 @@ -224,12 +224,12 @@
   66.58  	int i;
   66.59  
   66.60  	for ( i=0; SDL_joyport[i]; ++i ) {
   66.61 -		free(SDL_joyport[i]);
   66.62 +		SDL_free(SDL_joyport[i]);
   66.63  	}
   66.64  	SDL_joyport[0] = NULL;
   66.65  
   66.66  	for ( i=0; SDL_joyname[i]; ++i ) {
   66.67 -		free(SDL_joyname[i]);
   66.68 +		SDL_free(SDL_joyname[i]);
   66.69  	}
   66.70  	SDL_joyname[0] = NULL;
   66.71  }
    67.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    67.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    67.3 @@ -139,8 +139,8 @@
    67.4  
    67.5  	SDL_numjoysticks = 0;
    67.6  
    67.7 -	memset(joynames, 0, sizeof(joynames));
    67.8 -	memset(joydevnames, 0, sizeof(joydevnames));
    67.9 +	SDL_memset(joynames, 0, sizeof(joynames));
   67.10 +	SDL_memset(joydevnames, 0, sizeof(joydevnames));
   67.11  
   67.12  	for (i = 0; i < MAX_UHID_JOYS; i++) {
   67.13  		SDL_Joystick nj;
   67.14 @@ -154,7 +154,7 @@
   67.15  			SDL_SYS_JoystickClose(&nj);
   67.16  			SDL_numjoysticks++;
   67.17  		} else {
   67.18 -			free(joynames[nj.index]);
   67.19 +			SDL_free(joynames[nj.index]);
   67.20  			joynames[nj.index] = NULL;
   67.21  		}
   67.22  	}
   67.23 @@ -241,7 +241,7 @@
   67.24  		return (-1);
   67.25  	}
   67.26  
   67.27 -	hw = (struct joystick_hwdata *)malloc(sizeof(struct joystick_hwdata));
   67.28 +	hw = (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata));
   67.29  	if (hw == NULL) {
   67.30  		SDL_OutOfMemory();
   67.31  		close(fd);
   67.32 @@ -250,7 +250,7 @@
   67.33  	joy->hwdata = hw;
   67.34  	hw->fd = fd;
   67.35  	hw->path = strdup(path);
   67.36 -	if (! strncmp(path, "/dev/joy", 8)) {
   67.37 +	if (! SDL_strncmp(path, "/dev/joy", 8)) {
   67.38  		hw->type = BSDJOY_JOY;
   67.39  		joy->naxes = 2;
   67.40  		joy->nbuttons = 2;
   67.41 @@ -311,7 +311,7 @@
   67.42  				case HUG_JOYSTICK:
   67.43  				case HUG_GAME_PAD:
   67.44  					s = hid_usage_in_page(hitem.usage);
   67.45 -					sp = malloc(strlen(s) + 5);
   67.46 +					sp = SDL_malloc(SDL_strlen(s) + 5);
   67.47  					sprintf(sp, "%s (%d)", s,
   67.48  					    joy->index);
   67.49  					joydevnames[joy->index] = sp;
   67.50 @@ -351,8 +351,8 @@
   67.51  	return (0);
   67.52  usberr:
   67.53  	close(hw->fd);
   67.54 -	free(hw->path);
   67.55 -	free(hw);
   67.56 +	SDL_free(hw->path);
   67.57 +	SDL_free(hw);
   67.58  	return (-1);
   67.59  }
   67.60  
   67.61 @@ -482,13 +482,13 @@
   67.62  void
   67.63  SDL_SYS_JoystickClose(SDL_Joystick *joy)
   67.64  {
   67.65 -	if (strncmp(joy->hwdata->path, "/dev/joy", 8))	{
   67.66 +	if (SDL_strncmp(joy->hwdata->path, "/dev/joy", 8))	{
   67.67  		report_free(&joy->hwdata->inreport);
   67.68  		hid_dispose_report_desc(joy->hwdata->repdesc);
   67.69  	}
   67.70  	close(joy->hwdata->fd);
   67.71 -	free(joy->hwdata->path);
   67.72 -	free(joy->hwdata);
   67.73 +	SDL_free(joy->hwdata->path);
   67.74 +	SDL_free(joy->hwdata);
   67.75  
   67.76  	return;
   67.77  }
   67.78 @@ -500,9 +500,9 @@
   67.79  
   67.80  	for (i = 0; i < MAX_JOYS; i++) {
   67.81  		if (joynames[i] != NULL)
   67.82 -			free(joynames[i]);
   67.83 +			SDL_free(joynames[i]);
   67.84  		if (joydevnames[i] != NULL)
   67.85 -			free(joydevnames[i]);
   67.86 +			SDL_free(joydevnames[i]);
   67.87  	}
   67.88  
   67.89  	return;
   67.90 @@ -538,7 +538,7 @@
   67.91  	r->size = len;
   67.92  
   67.93  	if (r->size > 0) {
   67.94 -		r->buf = malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) +
   67.95 +		r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) +
   67.96  		    r->size);
   67.97  		if (r->buf == NULL) {
   67.98  			SDL_OutOfMemory();
   67.99 @@ -556,7 +556,7 @@
  67.100  report_free(struct report *r)
  67.101  {
  67.102  	if (r->buf != NULL) {
  67.103 -		free(r->buf);
  67.104 +		SDL_free(r->buf);
  67.105  	}
  67.106  	r->status = SREPORT_UNINIT;
  67.107  }
    68.1 --- a/src/joystick/dc/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    68.2 +++ b/src/joystick/dc/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    68.3 @@ -90,13 +90,13 @@
    68.4  int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
    68.5  {
    68.6  	/* allocate memory for system specific hardware data */
    68.7 -	joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
    68.8 +	joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
    68.9  	if (joystick->hwdata == NULL)
   68.10  	{
   68.11  		SDL_OutOfMemory();
   68.12  		return(-1);
   68.13  	}
   68.14 -	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   68.15 +	SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   68.16  
   68.17  	/* fill nbuttons, naxes, and nhats fields */
   68.18  	joystick->nbuttons = MAX_BUTTONS;
   68.19 @@ -182,7 +182,7 @@
   68.20  {
   68.21  	if (joystick->hwdata != NULL) {
   68.22  		/* free system specific hardware data */
   68.23 -		free(joystick->hwdata);
   68.24 +		SDL_free(joystick->hwdata);
   68.25  	}
   68.26  }
   68.27  
    69.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    69.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    69.3 @@ -23,7 +23,7 @@
    69.4  /* This is the system specific header for the SDL joystick API */
    69.5  
    69.6  #include <stdio.h>		/* For the definition of NULL */
    69.7 -#include <stdlib.h>		/* For getenv() prototype */
    69.8 +#include <stdlib.h>		/* For SDL_getenv() prototype */
    69.9  #include <string.h>
   69.10  #include <sys/stat.h>
   69.11  #include <unistd.h>
   69.12 @@ -187,9 +187,9 @@
   69.13  {
   69.14  	char *newstring;
   69.15  
   69.16 -	newstring = (char *)malloc(strlen(string)+1);
   69.17 +	newstring = (char *)SDL_malloc(SDL_strlen(string)+1);
   69.18  	if ( newstring ) {
   69.19 -		strcpy(newstring, string);
   69.20 +		SDL_strcpy(newstring, string);
   69.21  	}
   69.22  	return(newstring);
   69.23  }
   69.24 @@ -209,7 +209,7 @@
   69.25  
   69.26        if (name) {
   69.27           for(j = 0; j < SDL_TABLESIZE(joystick_logicalmap); j++) {
   69.28 -            if (!strcmp(name, joystick_logicalmap[j].name)) {
   69.29 +            if (!SDL_strcmp(name, joystick_logicalmap[j].name)) {
   69.30  
   69.31                 prev = i;
   69.32                 SDL_joylist[prev].map = joystick_logicalmap+j;
   69.33 @@ -243,7 +243,7 @@
   69.34        "20212223242526272829303132";
   69.35     const char* suffix;
   69.36  
   69.37 -   slen = strlen(namebuf);
   69.38 +   slen = SDL_strlen(namebuf);
   69.39  
   69.40     suffix = NULL;
   69.41  
   69.42 @@ -306,8 +306,8 @@
   69.43  	numjoysticks = 0;
   69.44  
   69.45  	/* First see if the user specified a joystick to use */
   69.46 -	if ( getenv("SDL_JOYSTICK_DEVICE") != NULL ) {
   69.47 -		strncpy(path, getenv("SDL_JOYSTICK_DEVICE"), sizeof(path));
   69.48 +	if ( SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL ) {
   69.49 +		SDL_strncpy(path, SDL_getenv("SDL_JOYSTICK_DEVICE"), sizeof(path));
   69.50  		path[sizeof(path)-1] = '\0';
   69.51  		if ( stat(path, &sb) == 0 ) {
   69.52  			fd = open(path, O_RDONLY, 0);
   69.53 @@ -426,7 +426,7 @@
   69.54  {
   69.55  	int i;
   69.56  
   69.57 -	joystick->hwdata->hats = (struct hwdata_hat *)malloc(
   69.58 +	joystick->hwdata->hats = (struct hwdata_hat *)SDL_malloc(
   69.59  		joystick->nhats * sizeof(struct hwdata_hat));
   69.60  	if ( joystick->hwdata->hats == NULL ) {
   69.61  		return(-1);
   69.62 @@ -442,7 +442,7 @@
   69.63  {
   69.64  	int i;
   69.65  
   69.66 -	joystick->hwdata->balls = (struct hwdata_ball *)malloc(
   69.67 +	joystick->hwdata->balls = (struct hwdata_ball *)SDL_malloc(
   69.68  		joystick->nballs * sizeof(struct hwdata_ball));
   69.69  	if ( joystick->hwdata->balls == NULL ) {
   69.70  		return(-1);
   69.71 @@ -481,8 +481,8 @@
   69.72  	old_axes = joystick->naxes;
   69.73  
   69.74  	/* Generic analog joystick support */
   69.75 -	if ( strstr(name, "Analog") == name && strstr(name, "-hat") ) {
   69.76 -		if ( sscanf(name,"Analog %d-axis %*d-button %d-hat",
   69.77 +	if ( SDL_strstr(name, "Analog") == name && SDL_strstr(name, "-hat") ) {
   69.78 +		if ( SDL_sscanf(name,"Analog %d-axis %*d-button %d-hat",
   69.79  			&tmp_naxes, &tmp_nhats) == 2 ) {
   69.80  
   69.81  			joystick->naxes = tmp_naxes;
   69.82 @@ -494,7 +494,7 @@
   69.83  
   69.84  	/* Special joystick support */
   69.85  	for ( i=0; i < SDL_TABLESIZE(special_joysticks); ++i ) {
   69.86 -		if ( strcmp(name, special_joysticks[i].name) == 0 ) {
   69.87 +		if ( SDL_strcmp(name, special_joysticks[i].name) == 0 ) {
   69.88  
   69.89  			joystick->naxes = special_joysticks[i].naxes;
   69.90  			joystick->nhats = special_joysticks[i].nhats;
   69.91 @@ -506,16 +506,16 @@
   69.92  	}
   69.93  
   69.94  	/* User environment joystick support */
   69.95 -	if ( (env = getenv("SDL_LINUX_JOYSTICK")) ) {
   69.96 -		strcpy(env_name, "");
   69.97 -		if ( *env == '\'' && sscanf(env, "'%[^']s'", env_name) == 1 )
   69.98 -			env += strlen(env_name)+2;
   69.99 -		else if ( sscanf(env, "%s", env_name) == 1 )
  69.100 -			env += strlen(env_name);
  69.101 +	if ( (env = SDL_getenv("SDL_LINUX_JOYSTICK")) ) {
  69.102 +		SDL_strcpy(env_name, "");
  69.103 +		if ( *env == '\'' && SDL_sscanf(env, "'%[^']s'", env_name) == 1 )
  69.104 +			env += SDL_strlen(env_name)+2;
  69.105 +		else if ( SDL_sscanf(env, "%s", env_name) == 1 )
  69.106 +			env += SDL_strlen(env_name);
  69.107  
  69.108 -		if ( strcmp(name, env_name) == 0 ) {
  69.109 +		if ( SDL_strcmp(name, env_name) == 0 ) {
  69.110  
  69.111 -			if ( sscanf(env, "%d %d %d", &tmp_naxes, &tmp_nhats,
  69.112 +			if ( SDL_sscanf(env, "%d %d %d", &tmp_naxes, &tmp_nhats,
  69.113  				&tmp_nballs) == 3 ) {
  69.114  
  69.115  				joystick->naxes = tmp_naxes;
  69.116 @@ -697,13 +697,13 @@
  69.117  		return(-1);
  69.118  	}
  69.119  	joystick->hwdata = (struct joystick_hwdata *)
  69.120 -	                   malloc(sizeof(*joystick->hwdata));
  69.121 +	                   SDL_malloc(sizeof(*joystick->hwdata));
  69.122  	if ( joystick->hwdata == NULL ) {
  69.123  		SDL_OutOfMemory();
  69.124  		close(fd);
  69.125  		return(-1);
  69.126  	}
  69.127 -	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
  69.128 +	SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
  69.129  	joystick->hwdata->fd = fd;
  69.130  
  69.131  	/* Set the joystick to non-blocking read mode */
  69.132 @@ -1064,12 +1064,12 @@
  69.133  #endif
  69.134  		close(joystick->hwdata->fd);
  69.135  		if ( joystick->hwdata->hats ) {
  69.136 -			free(joystick->hwdata->hats);
  69.137 +			SDL_free(joystick->hwdata->hats);
  69.138  		}
  69.139  		if ( joystick->hwdata->balls ) {
  69.140 -			free(joystick->hwdata->balls);
  69.141 +			SDL_free(joystick->hwdata->balls);
  69.142  		}
  69.143 -		free(joystick->hwdata);
  69.144 +		SDL_free(joystick->hwdata);
  69.145  		joystick->hwdata = NULL;
  69.146  	}
  69.147  }
  69.148 @@ -1080,7 +1080,7 @@
  69.149  	int i;
  69.150  
  69.151  	for ( i=0; SDL_joylist[i].fname; ++i ) {
  69.152 -		free(SDL_joylist[i].fname);
  69.153 +		SDL_free(SDL_joylist[i].fname);
  69.154  	}
  69.155  	SDL_joylist[0].fname = NULL;
  69.156  }
    70.1 --- a/src/joystick/macos/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    70.2 +++ b/src/joystick/macos/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    70.3 @@ -137,7 +137,7 @@
    70.4      if ( len >= sizeof(name) ) {
    70.5          len = (sizeof(name) - 1);
    70.6      }
    70.7 -    memcpy(name, &SYS_DevDef[index].deviceName[1], len);
    70.8 +    SDL_memcpy(name, &SYS_DevDef[index].deviceName[1], len);
    70.9      name[len] = '\0';
   70.10  
   70.11      return name;
   70.12 @@ -161,14 +161,14 @@
   70.13      index = joystick->index;
   70.14  
   70.15      /* allocate memory for system specific hardware data */
   70.16 -    joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
   70.17 +    joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
   70.18      if (joystick->hwdata == NULL)
   70.19      {
   70.20  		SDL_OutOfMemory();
   70.21  		return(-1);
   70.22      }
   70.23 -    memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   70.24 -    strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index));
   70.25 +    SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   70.26 +    SDL_strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index));
   70.27      joystick->name = joystick->hwdata->name;
   70.28  
   70.29      ISpElementList_ExtractByKind(
    71.1 --- a/src/joystick/mint/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    71.2 +++ b/src/joystick/mint/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    71.3 @@ -162,13 +162,13 @@
    71.4  {
    71.5  	int i;
    71.6  	unsigned long cookie_mch;
    71.7 -	const char *envr=getenv("SDL_JOYSTICK_ATARI");
    71.8 +	const char *envr=SDL_getenv("SDL_JOYSTICK_ATARI");
    71.9  	
   71.10  #define TEST_JOY_ENABLED(env,idstring,num) \
   71.11 -	if (strstr(env,idstring"-off")) { \
   71.12 +	if (SDL_strstr(env,idstring"-off")) { \
   71.13  		atarijoysticks[num].enabled=SDL_FALSE; \
   71.14  	} \
   71.15 -	if (strstr(env,idstring"-on")) { \
   71.16 +	if (SDL_strstr(env,idstring"-on")) { \
   71.17  		atarijoysticks[num].enabled=SDL_TRUE; \
   71.18  	}
   71.19  
    72.1 --- a/src/joystick/os2/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    72.2 +++ b/src/joystick/os2/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    72.3 @@ -326,14 +326,14 @@
    72.4  int i;			/* Generic Counter */
    72.5  
    72.6  /* allocate memory for system specific hardware data */
    72.7 -joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
    72.8 +joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
    72.9  if (joystick->hwdata == NULL)
   72.10  	{
   72.11  	SDL_OutOfMemory();
   72.12  	return(-1);
   72.13  	}
   72.14  /* Reset Hardware Data */
   72.15 -memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   72.16 +SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   72.17  
   72.18  /* ShortCut Pointer */
   72.19  index = joystick->index;
   72.20 @@ -517,7 +517,7 @@
   72.21  if (joystick->hwdata != NULL)
   72.22  	{
   72.23  	/* free system specific hardware data */
   72.24 -	free(joystick->hwdata);
   72.25 +	SDL_free(joystick->hwdata);
   72.26  	}
   72.27  }
   72.28  
   72.29 @@ -602,7 +602,7 @@
   72.30  char *joyenv;				/* Pointer to tested character */
   72.31  char tempnumber[5];		/* Temporary place to put numeric texts */
   72.32  
   72.33 -joyenv = getenv("SDL_OS2_JOYSTICK");
   72.34 +joyenv = SDL_getenv("SDL_OS2_JOYSTICK");
   72.35  if (joyenv == NULL) return 0;
   72.36  /* Joystick Environment is defined! */
   72.37  while (*joyenv==' ' && *joyenv!=0) joyenv++; /* jump spaces... */
    73.1 --- a/src/joystick/riscos/SDL_sysjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    73.2 +++ b/src/joystick/riscos/SDL_sysjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    73.3 @@ -89,7 +89,7 @@
    73.4  {
    73.5  	_kernel_swi_regs regs;
    73.6  
    73.7 -	if(!(joystick->hwdata=malloc(sizeof(struct joystick_hwdata))))
    73.8 +	if(!(joystick->hwdata=SDL_malloc(sizeof(struct joystick_hwdata))))
    73.9  		return -1;
   73.10  
   73.11  	regs.r[0] = joystick->index;
   73.12 @@ -161,7 +161,7 @@
   73.13  void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
   73.14  {
   73.15  	if(joystick->hwdata)
   73.16 -		free(joystick->hwdata);
   73.17 +		SDL_free(joystick->hwdata);
   73.18  	return;
   73.19  }
   73.20  
    74.1 --- a/src/joystick/win32/SDL_mmjoystick.c	Mon Feb 06 17:28:04 2006 +0000
    74.2 +++ b/src/joystick/win32/SDL_mmjoystick.c	Tue Feb 07 06:59:48 2006 +0000
    74.3 @@ -82,7 +82,7 @@
    74.4  	unsigned char regvalue[256];
    74.5  	unsigned char regname[256];
    74.6  
    74.7 -	snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
    74.8 +	SDL_snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
    74.9  		REGSTR_PATH_JOYCONFIG,
   74.10  		szRegKey,
   74.11  		REGSTR_KEY_JOYCURR);
   74.12 @@ -95,7 +95,7 @@
   74.13  			joystick's properties
   74.14  		*/
   74.15  		regsize = sizeof(regname);
   74.16 -		snprintf((char *) regvalue, SDL_arraysize(regvalue),
   74.17 +		SDL_snprintf((char *) regvalue, SDL_arraysize(regvalue),
   74.18  			"Joystick%d%s", index+1,
   74.19  			REGSTR_VAL_JOYOEMNAME);
   74.20  		regresult = RegQueryValueExA(hKey,
   74.21 @@ -105,7 +105,7 @@
   74.22  		if (regresult == ERROR_SUCCESS)
   74.23  		{
   74.24  			/* open that registry key */
   74.25 -			snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s",
   74.26 +			SDL_snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s",
   74.27  				REGSTR_PATH_JOYOEM, regname);
   74.28  			regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
   74.29  				(char *) regkey, 0, KEY_READ, &hKey);
   74.30 @@ -124,7 +124,7 @@
   74.31  						allocate enough memory
   74.32  						for the OEM name text ...
   74.33  					*/
   74.34 -					name = (char *) malloc(regsize);
   74.35 +					name = (char *) SDL_malloc(regsize);
   74.36  					/* ... and read it from the registry */
   74.37  					regresult =
   74.38  						RegQueryValueExA(hKey,
   74.39 @@ -227,13 +227,13 @@
   74.40  	axis_max[5] = SYS_Joystick[index].wVmax;
   74.41  
   74.42  	/* allocate memory for system specific hardware data */
   74.43 -	joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
   74.44 +	joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
   74.45  	if (joystick->hwdata == NULL)
   74.46  	{
   74.47  		SDL_OutOfMemory();
   74.48  		return(-1);
   74.49  	}
   74.50 -	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   74.51 +	SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
   74.52  
   74.53  	/* set hardware data */
   74.54  	joystick->hwdata->id = SYS_JoystickID[index];
   74.55 @@ -359,7 +359,7 @@
   74.56  {
   74.57  	if (joystick->hwdata != NULL) {
   74.58  		/* free system specific hardware data */
   74.59 -		free(joystick->hwdata);
   74.60 +		SDL_free(joystick->hwdata);
   74.61  	}
   74.62  }
   74.63  
   74.64 @@ -369,7 +369,7 @@
   74.65  	int i;
   74.66  	for (i = 0; i < MAX_JOYSTICKS; i++) {
   74.67  		if ( SYS_JoystickName[i] != NULL ) {
   74.68 -			free(SYS_JoystickName[i]);
   74.69 +			SDL_free(SYS_JoystickName[i]);
   74.70  		}
   74.71  	}
   74.72  }
   74.73 @@ -406,14 +406,14 @@
   74.74  		break;
   74.75  
   74.76  		default:
   74.77 -			snprintf(errbuf, SDL_arraysize(errbuf),
   74.78 +			SDL_snprintf(errbuf, SDL_arraysize(errbuf),
   74.79  			         "%s: Unknown Multimedia system error: 0x%x",
   74.80  								function, code);
   74.81  		break;
   74.82  	}
   74.83  
   74.84  	if ( ! errbuf[0] ) {
   74.85 -		snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
   74.86 +		SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
   74.87  	}
   74.88  	SDL_SetError("%s", errbuf);
   74.89  }
    75.1 --- a/src/loadso/macos/SDL_loadso.c	Mon Feb 06 17:28:04 2006 +0000
    75.2 +++ b/src/loadso/macos/SDL_loadso.c	Tue Feb 07 06:59:48 2006 +0000
    75.3 @@ -52,7 +52,7 @@
    75.4  	OSErr error;
    75.5  	char psofile[512];
    75.6  
    75.7 -	strncpy(psofile, sofile, SDL_TABLESIZE(psofile));
    75.8 +	SDL_strncpy(psofile, sofile, SDL_TABLESIZE(psofile));
    75.9  	psofile[SDL_TABLESIZE(psofile)-1] = '\0';
   75.10  	error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch,
   75.11  			kLoadCFrag, &library_id, &mainAddr, errName);
   75.12 @@ -90,7 +90,7 @@
   75.13  	CFragConnectionID library_id = (CFragConnectionID)handle;
   75.14  	char pname[512];
   75.15  
   75.16 -	strncpy(pname, name, SDL_TABLESIZE(pname));
   75.17 +	SDL_strncpy(pname, name, SDL_TABLESIZE(pname));
   75.18  	pname[SDL_TABLESIZE(pname)-1] = '\0';
   75.19  	if ( FindSymbol(library_id, C2PStr(pname),
   75.20  	                (char **)&symbol, &class) != noErr ) {
    76.1 --- a/src/loadso/macosx/SDL_loadso.c	Mon Feb 06 17:28:04 2006 +0000
    76.2 +++ b/src/loadso/macosx/SDL_loadso.c	Tue Feb 07 06:59:48 2006 +0000
    76.3 @@ -282,7 +282,7 @@
    76.4  	va_start(arg, str);
    76.5  	tss = pthread_getspecific(dlerror_key);
    76.6  	err_str = tss->errstr;
    76.7 -	strncpy(err_str, "dlcompat: ", ERR_STR_LEN);
    76.8 +	SDL_strncpy(err_str, "dlcompat: ", ERR_STR_LEN);
    76.9  	vsnprintf(err_str + 10, ERR_STR_LEN - 10, str, arg);
   76.10  	va_end(arg);
   76.11  	debug("ERROR: %s\n", err_str);
   76.12 @@ -298,7 +298,7 @@
   76.13  
   76.14  static const char *safegetenv(const char *s)
   76.15  {
   76.16 -	const char *ss = getenv(s);
   76.17 +	const char *ss = SDL_getenv(s);
   76.18  	return ss ? ss : "";
   76.19  }
   76.20  
   76.21 @@ -338,7 +338,7 @@
   76.22  	debug("Module name: %s", mod_name);
   76.23  	for (i = 0; i < count; i++)
   76.24  	{
   76.25 -		if (!strcmp(mod_name, _dyld_get_image_name(i)))
   76.26 +		if (!SDL_strcmp(mod_name, _dyld_get_image_name(i)))
   76.27  		{
   76.28  			mh = _dyld_get_image_header(i);
   76.29  			break;
   76.30 @@ -362,14 +362,14 @@
   76.31  	static char *buf=NULL;
   76.32  	const char *ldlp = safegetenv("LD_LIBRARY_PATH");
   76.33  	const char *dyldlp = safegetenv("DYLD_LIBRARY_PATH");
   76.34 -	const char *stdpath = getenv("DYLD_FALLBACK_LIBRARY_PATH");
   76.35 +	const char *stdpath = SDL_getenv("DYLD_FALLBACK_LIBRARY_PATH");
   76.36  	if (!stdpath)
   76.37  		stdpath = "/usr/local/lib:/lib:/usr/lib";
   76.38  	if (!buf)
   76.39  	{	
   76.40 -		buf_size = strlen(ldlp) + strlen(dyldlp) + strlen(stdpath) + 4;
   76.41 -		buf = malloc(buf_size);
   76.42 -		snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""),
   76.43 +		buf_size = SDL_strlen(ldlp) + SDL_strlen(dyldlp) + SDL_strlen(stdpath) + 4;
   76.44 +		buf = SDL_malloc(buf_size);
   76.45 +		SDL_snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""),
   76.46  				 stdpath, '\0');
   76.47  	}
   76.48  	return buf;
   76.49 @@ -383,7 +383,7 @@
   76.50  	static int end = 0;
   76.51  	static int numsize = MAX_SEARCH_PATHS;
   76.52  	static char **tmp;
   76.53 -	/* So we can call free() in the "destructor" we use i=-1 to return the alloc'd array */
   76.54 +	/* So we can call SDL_free() in the "destructor" we use i=-1 to return the alloc'd array */
   76.55  	if (i == -1)
   76.56  	{
   76.57  		return (const char*)path;
   76.58 @@ -400,8 +400,8 @@
   76.59  		tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **));
   76.60  		if (tmp)
   76.61  		{
   76.62 -			memcpy(tmp, path, sizeof(char **) * numsize);
   76.63 -			free(path);
   76.64 +			SDL_memcpy(tmp, path, sizeof(char **) * numsize);
   76.65 +			SDL_free(path);
   76.66  			path = tmp;
   76.67  			numsize += MAX_SEARCH_PATHS;
   76.68  		}
   76.69 @@ -428,7 +428,7 @@
   76.70  	const char *path = getSearchPath(i);
   76.71  	if (path)
   76.72  	{
   76.73 -		snprintf(buf, PATH_MAX, "%s/%s", path, file);
   76.74 +		SDL_snprintf(buf, PATH_MAX, "%s/%s", path, file);
   76.75  	}
   76.76  	return path ? buf : 0;
   76.77  }
   76.78 @@ -446,7 +446,7 @@
   76.79  	*fullPath = file;
   76.80  	if (0 == stat(file, &sbuf))
   76.81  		return &sbuf;
   76.82 -	if (strchr(file, '/'))
   76.83 +	if (SDL_strchr(file, '/'))
   76.84  		return 0;				/* If the path had a / we don't look in env var places */
   76.85  	fileName = NULL;
   76.86  	if (!fileName)
   76.87 @@ -567,7 +567,7 @@
   76.88  		for (j = 0; j < i; j++)
   76.89  		{
   76.90  			id = _dyld_get_image_name(j);
   76.91 -			if (!strcmp(id, name))
   76.92 +			if (!SDL_strcmp(id, name))
   76.93  			{
   76.94  				mh = _dyld_get_image_header(j);
   76.95  				break;
   76.96 @@ -620,7 +620,7 @@
   76.97  	return nssym;
   76.98  }
   76.99  
  76.100 -/* Up to the caller to free() returned string */
  76.101 +/* Up to the caller to SDL_free() returned string */
  76.102  static inline const char *dyld_error_str()
  76.103  {
  76.104  	NSLinkEditErrors dylder;
  76.105 @@ -629,10 +629,10 @@
  76.106  	const char *dyldfile;
  76.107  	const char* retStr = NULL;
  76.108  	NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr);
  76.109 -	if (dylderrstr && strlen(dylderrstr))
  76.110 +	if (dylderrstr && SDL_strlen(dylderrstr))
  76.111  	{
  76.112 -		retStr = malloc(strlen(dylderrstr) +1);
  76.113 -		strcpy((char*)retStr,dylderrstr);
  76.114 +		retStr = SDL_malloc(SDL_strlen(dylderrstr) +1);
  76.115 +		SDL_strcpy((char*)retStr,dylderrstr);
  76.116  	}
  76.117  	return retStr;
  76.118  }
  76.119 @@ -735,21 +735,21 @@
  76.120  			else
  76.121  			{
  76.122  				if (savedErrorStr)
  76.123 -					free((char*)savedErrorStr);			
  76.124 -				savedErrorStr = malloc(256);
  76.125 -				snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol);	
  76.126 +					SDL_free((char*)savedErrorStr);			
  76.127 +				savedErrorStr = SDL_malloc(256);
  76.128 +				SDL_snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol);	
  76.129  			}
  76.130  		}
  76.131  	}
  76.132  	/* Error reporting */
  76.133  	if (!nssym)
  76.134  	{
  76.135 -		if (!savedErrorStr || !strlen(savedErrorStr))
  76.136 +		if (!savedErrorStr || !SDL_strlen(savedErrorStr))
  76.137  		{
  76.138  			if (savedErrorStr)
  76.139 -				free((char*)savedErrorStr);
  76.140 -			savedErrorStr = malloc(256);
  76.141 -			snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol);
  76.142 +				SDL_free((char*)savedErrorStr);
  76.143 +			savedErrorStr = SDL_malloc(256);
  76.144 +			SDL_snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol);
  76.145  		}
  76.146  		if (canSetError)
  76.147  		{
  76.148 @@ -760,7 +760,7 @@
  76.149  			debug(savedErrorStr);
  76.150  		}
  76.151  		if (savedErrorStr)
  76.152 -			free((char*)savedErrorStr);
  76.153 +			SDL_free((char*)savedErrorStr);
  76.154  		return NULL;
  76.155  	}
  76.156  	return NSAddressOfSymbol(nssym);
  76.157 @@ -839,13 +839,13 @@
  76.158  		if (!(dls->module))
  76.159  		{
  76.160  			NSLinkEditError(&ler, &lerno, &file, &errstr);
  76.161 -			if (!errstr || (!strlen(errstr)))
  76.162 +			if (!errstr || (!SDL_strlen(errstr)))
  76.163  				error("Can't open this file type");
  76.164  			else
  76.165  				error(errstr);
  76.166  			if ((dls->flags & DL_IN_LIST) == 0)
  76.167  			{
  76.168 -				free(dls);
  76.169 +				SDL_free(dls);
  76.170  			}
  76.171  			return NULL;
  76.172  		}
  76.173 @@ -867,7 +867,7 @@
  76.174  		NSLinkEditError(&ler, &lerno, &file, &errstr);
  76.175  		if ((dls->flags & DL_IN_LIST) == 0)
  76.176  		{
  76.177 -			free(dls);
  76.178 +			SDL_free(dls);
  76.179  		}
  76.180  		error(errstr);
  76.181  		return NULL;
  76.182 @@ -917,7 +917,7 @@
  76.183  
  76.184  static void dlerrorfree(void *data)
  76.185  {
  76.186 -	free(data);
  76.187 +	SDL_free(data);
  76.188  }
  76.189  
  76.190  /* We kind of want a recursive lock here, but meet a little trouble
  76.191 @@ -932,7 +932,7 @@
  76.192  	tss = pthread_getspecific(dlerror_key);
  76.193  	if (!tss)
  76.194  	{
  76.195 -		tss = malloc(sizeof(struct dlthread));
  76.196 +		tss = SDL_malloc(sizeof(struct dlthread));
  76.197  		tss->lockcnt = 0;
  76.198  		tss->errset = 0;
  76.199  		if (pthread_setspecific(dlerror_key, tss))
  76.200 @@ -1010,16 +1010,16 @@
  76.201  #if !FINK_BUILD
  76.202  static void *SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol)
  76.203  {
  76.204 -	int sym_len = strlen(symbol);
  76.205 +	int sym_len = SDL_strlen(symbol);
  76.206  	void *value = NULL;
  76.207  	char *malloc_sym = NULL;
  76.208  	dolock();
  76.209 -	malloc_sym = malloc(sym_len + 2);
  76.210 +	malloc_sym = SDL_malloc(sym_len + 2);
  76.211  	if (malloc_sym)
  76.212  	{
  76.213  		sprintf(malloc_sym, "_%s", symbol);
  76.214  		value = dlsymIntern(handle, malloc_sym, 1);
  76.215 -		free(malloc_sym);
  76.216 +		SDL_free(malloc_sym);
  76.217  	}
  76.218  	else
  76.219  	{
  76.220 @@ -1056,15 +1056,15 @@
  76.221   *	the underscore always, or not at all. These global functions need to go away
  76.222   *	for opendarwin.
  76.223   */
  76.224 -	int sym_len = strlen(symbol);
  76.225 +	int sym_len = SDL_strlen(symbol);
  76.226  	void *value = NULL;
  76.227  	char *malloc_sym = NULL;
  76.228 -	malloc_sym = malloc(sym_len + 2);
  76.229 +	malloc_sym = SDL_malloc(sym_len + 2);
  76.230  	if (malloc_sym)
  76.231  	{
  76.232  		sprintf(malloc_sym, "_%s", symbol);
  76.233  		value = dlsymIntern(handle, malloc_sym, 1);
  76.234 -		free(malloc_sym);
  76.235 +		SDL_free(malloc_sym);
  76.236  	}
  76.237  	else
  76.238  	{
  76.239 @@ -1273,7 +1273,7 @@
  76.240  	{
  76.241  		if (LC_SEGMENT == lc->cmd)
  76.242  		{
  76.243 -			if (!strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT"))
  76.244 +			if (!SDL_strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT"))
  76.245  				break;
  76.246  		}
  76.247  	}
  76.248 @@ -1341,15 +1341,15 @@
  76.249  		void *d;
  76.250  		dlfunc_t f;
  76.251  	} rv;
  76.252 -	int sym_len = strlen(symbol);
  76.253 +	int sym_len = SDL_strlen(symbol);
  76.254  	char *malloc_sym = NULL;
  76.255  	dolock();
  76.256 -	malloc_sym = malloc(sym_len + 2);
  76.257 +	malloc_sym = SDL_malloc(sym_len + 2);
  76.258  	if (malloc_sym)
  76.259  	{
  76.260  		sprintf(malloc_sym, "_%s", symbol);
  76.261  		rv.d = dlsymIntern(handle, malloc_sym, 1);
  76.262 -		free(malloc_sym);
  76.263 +		SDL_free(malloc_sym);
  76.264  	}
  76.265  	else
  76.266  	{
    77.1 --- a/src/loadso/windows/SDL_loadso.c	Mon Feb 06 17:28:04 2006 +0000
    77.2 +++ b/src/loadso/windows/SDL_loadso.c	Tue Feb 07 06:59:48 2006 +0000
    77.3 @@ -45,8 +45,8 @@
    77.4  #if defined(_WIN32_WCE)
    77.5  	char errbuf[512];
    77.6  
    77.7 -	wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t));
    77.8 -	wchar_t *sofile_t = malloc((MAX_PATH+1) * sizeof(wchar_t));
    77.9 +	wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
   77.10 +	wchar_t *sofile_t = SDL_malloc((MAX_PATH+1) * sizeof(wchar_t));
   77.11  
   77.12  	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH);
   77.13  	handle = (void *)LoadLibrary(sofile_t);
   77.14 @@ -62,8 +62,8 @@
   77.15  		loaderror = errbuf;
   77.16  	}
   77.17  
   77.18 -	free(sofile_t);
   77.19 -	free(errbuf_t);
   77.20 +	SDL_free(sofile_t);
   77.21 +	SDL_free(errbuf_t);
   77.22  
   77.23  #else /*if defined(WIN32)*/
   77.24  	char errbuf[512];
   77.25 @@ -94,10 +94,10 @@
   77.26  
   77.27  #if defined(_WIN32_WCE)
   77.28  	char errbuf[512];
   77.29 -	int length = strlen(name);
   77.30 +	int length = SDL_strlen(name);
   77.31  
   77.32 -	wchar_t *name_t = malloc((length + 1) * sizeof(wchar_t));
   77.33 -	wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t));
   77.34 +	wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
   77.35 +	wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
   77.36  
   77.37  	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);
   77.38  
   77.39 @@ -112,8 +112,8 @@
   77.40  		loaderror = errbuf;
   77.41  	}
   77.42  
   77.43 -	free(name_t);
   77.44 -	free(errbuf_t);
   77.45 +	SDL_free(name_t);
   77.46 +	SDL_free(errbuf_t);
   77.47  
   77.48  #else /*if defined(WIN32)*/
   77.49  	char errbuf[512];
    78.1 --- a/src/main/macos/SDL_main.c	Mon Feb 06 17:28:04 2006 +0000
    78.2 +++ b/src/main/macos/SDL_main.c	Tue Feb 07 06:59:48 2006 +0000
    78.3 @@ -589,7 +589,7 @@
    78.4  
    78.5      /* Parse C-string into argv and argc */
    78.6      nargs = ParseCommandLine (commandLine, NULL);
    78.7 -    args = (char **)malloc((nargs+1)*(sizeof *args));
    78.8 +    args = (char **)SDL_malloc((nargs+1)*(sizeof *args));
    78.9      if ( args == NULL ) {
   78.10  		exit(-1);
   78.11  	}
    79.1 --- a/src/main/win32/SDL_win32_main.c	Mon Feb 06 17:28:04 2006 +0000
    79.2 +++ b/src/main/win32/SDL_win32_main.c	Tue Feb 07 06:59:48 2006 +0000
    79.3 @@ -5,12 +5,12 @@
    79.4  */
    79.5  
    79.6  #include <stdio.h>
    79.7 -#include <string.h>
    79.8 -#include <ctype.h>
    79.9  #include <stdlib.h>
   79.10  
   79.11 -#include <windows.h>
   79.12 -#include <malloc.h>			/* For _alloca() */
   79.13 +#include "SDL_windows.h"
   79.14 +
   79.15 +#include "SDL_stdlib.h"
   79.16 +#include "SDL_string.h"
   79.17  
   79.18  #ifdef _WIN32_WCE
   79.19  # define DIR_SEPERATOR TEXT("\\")
   79.20 @@ -56,7 +56,7 @@
   79.21  #define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
   79.22  
   79.23  /* seems to be undefined in Win CE although in online help */
   79.24 -char *strrchr(char *str, int c)
   79.25 +char *SDL_strrchr(char *str, int c)
   79.26  {
   79.27  	char *p;
   79.28  
   79.29 @@ -195,15 +195,15 @@
   79.30  
   79.31  	/* Get the class name from argv[0] */
   79.32  	appname = argv[0];
   79.33 -	if ( (bufp=strrchr(argv[0], '\\')) != NULL ) {
   79.34 +	if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) {
   79.35  		appname = bufp+1;
   79.36  	} else
   79.37 -	if ( (bufp=strrchr(argv[0], '/')) != NULL ) {
   79.38 +	if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) {
   79.39  		appname = bufp+1;
   79.40  	}
   79.41  
   79.42 -	if ( (bufp=strrchr(appname, '.')) == NULL )
   79.43 -		n = strlen(appname);
   79.44 +	if ( (bufp=SDL_strrchr(appname, '.')) == NULL )
   79.45 +		n = SDL_strlen(appname);
   79.46  	else
   79.47  		n = (bufp-appname);
   79.48  
   79.49 @@ -211,7 +211,7 @@
   79.50  	if ( bufp == NULL ) {
   79.51  		return OutOfMemory();
   79.52  	}
   79.53 -	strncpy(bufp, appname, n);
   79.54 +	SDL_strncpy(bufp, appname, n);
   79.55  	bufp[n] = '\0';
   79.56  	appname = bufp;
   79.57  
   79.58 @@ -298,8 +298,8 @@
   79.59  	}
   79.60  	path[pathlen] = '\0';
   79.61  
   79.62 -	strcpy( stdoutPath, path );
   79.63 -	strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE );
   79.64 +	SDL_strcpy( stdoutPath, path );
   79.65 +	SDL_strcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE );
   79.66      
   79.67  	/* Redirect standard input and standard output */
   79.68  	newfp = freopen(stdoutPath, TEXT("w"), stdout);
   79.69 @@ -317,8 +317,8 @@
   79.70  	}
   79.71  #endif /* _WIN32_WCE */
   79.72  
   79.73 -	strcpy( stderrPath, path );
   79.74 -	strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );
   79.75 +	SDL_strcpy( stderrPath, path );
   79.76 +	SDL_strcat( stderrPath, DIR_SEPERATOR STDERR_FILE );
   79.77  
   79.78  	newfp = freopen(stderrPath, TEXT("w"), stderr);
   79.79  #ifndef _WIN32_WCE
   79.80 @@ -354,11 +354,11 @@
   79.81  #else
   79.82  	/* Grab the command line (use alloca() on Windows) */
   79.83  	bufp = GetCommandLine();
   79.84 -	cmdline = (char *)alloca(strlen(bufp)+1);
   79.85 +	cmdline = (char *)alloca(SDL_strlen(bufp)+1);
   79.86  	if ( cmdline == NULL ) {
   79.87  		return OutOfMemory();
   79.88  	}
   79.89 -	strcpy(cmdline, bufp);
   79.90 +	SDL_strcpy(cmdline, bufp);
   79.91  #endif
   79.92  
   79.93  	/* Parse it into argv and argc */
    80.1 --- a/src/stdlib/SDL_getenv.c	Mon Feb 06 17:28:04 2006 +0000
    80.2 +++ b/src/stdlib/SDL_getenv.c	Tue Feb 07 06:59:48 2006 +0000
    80.3 @@ -42,20 +42,20 @@
    80.4  	char *value;
    80.5  	const char *sep;
    80.6  
    80.7 -	sep = strchr(variable, '=');
    80.8 +	sep = SDL_strchr(variable, '=');
    80.9  	if ( sep == NULL ) {
   80.10  		return -1;
   80.11  	}
   80.12 -	bufferlen = strlen(variable)+1;
   80.13 +	bufferlen = SDL_strlen(variable)+1;
   80.14  	if ( bufferlen > SDL_envmemlen ) {
   80.15 -		char *newmem = (char *)realloc(SDL_envmem, bufferlen);
   80.16 +		char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
   80.17  		if ( newmem == NULL ) {
   80.18  			return -1;
   80.19  		}
   80.20  		SDL_envmem = newmem;
   80.21  		SDL_envmemlen = bufferlen;
   80.22  	}
   80.23 -	strcpy(SDL_envmem, variable);
   80.24 +	SDL_strcpy(SDL_envmem, variable);
   80.25  	value = SDL_envmem + (sep - variable);
   80.26  	*value++ = '\0';
   80.27  	if ( !SetEnvironmentVariable(SDL_envmem, *value ? value : NULL) ) {
   80.28 @@ -74,7 +74,7 @@
   80.29  		return NULL;
   80.30  	}
   80.31  	if ( bufferlen > SDL_envmemlen ) {
   80.32 -		char *newmem = (char *)realloc(SDL_envmem, bufferlen);
   80.33 +		char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
   80.34  		if ( newmem == NULL ) {
   80.35  			return NULL;
   80.36  		}
   80.37 @@ -140,7 +140,7 @@
   80.38  
   80.39  	/* Didn't find it in the environment, expand and add */
   80.40  	if ( ! added ) {
   80.41 -		new_env = realloc(SDL_env, (i+2)*sizeof(char *));
   80.42 +		new_env = SDL_realloc(SDL_env, (i+2)*sizeof(char *));
   80.43  		if ( new_env ) {
   80.44  			SDL_env = new_env;
   80.45  			SDL_env[i++] = new_variable;
    81.1 --- a/src/stdlib/SDL_malloc.c	Mon Feb 06 17:28:04 2006 +0000
    81.2 +++ b/src/stdlib/SDL_malloc.c	Tue Feb 07 06:59:48 2006 +0000
    81.3 @@ -39,6 +39,11 @@
    81.4  #define LACKS_ERRNO_H
    81.5  #define LACKS_STDLIB_H
    81.6  #define ABORT
    81.7 +#define memset	SDL_memset
    81.8 +#define memcpy	SDL_memcpy
    81.9 +#define malloc	SDL_malloc
   81.10 +#define realloc	SDL_realloc
   81.11 +#define free	SDL_free
   81.12  
   81.13  /*
   81.14    This is a version (aka dlmalloc) of malloc/free/realloc written by
    82.1 --- a/src/stdlib/SDL_qsort.c	Mon Feb 06 17:28:04 2006 +0000
    82.2 +++ b/src/stdlib/SDL_qsort.c	Tue Feb 07 06:59:48 2006 +0000
    82.3 @@ -233,9 +233,9 @@
    82.4        /* Shift everything in [test,first)	\
    82.5         * up by one, and place |first|		\
    82.6         * where |test| is. */			\
    82.7 -      memcpy(pivot,first,size);			\
    82.8 -      memmove(test+size,test,first-test);	\
    82.9 -      memcpy(test,pivot,size);			\
   82.10 +      SDL_memcpy(pivot,first,size);			\
   82.11 +      SDL_memmove(test+size,test,first-test);	\
   82.12 +      SDL_memcpy(test,pivot,size);			\
   82.13      }						\
   82.14    }
   82.15  
   82.16 @@ -298,7 +298,7 @@
   82.17    stack_entry stack[STACK_SIZE];
   82.18    int stacktop=0;
   82.19    char *first,*last;
   82.20 -  char *pivot=malloc(size);
   82.21 +  char *pivot=SDL_malloc(size);
   82.22    size_t trunc=TRUNC_nonaligned*size;
   82.23    assert(pivot!=0);
   82.24  
   82.25 @@ -310,7 +310,7 @@
   82.26        /* Select pivot */
   82.27        { char * mid=first+size*((last-first)/size >> 1);
   82.28          Pivot(SWAP_nonaligned,size);
   82.29 -        memcpy(pivot,mid,size);
   82.30 +        SDL_memcpy(pivot,mid,size);
   82.31        }
   82.32        /* Partition. */
   82.33        Partition(SWAP_nonaligned,size);
   82.34 @@ -320,7 +320,7 @@
   82.35    }
   82.36    PreInsertion(SWAP_nonaligned,TRUNC_nonaligned,size);
   82.37    Insertion(SWAP_nonaligned);
   82.38 -  free(pivot);
   82.39 +  SDL_free(pivot);
   82.40  }
   82.41  
   82.42  static void qsort_aligned(void *base, size_t nmemb, size_t size,
   82.43 @@ -329,7 +329,7 @@
   82.44    stack_entry stack[STACK_SIZE];
   82.45    int stacktop=0;
   82.46    char *first,*last;
   82.47 -  char *pivot=malloc(size);
   82.48 +  char *pivot=SDL_malloc(size);
   82.49    size_t trunc=TRUNC_aligned*size;
   82.50    assert(pivot!=0);
   82.51  
   82.52 @@ -341,7 +341,7 @@
   82.53        /* Select pivot */
   82.54        { char * mid=first+size*((last-first)/size >> 1);
   82.55          Pivot(SWAP_aligned,size);
   82.56 -        memcpy(pivot,mid,size);
   82.57 +        SDL_memcpy(pivot,mid,size);
   82.58        }
   82.59        /* Partition. */
   82.60        Partition(SWAP_aligned,size);
   82.61 @@ -351,7 +351,7 @@
   82.62    }
   82.63    PreInsertion(SWAP_aligned,TRUNC_aligned,size);
   82.64    Insertion(SWAP_aligned);
   82.65 -  free(pivot);
   82.66 +  SDL_free(pivot);
   82.67  }
   82.68  
   82.69  static void qsort_words(void *base, size_t nmemb,
   82.70 @@ -360,7 +360,7 @@
   82.71    stack_entry stack[STACK_SIZE];
   82.72    int stacktop=0;
   82.73    char *first,*last;
   82.74 -  char *pivot=malloc(WORD_BYTES);
   82.75 +  char *pivot=SDL_malloc(WORD_BYTES);
   82.76    assert(pivot!=0);
   82.77  
   82.78    first=(char*)base; last=first+(nmemb-1)*WORD_BYTES;
   82.79 @@ -398,7 +398,7 @@
   82.80        *pr=*pl; }
   82.81      if (pr!=(int*)first) *pr=*(int*)pivot;
   82.82    }
   82.83 -  free(pivot);
   82.84 +  SDL_free(pivot);
   82.85  }
   82.86  
   82.87  /* ---------------------------------------------------------------------- */
    83.1 --- a/src/stdlib/SDL_string.c	Mon Feb 06 17:28:04 2006 +0000
    83.2 +++ b/src/stdlib/SDL_string.c	Tue Feb 07 06:59:48 2006 +0000
    83.3 @@ -375,7 +375,7 @@
    83.4  #ifndef HAVE_STRRCHR
    83.5  char *SDL_strrchr(const char *string, int c)
    83.6  {
    83.7 -    const char *bufp = string + strlen(string) - 1;
    83.8 +    const char *bufp = string + SDL_strlen(string) - 1;
    83.9      while ( bufp >= string ) {
   83.10          if ( *bufp == c ) {
   83.11              return (char *)bufp;
   83.12 @@ -388,9 +388,9 @@
   83.13  #ifndef HAVE_STRSTR
   83.14  char *SDL_strstr(const char *haystack, const char *needle)
   83.15  {
   83.16 -    size_t length = strlen(needle);
   83.17 +    size_t length = SDL_strlen(needle);
   83.18      while ( *haystack ) {
   83.19 -        if ( strncmp(haystack, needle, length) == 0 ) {
   83.20 +        if ( SDL_strncmp(haystack, needle, length) == 0 ) {
   83.21              return (char *)haystack;
   83.22          }
   83.23      }
   83.24 @@ -429,9 +429,9 @@
   83.25  
   83.26      /* The numbers went into the string backwards. :) */
   83.27      if ( *string == '-' ) {
   83.28 -        _strrev(string+1);
   83.29 +        SDL_strrev(string+1);
   83.30      } else {
   83.31 -        _strrev(string);
   83.32 +        SDL_strrev(string);
   83.33      }
   83.34  
   83.35      return string;
   83.36 @@ -454,7 +454,7 @@
   83.37      *bufp = '\0';
   83.38  
   83.39      /* The numbers went into the string backwards. :) */
   83.40 -    _strrev(string);
   83.41 +    SDL_strrev(string);
   83.42  
   83.43      return string;
   83.44  }
   83.45 @@ -497,9 +497,9 @@
   83.46  
   83.47      /* The numbers went into the string backwards. :) */
   83.48      if ( *string == '-' ) {
   83.49 -        _strrev(string+1);
   83.50 +        SDL_strrev(string+1);
   83.51      } else {
   83.52 -        _strrev(string);
   83.53 +        SDL_strrev(string);
   83.54      }
   83.55  
   83.56      return string;
   83.57 @@ -522,7 +522,7 @@
   83.58      *bufp = '\0';
   83.59  
   83.60      /* The numbers went into the string backwards. :) */
   83.61 -    _strrev(string);
   83.62 +    SDL_strrev(string);
   83.63  
   83.64      return string;
   83.65  }
   83.66 @@ -878,12 +878,12 @@
   83.67      char num[130];
   83.68      size_t size;
   83.69  
   83.70 -    _ltoa(value, num, radix);
   83.71 +    SDL_ltoa(value, num, radix);
   83.72      size = SDL_strlen(num);
   83.73      if ( size > maxlen ) {
   83.74          size = maxlen;
   83.75      }
   83.76 -    strncpy(text, num, size);
   83.77 +    SDL_strncpy(text, num, size);
   83.78  
   83.79      return size;
   83.80  }
   83.81 @@ -892,12 +892,12 @@
   83.82      char num[130];
   83.83      size_t size;
   83.84  
   83.85 -    _ultoa(value, num, radix);
   83.86 +    SDL_ultoa(value, num, radix);
   83.87      size = SDL_strlen(num);
   83.88      if ( size > maxlen ) {
   83.89          size = maxlen;
   83.90      }
   83.91 -    strncpy(text, num, size);
   83.92 +    SDL_strncpy(text, num, size);
   83.93  
   83.94      return size;
   83.95  }
   83.96 @@ -907,12 +907,12 @@
   83.97      char num[130];
   83.98      size_t size;
   83.99  
  83.100 -    _i64toa(value, num, radix);
  83.101 +    SDL_lltoa(value, num, radix);
  83.102      size = SDL_strlen(num);
  83.103      if ( size > maxlen ) {
  83.104          size = maxlen;
  83.105      }
  83.106 -    strncpy(text, num, size);
  83.107 +    SDL_strncpy(text, num, size);
  83.108  
  83.109      return size;
  83.110  }
  83.111 @@ -921,12 +921,12 @@
  83.112      char num[130];
  83.113      size_t size;
  83.114  
  83.115 -    _ui64toa(value, num, radix);
  83.116 +    SDL_ulltoa(value, num, radix);
  83.117      size = SDL_strlen(num);
  83.118      if ( size > maxlen ) {
  83.119          size = maxlen;
  83.120      }
  83.121 -    strncpy(text, num, size);
  83.122 +    SDL_strncpy(text, num, size);
  83.123  
  83.124      return size;
  83.125  }
  83.126 @@ -1076,7 +1076,7 @@
  83.127                                  break;
  83.128                          }
  83.129                          if ( do_lowercase ) {
  83.130 -                            _strlwr(text);
  83.131 +                            SDL_strlwr(text);
  83.132                          }
  83.133                          done = SDL_TRUE;
  83.134                          break;
    84.1 --- a/src/thread/SDL_thread.c	Mon Feb 06 17:28:04 2006 +0000
    84.2 +++ b/src/thread/SDL_thread.c	Tue Feb 07 06:59:48 2006 +0000
    84.3 @@ -99,16 +99,16 @@
    84.4  			SDL_numthreads, SDL_maxthreads);
    84.5  #endif
    84.6  	if ( SDL_numthreads == SDL_maxthreads ) {
    84.7 -		threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
    84.8 +		threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
    84.9  		                              (sizeof *threads));
   84.10  		if ( threads == NULL ) {
   84.11  			SDL_OutOfMemory();
   84.12  			goto done;
   84.13  		}
   84.14 -		memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
   84.15 +		SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
   84.16  		SDL_maxthreads += ARRAY_CHUNKSIZE;
   84.17  		if ( SDL_Threads ) {
   84.18 -			free(SDL_Threads);
   84.19 +			SDL_free(SDL_Threads);
   84.20  		}
   84.21  		SDL_Threads = threads;
   84.22  	}
   84.23 @@ -136,7 +136,7 @@
   84.24  				}
   84.25  			} else {
   84.26  				SDL_maxthreads = 0;
   84.27 -				free(SDL_Threads);
   84.28 +				SDL_free(SDL_Threads);
   84.29  				SDL_Threads = NULL;
   84.30  			}
   84.31  #ifdef DEBUG_THREADS
   84.32 @@ -223,19 +223,19 @@
   84.33  	int ret;
   84.34  
   84.35  	/* Allocate memory for the thread info structure */
   84.36 -	thread = (SDL_Thread *)malloc(sizeof(*thread));
   84.37 +	thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
   84.38  	if ( thread == NULL ) {
   84.39  		SDL_OutOfMemory();
   84.40  		return(NULL);
   84.41  	}
   84.42 -	memset(thread, 0, (sizeof *thread));
   84.43 +	SDL_memset(thread, 0, (sizeof *thread));
   84.44  	thread->status = -1;
   84.45  
   84.46  	/* Set up the arguments for the thread */
   84.47 -	args = (thread_args *)malloc(sizeof(*args));
   84.48 +	args = (thread_args *)SDL_malloc(sizeof(*args));
   84.49  	if ( args == NULL ) {
   84.50  		SDL_OutOfMemory();
   84.51 -		free(thread);
   84.52 +		SDL_free(thread);
   84.53  		return(NULL);
   84.54  	}
   84.55  	args->func = fn;
   84.56 @@ -243,8 +243,8 @@
   84.57  	args->info = thread;
   84.58  	args->wait = SDL_CreateSemaphore(0);
   84.59  	if ( args->wait == NULL ) {
   84.60 -		free(thread);
   84.61 -		free(args);
   84.62 +		SDL_free(thread);
   84.63 +		SDL_free(args);
   84.64  		return(NULL);
   84.65  	}
   84.66  
   84.67 @@ -263,11 +263,11 @@
   84.68  	} else {
   84.69  		/* Oops, failed.  Gotta free everything */
   84.70  		SDL_DelThread(thread);
   84.71 -		free(thread);
   84.72 +		SDL_free(thread);
   84.73  		thread = NULL;
   84.74  	}
   84.75  	SDL_DestroySemaphore(args->wait);
   84.76 -	free(args);
   84.77 +	SDL_free(args);
   84.78  
   84.79  	/* Everything is running now */
   84.80  	return(thread);
   84.81 @@ -281,7 +281,7 @@
   84.82  			*status = thread->status;
   84.83  		}
   84.84  		SDL_DelThread(thread);
   84.85 -		free(thread);
   84.86 +		SDL_free(thread);
   84.87  	}
   84.88  }
   84.89  
    85.1 --- a/src/thread/amigaos/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
    85.2 +++ b/src/thread/amigaos/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
    85.3 @@ -44,7 +44,7 @@
    85.4  {
    85.5  	SDL_sem *sem;
    85.6  
    85.7 -	sem = (SDL_sem *)malloc(sizeof(*sem));
    85.8 +	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
    85.9  
   85.10  	if ( ! sem ) {
   85.11  		SDL_OutOfMemory();
   85.12 @@ -53,7 +53,7 @@
   85.13  
   85.14  	D(bug("Creating semaphore %lx...\n",sem));
   85.15  
   85.16 -	memset(sem,0,sizeof(*sem));
   85.17 +	SDL_memset(sem,0,sizeof(*sem));
   85.18  
   85.19  	InitSemaphore(&sem->Sem);
   85.20  
   85.21 @@ -66,7 +66,7 @@
   85.22  
   85.23  	if ( sem ) {
   85.24  // Condizioni per liberare i task in attesa?
   85.25 -		free(sem);
   85.26 +		SDL_free(sem);
   85.27  	}
   85.28  }
   85.29  
    86.1 --- a/src/thread/amigaos/SDL_thread.c	Mon Feb 06 17:28:04 2006 +0000
    86.2 +++ b/src/thread/amigaos/SDL_thread.c	Tue Feb 07 06:59:48 2006 +0000
    86.3 @@ -84,16 +84,16 @@
    86.4  			SDL_numthreads, SDL_maxthreads);
    86.5  #endif
    86.6  	if ( SDL_numthreads == SDL_maxthreads ) {
    86.7 -		threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
    86.8 +		threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
    86.9  		                              (sizeof *threads));
   86.10  		if ( threads == NULL ) {
   86.11  			SDL_OutOfMemory();
   86.12  			goto done;
   86.13  		}
   86.14 -		memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
   86.15 +		SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
   86.16  		SDL_maxthreads += ARRAY_CHUNKSIZE;
   86.17  		if ( SDL_Threads ) {
   86.18 -			free(SDL_Threads);
   86.19 +			SDL_free(SDL_Threads);
   86.20  		}
   86.21  		SDL_Threads = threads;
   86.22  	}
   86.23 @@ -198,19 +198,19 @@
   86.24  	int ret;
   86.25  
   86.26  	/* Allocate memory for the thread info structure */
   86.27 -	thread = (SDL_Thread *)malloc(sizeof(*thread));
   86.28 +	thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
   86.29  	if ( thread == NULL ) {
   86.30  		SDL_OutOfMemory();
   86.31  		return(NULL);
   86.32  	}
   86.33 -	memset(thread, 0, (sizeof *thread));
   86.34 +	SDL_memset(thread, 0, (sizeof *thread));
   86.35  	thread->status = -1;
   86.36  
   86.37  	/* Set up the arguments for the thread */
   86.38 -	args = (thread_args *)malloc(sizeof(*args));
   86.39 +	args = (thread_args *)SDL_malloc(sizeof(*args));
   86.40  	if ( args == NULL ) {
   86.41  		SDL_OutOfMemory();
   86.42 -		free(thread);
   86.43 +		SDL_free(thread);
   86.44  		return(NULL);
   86.45  	}
   86.46  	args->func = fn;
   86.47 @@ -218,8 +218,8 @@
   86.48  	args->info = thread;
   86.49  	args->wait = FindTask(NULL);
   86.50  	if ( args->wait == NULL ) {
   86.51 -		free(thread);
   86.52 -		free(args);
   86.53 +		SDL_free(thread);
   86.54 +		SDL_free(args);
   86.55  		SDL_OutOfMemory();
   86.56  		return(NULL);
   86.57  	}
   86.58 @@ -239,10 +239,10 @@
   86.59  	} else {
   86.60  		/* Oops, failed.  Gotta free everything */
   86.61  		SDL_DelThread(thread);
   86.62 -		free(thread);
   86.63 +		SDL_free(thread);
   86.64  		thread = NULL;
   86.65  	}
   86.66 -	free(args);
   86.67 +	SDL_free(args);
   86.68  
   86.69  	/* Everything is running now */
   86.70  	return(thread);
   86.71 @@ -256,7 +256,7 @@
   86.72  			*status = thread->status;
   86.73  		}
   86.74  		SDL_DelThread(thread);
   86.75 -		free(thread);
   86.76 +		SDL_free(thread);
   86.77  	}
   86.78  }
   86.79  
    87.1 --- a/src/thread/beos/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
    87.2 +++ b/src/thread/beos/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
    87.3 @@ -37,12 +37,12 @@
    87.4  {
    87.5  	SDL_sem *sem;
    87.6  
    87.7 -	sem = (SDL_sem *)malloc(sizeof(*sem));
    87.8 +	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
    87.9  	if ( sem ) {
   87.10  		sem->id = create_sem(initial_value, "SDL semaphore");
   87.11  		if ( sem->id < B_NO_ERROR ) {
   87.12  			SDL_SetError("create_sem() failed");
   87.13 -			free(sem);
   87.14 +			SDL_free(sem);
   87.15  			sem = NULL;
   87.16  		}
   87.17  	} else {
   87.18 @@ -58,7 +58,7 @@
   87.19  		if ( sem->id >= B_NO_ERROR ) {
   87.20  			delete_sem(sem->id);
   87.21  		}
   87.22 -		free(sem);
   87.23 +		SDL_free(sem);
   87.24  	}
   87.25  }
   87.26  
    88.1 --- a/src/thread/bsdi/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
    88.2 +++ b/src/thread/bsdi/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
    88.3 @@ -113,11 +113,11 @@
    88.4  /* Create a semaphore, initialized with value */
    88.5  SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
    88.6  {
    88.7 -	SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem));
    88.8 +	SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
    88.9  	if ( sem ) {
   88.10  		if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
   88.11  			SDL_SetError("sem_init() failed");
   88.12 -			free(sem);
   88.13 +			SDL_free(sem);
   88.14  			sem = NULL;
   88.15  		} else {
   88.16  			sem->sem = &sem->sem_data;
   88.17 @@ -132,7 +132,7 @@
   88.18  {
   88.19  	if ( sem ) {
   88.20  		sem_destroy(sem->sem);
   88.21 -		free(sem);
   88.22 +		SDL_free(sem);
   88.23  	}
   88.24  }
   88.25  
   88.26 @@ -322,7 +322,7 @@
   88.27  		goto RETURN;
   88.28  	}
   88.29  
   88.30 -	*sem = (sem_t)malloc(sizeof(struct sem));
   88.31 +	*sem = (sem_t)SDL_malloc(sizeof(struct sem));
   88.32  	if (*sem == NULL) {
   88.33  		errno = ENOSPC;
   88.34  		retval = -1;
   88.35 @@ -333,7 +333,7 @@
   88.36  	 * Initialize the semaphore.
   88.37  	 */
   88.38  	if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) {
   88.39 -		free(*sem);
   88.40 +		SDL_free(*sem);
   88.41  		errno = ENOSPC;
   88.42  		retval = -1;
   88.43  		goto RETURN;
   88.44 @@ -341,7 +341,7 @@
   88.45  
   88.46  	if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) {
   88.47  		pthread_mutex_destroy(&(*sem)->lock);
   88.48 -		free(*sem);
   88.49 +		SDL_free(*sem);
   88.50  		errno = ENOSPC;
   88.51  		retval = -1;
   88.52  		goto RETURN;
   88.53 @@ -377,7 +377,7 @@
   88.54  	pthread_cond_destroy(&(*sem)->gtzero);
   88.55  	(*sem)->magic = 0;
   88.56  
   88.57 -	free(*sem);
   88.58 +	SDL_free(*sem);
   88.59  
   88.60  	retval = 0;
   88.61    RETURN:
    89.1 --- a/src/thread/dc/SDL_syscond.c	Mon Feb 06 17:28:04 2006 +0000
    89.2 +++ b/src/thread/dc/SDL_syscond.c	Tue Feb 07 06:59:48 2006 +0000
    89.3 @@ -46,7 +46,7 @@
    89.4  {
    89.5  	SDL_cond *cond;
    89.6  
    89.7 -	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
    89.8 +	cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
    89.9  	if ( cond ) {
   89.10  		cond->lock = SDL_CreateMutex();
   89.11  		cond->wait_sem = SDL_CreateSemaphore(0);
   89.12 @@ -75,7 +75,7 @@
   89.13  		if ( cond->lock ) {
   89.14  			SDL_DestroyMutex(cond->lock);
   89.15  		}
   89.16 -		free(cond);
   89.17 +		SDL_free(cond);
   89.18  	}
   89.19  }
   89.20  
    90.1 --- a/src/thread/dc/SDL_sysmutex.c	Mon Feb 06 17:28:04 2006 +0000
    90.2 +++ b/src/thread/dc/SDL_sysmutex.c	Tue Feb 07 06:59:48 2006 +0000
    90.3 @@ -43,7 +43,7 @@
    90.4  	SDL_mutex *mutex;
    90.5  
    90.6  	/* Allocate mutex memory */
    90.7 -	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
    90.8 +	mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
    90.9  	if ( mutex ) {
   90.10  		spinlock_init(&mutex->mutex);
   90.11  		mutex->recursive = 0;
   90.12 @@ -58,7 +58,7 @@
   90.13  void SDL_DestroyMutex(SDL_mutex *mutex)
   90.14  {
   90.15  	if ( mutex ) {
   90.16 -		free(mutex);
   90.17 +		SDL_free(mutex);
   90.18  	}
   90.19  }
   90.20  
    91.1 --- a/src/thread/generic/SDL_syscond.c	Mon Feb 06 17:28:04 2006 +0000
    91.2 +++ b/src/thread/generic/SDL_syscond.c	Tue Feb 07 06:59:48 2006 +0000
    91.3 @@ -44,7 +44,7 @@
    91.4  {
    91.5  	SDL_cond *cond;
    91.6  
    91.7 -	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
    91.8 +	cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
    91.9  	if ( cond ) {
   91.10  		cond->lock = SDL_CreateMutex();
   91.11  		cond->wait_sem = SDL_CreateSemaphore(0);
   91.12 @@ -73,7 +73,7 @@
   91.13  		if ( cond->lock ) {
   91.14  			SDL_DestroyMutex(cond->lock);
   91.15  		}
   91.16 -		free(cond);
   91.17 +		SDL_free(cond);
   91.18  	}
   91.19  }
   91.20  
    92.1 --- a/src/thread/generic/SDL_sysmutex.c	Mon Feb 06 17:28:04 2006 +0000
    92.2 +++ b/src/thread/generic/SDL_sysmutex.c	Tue Feb 07 06:59:48 2006 +0000
    92.3 @@ -40,14 +40,14 @@
    92.4  	SDL_mutex *mutex;
    92.5  
    92.6  	/* Allocate mutex memory */
    92.7 -	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
    92.8 +	mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
    92.9  	if ( mutex ) {
   92.10  		/* Create the mutex semaphore, with initial value 1 */
   92.11  		mutex->sem = SDL_CreateSemaphore(1);
   92.12  		mutex->recursive = 0;
   92.13  		mutex->owner = 0;
   92.14  		if ( ! mutex->sem ) {
   92.15 -			free(mutex);
   92.16 +			SDL_free(mutex);
   92.17  			mutex = NULL;
   92.18  		}
   92.19  	} else {
   92.20 @@ -63,7 +63,7 @@
   92.21  		if ( mutex->sem ) {
   92.22  			SDL_DestroySemaphore(mutex->sem);
   92.23  		}
   92.24 -		free(mutex);
   92.25 +		SDL_free(mutex);
   92.26  	}
   92.27  }
   92.28  
    93.1 --- a/src/thread/generic/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
    93.2 +++ b/src/thread/generic/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
    93.3 @@ -85,7 +85,7 @@
    93.4  {
    93.5  	SDL_sem *sem;
    93.6  
    93.7 -	sem = (SDL_sem *)malloc(sizeof(*sem));
    93.8 +	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
    93.9  	if ( ! sem ) {
   93.10  		SDL_OutOfMemory();
   93.11  		return(0);
   93.12 @@ -118,7 +118,7 @@
   93.13  		SDL_mutexP(sem->count_lock);
   93.14  		SDL_mutexV(sem->count_lock);
   93.15  		SDL_DestroyMutex(sem->count_lock);
   93.16 -		free(sem);
   93.17 +		SDL_free(sem);
   93.18  	}
   93.19  }
   93.20  
    94.1 --- a/src/thread/linux/SDL_syscond.c	Mon Feb 06 17:28:04 2006 +0000
    94.2 +++ b/src/thread/linux/SDL_syscond.c	Tue Feb 07 06:59:48 2006 +0000
    94.3 @@ -62,11 +62,11 @@
    94.4  {
    94.5  	SDL_cond *cond;
    94.6  
    94.7 -	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
    94.8 +	cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
    94.9  	if ( cond ) {
   94.10  		if ( pthread_cond_init(&cond->cond, NULL) < 0 ) {
   94.11  			SDL_SetError("pthread_cond_init() failed");
   94.12 -			free(cond);
   94.13 +			SDL_free(cond);
   94.14  			cond = NULL;
   94.15  		}
   94.16  	}
   94.17 @@ -78,7 +78,7 @@
   94.18  {
   94.19  	if ( cond ) {
   94.20  		pthread_cond_destroy(&cond->cond);
   94.21 -		free(cond);
   94.22 +		SDL_free(cond);
   94.23  	}
   94.24  }
   94.25  
    95.1 --- a/src/thread/linux/SDL_sysmutex.c	Mon Feb 06 17:28:04 2006 +0000
    95.2 +++ b/src/thread/linux/SDL_sysmutex.c	Tue Feb 07 06:59:48 2006 +0000
    95.3 @@ -71,7 +71,7 @@
    95.4  #endif /* PTHREAD_RECURSIVE_MUTEX */
    95.5  		if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
    95.6  			SDL_SetError("pthread_mutex_init() failed");
    95.7 -			free(mutex);
    95.8 +			SDL_free(mutex);
    95.9  			mutex = NULL;
   95.10  		}
   95.11  	} else {
   95.12 @@ -84,7 +84,7 @@
   95.13  {
   95.14  	if ( mutex ) {
   95.15  		pthread_mutex_destroy(&mutex->id);
   95.16 -		free(mutex);
   95.17 +		SDL_free(mutex);
   95.18  	}
   95.19  }
   95.20  
    96.1 --- a/src/thread/linux/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
    96.2 +++ b/src/thread/linux/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
    96.3 @@ -68,7 +68,7 @@
    96.4  /* Create a semaphore, initialized with value */
    96.5  SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
    96.6  {
    96.7 -	SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem));
    96.8 +	SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
    96.9  	if ( sem ) {
   96.10  #ifdef USE_NAMED_SEMAPHORES
   96.11  		static int semnum = 0;
   96.12 @@ -78,7 +78,7 @@
   96.13  		sem->sem = sem_open(name, O_CREAT, 0600, initial_value);
   96.14  		if ( sem->sem == (sem_t *)SEM_FAILED ) {
   96.15  			SDL_SetError("sem_open(%s) failed", name);
   96.16 -			free(sem);
   96.17 +			SDL_free(sem);
   96.18  			sem = NULL;
   96.19  		} else {
   96.20  			sem_unlink(name);
   96.21 @@ -86,7 +86,7 @@
   96.22  #else
   96.23  		if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
   96.24  			SDL_SetError("sem_init() failed");
   96.25 -			free(sem);
   96.26 +			SDL_free(sem);
   96.27  			sem = NULL;
   96.28  		} else {
   96.29  			sem->sem = &sem->sem_data;
   96.30 @@ -106,7 +106,7 @@
   96.31  #else
   96.32  		sem_destroy(sem->sem);
   96.33  #endif
   96.34 -		free(sem);
   96.35 +		SDL_free(sem);
   96.36  	}
   96.37  }
   96.38  
   96.39 @@ -245,7 +245,7 @@
   96.40  	union semun init;
   96.41  	key_t key;
   96.42  
   96.43 -	sem = (SDL_sem *)malloc(sizeof(*sem));
   96.44 +	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
   96.45  	if ( sem == NULL ) {
   96.46  		SDL_OutOfMemory();
   96.47  		return(NULL);
   96.48 @@ -269,7 +269,7 @@
   96.49  	/* Report the error if we eventually failed */
   96.50  	if ( sem->id < 0 ) {
   96.51  		SDL_SetError("Couldn't create semaphore");
   96.52 -		free(sem);
   96.53 +		SDL_free(sem);
   96.54  		return(NULL);
   96.55  	}
   96.56  	init.val = initial_value;	/* Initialize semaphore */
   96.57 @@ -287,7 +287,7 @@
   96.58  		dummy.val = 0;
   96.59  		semctl(sem->id, 0, IPC_RMID, dummy);
   96.60  #endif
   96.61 -		free(sem);
   96.62 +		SDL_free(sem);
   96.63  	}
   96.64  }
   96.65  
    97.1 --- a/src/thread/linux/SDL_systhread.c	Mon Feb 06 17:28:04 2006 +0000
    97.2 +++ b/src/thread/linux/SDL_systhread.c	Tue Feb 07 06:59:48 2006 +0000
    97.3 @@ -172,7 +172,7 @@
    97.4  	void *stack;
    97.5  
    97.6  	/* Allocate memory for thread stack */
    97.7 -	stack = malloc(STACKSIZE);
    97.8 +	stack = SDL_malloc(STACKSIZE);
    97.9  	if ( stack == (void *)0 ) {
   97.10  		SDL_OutOfMemory();
   97.11  		return(-1);
   97.12 @@ -186,7 +186,7 @@
   97.13  	thread->handle = clone(RunThread, stack,
   97.14  			(CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND), args);
   97.15  	if ( thread->handle < 0 ) {
   97.16 -		free(thread->data);
   97.17 +		SDL_free(thread->data);
   97.18  		SDL_SetError("Not enough resources to create thread");
   97.19  		return(-1);
   97.20  	}
   97.21 @@ -233,7 +233,7 @@
   97.22  	while ( system(command) == 0 )
   97.23  		sleep(1);
   97.24  #endif
   97.25 -	free(thread->data);
   97.26 +	SDL_free(thread->data);
   97.27  }
   97.28  
   97.29  void SDL_SYS_KillThread(SDL_Thread *thread)
    98.1 --- a/src/thread/os2/SDL_syscond.c	Mon Feb 06 17:28:04 2006 +0000
    98.2 +++ b/src/thread/os2/SDL_syscond.c	Tue Feb 07 06:59:48 2006 +0000
    98.3 @@ -46,7 +46,7 @@
    98.4  {
    98.5  	SDL_cond *cond;
    98.6  
    98.7 -	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
    98.8 +	cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
    98.9  	if ( cond ) {
   98.10  		cond->lock = SDL_CreateMutex();
   98.11  		cond->wait_sem = SDL_CreateSemaphore(0);
   98.12 @@ -75,7 +75,7 @@
   98.13  		if ( cond->lock ) {
   98.14  			SDL_DestroyMutex(cond->lock);
   98.15  		}
   98.16 -		free(cond);
   98.17 +		SDL_free(cond);
   98.18  	}
   98.19  }
   98.20  
    99.1 --- a/src/thread/os2/SDL_sysmutex.c	Mon Feb 06 17:28:04 2006 +0000
    99.2 +++ b/src/thread/os2/SDL_sysmutex.c	Tue Feb 07 06:59:48 2006 +0000
    99.3 @@ -43,7 +43,7 @@
    99.4    APIRET ulrc;
    99.5  
    99.6    /* Allocate mutex memory */
    99.7 -  mutex = (SDL_mutex *)malloc(sizeof(*mutex));
    99.8 +  mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
    99.9    if (mutex)
   99.10    {
   99.11      /* Create the mutex, with initial value signaled */
   99.12 @@ -54,7 +54,7 @@
   99.13      if (ulrc!=NO_ERROR)
   99.14      {
   99.15        SDL_SetError("Couldn't create mutex");
   99.16 -      free(mutex);
   99.17 +      SDL_free(mutex);
   99.18        mutex = NULL;
   99.19      }
   99.20    } else {
   99.21 @@ -73,7 +73,7 @@
   99.22        DosCloseMutexSem(mutex->hmtxID);
   99.23        mutex->hmtxID = 0;
   99.24      }
   99.25 -    free(mutex);
   99.26 +    SDL_free(mutex);
   99.27    }
   99.28  }
   99.29  
   100.1 --- a/src/thread/os2/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
   100.2 +++ b/src/thread/os2/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
   100.3 @@ -48,13 +48,13 @@
   100.4          ULONG ulrc;
   100.5  
   100.6          /* Allocate sem memory */
   100.7 -        sem = (SDL_sem *)malloc(sizeof(*sem));
   100.8 +        sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
   100.9          if ( sem ) {
  100.10                  /* Create the mutex semaphore */
  100.11                  ulrc = DosCreateMutexSem(NULL,&(sem->id),0,TRUE);
  100.12                  if ( ulrc ) {
  100.13                          SDL_SetError("Couldn't create semaphore");
  100.14 -                        free(sem);
  100.15 +                        SDL_free(sem);
  100.16                          sem = NULL;
  100.17                  } else
  100.18                  {
  100.19 @@ -77,7 +77,7 @@
  100.20                          DosCloseMutexSem(sem->id);
  100.21                          sem->id = 0;
  100.22                  }
  100.23 -                free(sem);
  100.24 +                SDL_free(sem);
  100.25          }
  100.26  }
  100.27  
   101.1 --- a/src/thread/os2/SDL_systhread.c	Mon Feb 06 17:28:04 2006 +0000
   101.2 +++ b/src/thread/os2/SDL_systhread.c	Tue Feb 07 06:59:48 2006 +0000
   101.3 @@ -51,7 +51,7 @@
   101.4    if (pThreadParms)
   101.5    {
   101.6      pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
   101.7 -    free(pThreadParms);
   101.8 +    SDL_free(pThreadParms);
   101.9    }
  101.10    // Call endthread!
  101.11    if (pfnCurrentEndThread)
  101.12 @@ -60,7 +60,7 @@
  101.13  
  101.14  int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
  101.15  {
  101.16 -  pThreadStartParms pThreadParms = malloc(sizeof(tThreadStartParms));
  101.17 +  pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms));
  101.18    if (!pThreadParms)
  101.19    {
  101.20      SDL_SetError("Not enough memory to create thread");
   102.1 --- a/src/thread/pth/SDL_syscond.c	Mon Feb 06 17:28:04 2006 +0000
   102.2 +++ b/src/thread/pth/SDL_syscond.c	Tue Feb 07 06:59:48 2006 +0000
   102.3 @@ -18,11 +18,11 @@
   102.4  {
   102.5  	SDL_cond *cond;
   102.6  
   102.7 -	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
   102.8 +	cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
   102.9  	if ( cond ) {
  102.10  		if ( pth_cond_init(&(cond->condpth_p)) < 0 ) {
  102.11  			SDL_SetError("pthread_cond_init() failed");
  102.12 -			free(cond);
  102.13 +			SDL_free(cond);
  102.14  			cond = NULL;
  102.15  		}
  102.16  	} else {
  102.17 @@ -35,7 +35,7 @@
  102.18  void SDL_DestroyCond(SDL_cond *cond)
  102.19  {
  102.20  	if ( cond ) {
  102.21 -		free(cond);
  102.22 +		SDL_free(cond);
  102.23  	}
  102.24  }
  102.25  
   103.1 --- a/src/thread/pth/SDL_sysmutex.c	Mon Feb 06 17:28:04 2006 +0000
   103.2 +++ b/src/thread/pth/SDL_sysmutex.c	Tue Feb 07 06:59:48 2006 +0000
   103.3 @@ -18,12 +18,12 @@
   103.4  	SDL_mutex *mutex;
   103.5  
   103.6  	/* Allocate mutex memory */
   103.7 -	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
   103.8 +	mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
   103.9  	if ( mutex ) {
  103.10  		/* Create the mutex, with initial value signaled */
  103.11  	    if (!pth_mutex_init(&(mutex->mutexpth_p))) {
  103.12  			SDL_SetError("Couldn't create mutex");
  103.13 -			free(mutex);
  103.14 +			SDL_free(mutex);
  103.15  			mutex = NULL;
  103.16  		}
  103.17  	} else {
  103.18 @@ -36,7 +36,7 @@
  103.19  void SDL_DestroyMutex(SDL_mutex *mutex)
  103.20  {
  103.21  	if ( mutex ) {
  103.22 -		free(mutex);
  103.23 +		SDL_free(mutex);
  103.24  	}
  103.25  }
  103.26  
   104.1 --- a/src/thread/riscos/SDL_syscond.c	Mon Feb 06 17:28:04 2006 +0000
   104.2 +++ b/src/thread/riscos/SDL_syscond.c	Tue Feb 07 06:59:48 2006 +0000
   104.3 @@ -45,11 +45,11 @@
   104.4  {
   104.5  	SDL_cond *cond;
   104.6  
   104.7 -	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
   104.8 +	cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
   104.9  	if ( cond ) {
  104.10  		if ( pthread_cond_init(&cond->cond, NULL) < 0 ) {
  104.11  			SDL_SetError("pthread_cond_init() failed");
  104.12 -			free(cond);
  104.13 +			SDL_free(cond);
  104.14  			cond = NULL;
  104.15  		}
  104.16  	}
  104.17 @@ -61,7 +61,7 @@
  104.18  {
  104.19  	if ( cond ) {
  104.20  		pthread_cond_destroy(&cond->cond);
  104.21 -		free(cond);
  104.22 +		SDL_free(cond);
  104.23  	}
  104.24  }
  104.25  
   105.1 --- a/src/thread/riscos/SDL_sysmutex.c	Mon Feb 06 17:28:04 2006 +0000
   105.2 +++ b/src/thread/riscos/SDL_sysmutex.c	Tue Feb 07 06:59:48 2006 +0000
   105.3 @@ -57,7 +57,7 @@
   105.4  #endif /* PTHREAD_NO_RECURSIVE_MUTEX */
   105.5  		if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
   105.6  			SDL_SetError("pthread_mutex_init() failed");
   105.7 -			free(mutex);
   105.8 +			SDL_free(mutex);
   105.9  			mutex = NULL;
  105.10  		}
  105.11  	} else {
  105.12 @@ -70,7 +70,7 @@
  105.13  {
  105.14  	if ( mutex ) {
  105.15  		pthread_mutex_destroy(&mutex->id);
  105.16 -		free(mutex);
  105.17 +		SDL_free(mutex);
  105.18  	}
  105.19  }
  105.20  
   106.1 --- a/src/thread/riscos/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
   106.2 +++ b/src/thread/riscos/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
   106.3 @@ -90,11 +90,11 @@
   106.4  /* Create a semaphore, initialized with value */
   106.5  SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
   106.6  {
   106.7 -	SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem));
   106.8 +	SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
   106.9  	if ( sem ) {
  106.10  		if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
  106.11  			SDL_SetError("sem_init() failed");
  106.12 -			free(sem);
  106.13 +			SDL_free(sem);
  106.14  			sem = NULL;
  106.15  		} else {
  106.16  			sem->sem = &sem->sem_data;
  106.17 @@ -109,7 +109,7 @@
  106.18  {
  106.19  	if ( sem ) {
  106.20  		sem_destroy(sem->sem);
  106.21 -		free(sem);
  106.22 +		SDL_free(sem);
  106.23  	}
  106.24  }
  106.25  
   107.1 --- a/src/thread/win32/SDL_sysmutex.c	Mon Feb 06 17:28:04 2006 +0000
   107.2 +++ b/src/thread/win32/SDL_sysmutex.c	Tue Feb 07 06:59:48 2006 +0000
   107.3 @@ -39,13 +39,13 @@
   107.4  	SDL_mutex *mutex;
   107.5  
   107.6  	/* Allocate mutex memory */
   107.7 -	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
   107.8 +	mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
   107.9  	if ( mutex ) {
  107.10  		/* Create the mutex, with initial value signaled */
  107.11  		mutex->id = CreateMutex(NULL, FALSE, NULL);
  107.12  		if ( ! mutex->id ) {
  107.13  			SDL_SetError("Couldn't create mutex");
  107.14 -			free(mutex);
  107.15 +			SDL_free(mutex);
  107.16  			mutex = NULL;
  107.17  		}
  107.18  	} else {
  107.19 @@ -62,7 +62,7 @@
  107.20  			CloseHandle(mutex->id);
  107.21  			mutex->id = 0;
  107.22  		}
  107.23 -		free(mutex);
  107.24 +		SDL_free(mutex);
  107.25  	}
  107.26  }
  107.27  
   108.1 --- a/src/thread/win32/SDL_syssem.c	Mon Feb 06 17:28:04 2006 +0000
   108.2 +++ b/src/thread/win32/SDL_syssem.c	Tue Feb 07 06:59:48 2006 +0000
   108.3 @@ -48,7 +48,7 @@
   108.4  	SDL_sem *sem;
   108.5  
   108.6  	/* Allocate sem memory */
   108.7 -	sem = (SDL_sem *)malloc(sizeof(*sem));
   108.8 +	sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
   108.9  	if ( sem ) {
  108.10  		/* Create the semaphore, with max value 32K */
  108.11  #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
  108.12 @@ -59,7 +59,7 @@
  108.13  		sem->count = initial_value;
  108.14  		if ( ! sem->id ) {
  108.15  			SDL_SetError("Couldn't create semaphore");
  108.16 -			free(sem);
  108.17 +			SDL_free(sem);
  108.18  			sem = NULL;
  108.19  		}
  108.20  	} else {
  108.21 @@ -80,7 +80,7 @@
  108.22  #endif
  108.23  			sem->id = 0;
  108.24  		}
  108.25 -		free(sem);
  108.26 +		SDL_free(sem);
  108.27  	}
  108.28  }
  108.29  
   109.1 --- a/src/thread/win32/SDL_systhread.c	Mon Feb 06 17:28:04 2006 +0000
   109.2 +++ b/src/thread/win32/SDL_systhread.c	Tue Feb 07 06:59:48 2006 +0000
   109.3 @@ -47,7 +47,7 @@
   109.4    if (pThreadParms)
   109.5    {
   109.6      pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
   109.7 -    free(pThreadParms);
   109.8 +    SDL_free(pThreadParms);
   109.9    }
  109.10    // Call endthread!
  109.11    if (pfnCurrentEndThread)
  109.12 @@ -58,7 +58,7 @@
  109.13  int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
  109.14  {
  109.15  	unsigned threadid;
  109.16 -    pThreadStartParms pThreadParms = (pThreadStartParms)malloc(sizeof(tThreadStartParms));
  109.17 +    pThreadStartParms pThreadParms = (pThreadStartParms)SDL_malloc(sizeof(tThreadStartParms));
  109.18      if (!pThreadParms) {
  109.19  		SDL_OutOfMemory();
  109.20          return(-1);
   110.1 --- a/src/timer/SDL_timer.c	Mon Feb 06 17:28:04 2006 +0000
   110.2 +++ b/src/timer/SDL_timer.c	Tue Feb 07 06:59:48 2006 +0000
   110.3 @@ -148,7 +148,7 @@
   110.4  					} else {
   110.5  						SDL_timers = next;
   110.6  					}
   110.7 -					free(t);
   110.8 +					SDL_free(t);
   110.9  					--SDL_timer_running;
  110.10  					removed = SDL_TRUE;
  110.11  				}
  110.12 @@ -165,7 +165,7 @@
  110.13  static SDL_TimerID SDL_AddTimerInternal(Uint32 interval, SDL_NewTimerCallback callback, void *param)
  110.14  {
  110.15  	SDL_TimerID t;
  110.16 -	t = (SDL_TimerID) malloc(sizeof(struct _SDL_TimerID));
  110.17 +	t = (SDL_TimerID) SDL_malloc(sizeof(struct _SDL_TimerID));
  110.18  	if ( t ) {
  110.19  		t->interval = ROUND_RESOLUTION(interval);
  110.20  		t->cb = callback;
  110.21 @@ -218,7 +218,7 @@
  110.22  			} else {
  110.23  				SDL_timers = t->next;
  110.24  			}
  110.25 -			free(t);
  110.26 +			SDL_free(t);
  110.27  			--SDL_timer_running;
  110.28  			removed = SDL_TRUE;
  110.29  			list_changed = SDL_TRUE;
  110.30 @@ -256,7 +256,7 @@
  110.31  			while ( SDL_timers ) {
  110.32  				SDL_TimerID freeme = SDL_timers;
  110.33  				SDL_timers = SDL_timers->next;
  110.34 -				free(freeme);
  110.35 +				SDL_free(freeme);
  110.36  			}
  110.37  			SDL_timer_running = 0;
  110.38  			list_changed = SDL_TRUE;
   111.1 --- a/src/timer/linux/SDL_systimer.c	Mon Feb 06 17:28:04 2006 +0000
   111.2 +++ b/src/timer/linux/SDL_systimer.c	Tue Feb 07 06:59:48 2006 +0000
   111.3 @@ -256,7 +256,7 @@
   111.4  	struct sigaction action;
   111.5  
   111.6  	/* Set the alarm handler (Linux specific) */
   111.7 -	memset(&action, 0, sizeof(action));
   111.8 +	SDL_memset(&action, 0, sizeof(action));
   111.9  	action.sa_handler = HandleAlarm;
  111.10  	action.sa_flags = SA_RESTART;
  111.11  	sigemptyset(&action.sa_mask);
  111.12 @@ -285,7 +285,7 @@
  111.13  {
  111.14  	struct itimerval timer;
  111.15  
  111.16 -	memset(&timer, 0, (sizeof timer));
  111.17 +	SDL_memset(&timer, 0, (sizeof timer));
  111.18  	setitimer(ITIMER_REAL, &timer, NULL);
  111.19  }
  111.20  
   112.1 --- a/src/video/SDL_RLEaccel.c	Mon Feb 06 17:28:04 2006 +0000
   112.2 +++ b/src/video/SDL_RLEaccel.c	Tue Feb 07 06:59:48 2006 +0000
   112.3 @@ -1467,7 +1467,7 @@
   112.4      }
   112.5  
   112.6      maxsize += sizeof(RLEDestFormat);
   112.7 -    rlebuf = (Uint8 *)malloc(maxsize);
   112.8 +    rlebuf = (Uint8 *)SDL_malloc(maxsize);
   112.9      if(!rlebuf) {
  112.10  	SDL_OutOfMemory();
  112.11  	return -1;
  112.12 @@ -1597,13 +1597,13 @@
  112.13      /* Now that we have it encoded, release the original pixels */
  112.14      if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
  112.15         && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {
  112.16 -	free( surface->pixels );
  112.17 +	SDL_free( surface->pixels );
  112.18  	surface->pixels = NULL;
  112.19      }
  112.20  
  112.21      /* realloc the buffer to release unused memory */
  112.22      {
  112.23 -	Uint8 *p = realloc(rlebuf, dst - rlebuf);
  112.24 +	Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
  112.25  	if(!p)
  112.26  	    p = rlebuf;
  112.27  	surface->map->sw_data->aux_data = p;
  112.28 @@ -1675,7 +1675,7 @@
  112.29  	    break;
  112.30  	}
  112.31  
  112.32 -	rlebuf = (Uint8 *)malloc(maxsize);
  112.33 +	rlebuf = (Uint8 *)SDL_malloc(maxsize);
  112.34  	if ( rlebuf == NULL ) {
  112.35  		SDL_OutOfMemory();
  112.36  		return(-1);
  112.37 @@ -1731,14 +1731,14 @@
  112.38  		}
  112.39  		len = MIN(run, maxn);
  112.40  		ADD_COUNTS(skip, len);
  112.41 -		memcpy(dst, srcbuf + runstart * bpp, len * bpp);
  112.42 +		SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
  112.43  		dst += len * bpp;
  112.44  		run -= len;
  112.45  		runstart += len;
  112.46  		while(run) {
  112.47  		    len = MIN(run, maxn);
  112.48  		    ADD_COUNTS(0, len);
  112.49 -		    memcpy(dst, srcbuf + runstart * bpp, len * bpp);
  112.50 +		    SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
  112.51  		    dst += len * bpp;
  112.52  		    runstart += len;
  112.53  		    run -= len;
  112.54 @@ -1757,14 +1757,14 @@
  112.55  	/* Now that we have it encoded, release the original pixels */
  112.56  	if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
  112.57  	   && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {
  112.58 -	    free( surface->pixels );
  112.59 +	    SDL_free( surface->pixels );
  112.60  	    surface->pixels = NULL;
  112.61  	}
  112.62  
  112.63  	/* realloc the buffer to release unused memory */
  112.64  	{
  112.65  	    /* If realloc returns NULL, the original block is left intact */
  112.66 -	    Uint8 *p = realloc(rlebuf, dst - rlebuf);
  112.67 +	    Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
  112.68  	    if(!p)
  112.69  		p = rlebuf;
  112.70  	    surface->map->sw_data->aux_data = p;
  112.71 @@ -1845,12 +1845,12 @@
  112.72  	uncopy_opaque = uncopy_transl = uncopy_32;
  112.73      }
  112.74  
  112.75 -    surface->pixels = malloc(surface->h * surface->pitch);
  112.76 +    surface->pixels = SDL_malloc(surface->h * surface->pitch);
  112.77      if ( !surface->pixels ) {
  112.78          return(SDL_FALSE);
  112.79      }
  112.80      /* fill background with transparent pixels */
  112.81 -    memset(surface->pixels, 0, surface->h * surface->pitch);
  112.82 +    SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
  112.83  
  112.84      dst = surface->pixels;
  112.85      srcbuf = (Uint8 *)(df + 1);
  112.86 @@ -1909,7 +1909,7 @@
  112.87  		unsigned alpha_flag;
  112.88  
  112.89  		/* re-create the original surface */
  112.90 -		surface->pixels = malloc(surface->h * surface->pitch);
  112.91 +		surface->pixels = SDL_malloc(surface->h * surface->pitch);
  112.92  		if ( !surface->pixels ) {
  112.93  			/* Oh crap... */
  112.94  			surface->flags |= SDL_RLEACCEL;
  112.95 @@ -1937,7 +1937,7 @@
  112.96  	}
  112.97  
  112.98  	if ( surface->map && surface->map->sw_data->aux_data ) {
  112.99 -	    free(surface->map->sw_data->aux_data);
 112.100 +	    SDL_free(surface->map->sw_data->aux_data);
 112.101  	    surface->map->sw_data->aux_data = NULL;
 112.102  	}
 112.103      }
   113.1 --- a/src/video/SDL_blit_0.c	Mon Feb 06 17:28:04 2006 +0000
   113.2 +++ b/src/video/SDL_blit_0.c	Tue Feb 07 06:59:48 2006 +0000
   113.3 @@ -297,7 +297,7 @@
   113.4  			}
   113.5  			bit = (byte&0x80)>>7;
   113.6  			if ( bit != ckey ) {
   113.7 -				memcpy(dst, &palmap[bit*4], 3);
   113.8 +				SDL_memcpy(dst, &palmap[bit*4], 3);
   113.9  			}
  113.10  			byte <<= 1;
  113.11  			dst += 3;
   114.1 --- a/src/video/SDL_blit_N.c	Mon Feb 06 17:28:04 2006 +0000
   114.2 +++ b/src/video/SDL_blit_N.c	Tue Feb 07 06:59:48 2006 +0000
   114.3 @@ -817,10 +817,10 @@
   114.4      static Uint32 features = 0xffffffff;
   114.5      if (features == 0xffffffff) {
   114.6          /* Provide an override for testing .. */
   114.7 -        char *override = getenv("SDL_ALTIVEC_BLIT_FEATURES");
   114.8 +        char *override = SDL_getenv("SDL_ALTIVEC_BLIT_FEATURES");
   114.9          if (override) {
  114.10              features = 0;
  114.11 -            sscanf(override, "%u", &features);
  114.12 +            SDL_sscanf(override, "%u", &features);
  114.13          } else {
  114.14              features = ( 0
  114.15                  /* Feature 1 is has-MMX */
   115.1 --- a/src/video/SDL_bmp.c	Mon Feb 06 17:28:04 2006 +0000
   115.2 +++ b/src/video/SDL_bmp.c	Tue Feb 07 06:59:48 2006 +0000
   115.3 @@ -98,7 +98,7 @@
   115.4  		was_error = 1;
   115.5  		goto done;
   115.6  	}
   115.7 -	if ( strncmp(magic, "BM", 2) != 0 ) {
   115.8 +	if ( SDL_strncmp(magic, "BM", 2) != 0 ) {
   115.9  		SDL_SetError("File is not a Windows BMP file");
  115.10  		was_error = 1;
  115.11  		goto done;
  115.12 @@ -135,7 +135,7 @@
  115.13  	}
  115.14  
  115.15  	/* Check for read error */
  115.16 -	if ( strcmp(SDL_GetError(), "") != 0 ) {
  115.17 +	if ( SDL_strcmp(SDL_GetError(), "") != 0 ) {
  115.18  		was_error = 1;
  115.19  		goto done;
  115.20  	}
  115.21 @@ -519,7 +519,7 @@
  115.22  	if ( freedst && dst ) {
  115.23  		SDL_RWclose(dst);
  115.24  	}
  115.25 -	return((strcmp(SDL_GetError(), "") == 0) ? 0 : -1);
  115.26 +	return((SDL_strcmp(SDL_GetError(), "") == 0) ? 0 : -1);
  115.27  }
  115.28  
  115.29  #endif /* ENABLE_FILE */
   116.1 --- a/src/video/SDL_cursor.c	Mon Feb 06 17:28:04 2006 +0000
   116.2 +++ b/src/video/SDL_cursor.c	Tue Feb 07 06:59:48 2006 +0000
   116.3 @@ -125,7 +125,7 @@
   116.4  	}
   116.5  
   116.6  	/* Allocate memory for the cursor */
   116.7 -	cursor = (SDL_Cursor *)malloc(sizeof *cursor);
   116.8 +	cursor = (SDL_Cursor *)SDL_malloc(sizeof *cursor);
   116.9  	if ( cursor == NULL ) {
  116.10  		SDL_OutOfMemory();
  116.11  		return(NULL);
  116.12 @@ -137,9 +137,9 @@
  116.13  	cursor->area.h = h;
  116.14  	cursor->hot_x = hot_x;
  116.15  	cursor->hot_y = hot_y;
  116.16 -	cursor->data = (Uint8 *)malloc((w/8)*h*2);
  116.17 +	cursor->data = (Uint8 *)SDL_malloc((w/8)*h*2);
  116.18  	cursor->mask = cursor->data+((w/8)*h);
  116.19 -	cursor->save[0] = (Uint8 *)malloc(savelen*2);
  116.20 +	cursor->save[0] = (Uint8 *)SDL_malloc(savelen*2);
  116.21  	cursor->save[1] = cursor->save[0] + savelen;
  116.22  	cursor->wm_cursor = NULL;
  116.23  	if ( ! cursor->data || ! cursor->save[0] ) {
  116.24 @@ -151,7 +151,7 @@
  116.25  		cursor->data[i] = data[i];
  116.26  		cursor->mask[i] = mask[i] | data[i];
  116.27  	}
  116.28 -	memset(cursor->save[0], 0, savelen*2);
  116.29 +	SDL_memset(cursor->save[0], 0, savelen*2);
  116.30  
  116.31  	/* If the window manager gives us a good cursor, we're done! */
  116.32  	if ( video->CreateWMCursor ) {
  116.33 @@ -244,15 +244,15 @@
  116.34  			SDL_VideoDevice *this  = current_video;
  116.35  
  116.36  			if ( cursor->data ) {
  116.37 -				free(cursor->data);
  116.38 +				SDL_free(cursor->data);
  116.39  			}
  116.40  			if ( cursor->save[0] ) {
  116.41 -				free(cursor->save[0]);
  116.42 +				SDL_free(cursor->save[0]);
  116.43  			}
  116.44  			if ( video && cursor->wm_cursor ) {
  116.45  				video->FreeWMCursor(this, cursor->wm_cursor);
  116.46  			}
  116.47 -			free(cursor);
  116.48 +			SDL_free(cursor);
  116.49  		}
  116.50  	}
  116.51  }
  116.52 @@ -448,7 +448,7 @@
  116.53  				datab = *data++;
  116.54  				for ( i=0; i<8; ++i ) {
  116.55  					if ( maskb & 0x80 ) {
  116.56 -						memset(dst,pixels[datab>>7],3);
  116.57 +						SDL_memset(dst,pixels[datab>>7],3);
  116.58  					}
  116.59  					maskb <<= 1;
  116.60  					datab <<= 1;
  116.61 @@ -523,7 +523,7 @@
  116.62  				}
  116.63  				if ( (x >= minx) && (x < maxx) ) {
  116.64  					if ( maskb & 0x80 ) {
  116.65 -						memset(dst, pixels8[datab>>7], dstbpp);
  116.66 +						SDL_memset(dst, pixels8[datab>>7], dstbpp);
  116.67  					}
  116.68  				}
  116.69  				maskb <<= 1;
  116.70 @@ -541,7 +541,7 @@
  116.71  				}
  116.72  				if ( (x >= minx) && (x < maxx) ) {
  116.73  					if ( maskb & 0x80 ) {
  116.74 -						memset(dst, pixels[datab>>7], dstbpp);
  116.75 +						SDL_memset(dst, pixels[datab>>7], dstbpp);
  116.76  					}
  116.77  				}
  116.78  				maskb <<= 1;
  116.79 @@ -616,7 +616,7 @@
  116.80  	  w = area.w*screenbpp;
  116.81  	  h = area.h;
  116.82  	  while ( h-- ) {
  116.83 -		  memcpy(dst, src, w);
  116.84 +		  SDL_memcpy(dst, src, w);
  116.85  		  dst += w;
  116.86  		  src += screen->pitch;
  116.87  	  }
  116.88 @@ -694,7 +694,7 @@
  116.89  	  w = area.w*screenbpp;
  116.90  	  h = area.h;
  116.91  	  while ( h-- ) {
  116.92 -		  memcpy(dst, src, w);
  116.93 +		  SDL_memcpy(dst, src, w);
  116.94  		  src += w;
  116.95  		  dst += screen->pitch;
  116.96  	  }
  116.97 @@ -748,6 +748,6 @@
  116.98  		savelen = SDL_cursor->area.w*4*SDL_cursor->area.h;
  116.99  		SDL_cursor->area.x = 0;
 116.100  		SDL_cursor->area.y = 0;
 116.101 -		memset(SDL_cursor->save[0], 0, savelen);
 116.102 +		SDL_memset(SDL_cursor->save[0], 0, savelen);
 116.103  	}
 116.104  }
   117.1 --- a/src/video/SDL_gamma.c	Mon Feb 06 17:28:04 2006 +0000
   117.2 +++ b/src/video/SDL_gamma.c	Tue Feb 07 06:59:48 2006 +0000
   117.3 @@ -165,13 +165,13 @@
   117.4  
   117.5  	/* Fill the gamma table with the new values */
   117.6  	if ( red ) {
   117.7 -		memcpy(&video->gamma[0*256], red, 256*sizeof(*video->gamma));
   117.8 +		SDL_memcpy(&video->gamma[0*256], red, 256*sizeof(*video->gamma));
   117.9  	}
  117.10  	if ( green ) {
  117.11 -		memcpy(&video->gamma[1*256], green, 256*sizeof(*video->gamma));
  117.12 +		SDL_memcpy(&video->gamma[1*256], green, 256*sizeof(*video->gamma));
  117.13  	}
  117.14  	if ( blue ) {
  117.15 -		memcpy(&video->gamma[2*256], blue, 256*sizeof(*video->gamma));
  117.16 +		SDL_memcpy(&video->gamma[2*256], blue, 256*sizeof(*video->gamma));
  117.17  	}
  117.18  
  117.19  	/* Gamma correction always possible on split palettes */
  117.20 @@ -204,7 +204,7 @@
  117.21  
  117.22  	/* Lazily allocate the gamma table */
  117.23  	if ( ! video->gamma ) {
  117.24 -		video->gamma = malloc(3*256*sizeof(*video->gamma));
  117.25 +		video->gamma = SDL_malloc(3*256*sizeof(*video->gamma));
  117.26  		if ( ! video->gamma ) {
  117.27  			SDL_OutOfMemory();
  117.28  			return -1;
  117.29 @@ -225,13 +225,13 @@
  117.30  
  117.31  	/* Just copy from our internal table */
  117.32  	if ( red ) {
  117.33 -		memcpy(red, &video->gamma[0*256], 256*sizeof(*red));
  117.34 +		SDL_memcpy(red, &video->gamma[0*256], 256*sizeof(*red));
  117.35  	}
  117.36  	if ( green ) {
  117.37 -		memcpy(green, &video->gamma[1*256], 256*sizeof(*green));
  117.38 +		SDL_memcpy(green, &video->gamma[1*256], 256*sizeof(*green));
  117.39  	}
  117.40  	if ( blue ) {
  117.41 -		memcpy(blue, &video->gamma[2*256], 256*sizeof(*blue));
  117.42 +		SDL_memcpy(blue, &video->gamma[2*256], 256*sizeof(*blue));
  117.43  	}
  117.44  	return 0;
  117.45  }
   118.1 --- a/src/video/SDL_pixels.c	Mon Feb 06 17:28:04 2006 +0000
   118.2 +++ b/src/video/SDL_pixels.c	Tue Feb 07 06:59:48 2006 +0000
   118.3 @@ -43,12 +43,12 @@
   118.4  	Uint32 mask;
   118.5  
   118.6  	/* Allocate an empty pixel format structure */
   118.7 -	format = malloc(sizeof(*format));
   118.8 +	format = SDL_malloc(sizeof(*format));
   118.9  	if ( format == NULL ) {
  118.10  		SDL_OutOfMemory();
  118.11  		return(NULL);
  118.12  	}
  118.13 -	memset(format, 0, sizeof(*format));
  118.14 +	SDL_memset(format, 0, sizeof(*format));
  118.15  	format->alpha = SDL_ALPHA_OPAQUE;
  118.16  
  118.17  	/* Set up the format */
  118.18 @@ -125,14 +125,14 @@
  118.19  #ifdef DEBUG_PALETTE
  118.20  		fprintf(stderr,"bpp=%d ncolors=%d\n",bpp,ncolors);
  118.21  #endif
  118.22 -		format->palette = (SDL_Palette *)malloc(sizeof(SDL_Palette));
  118.23 +		format->palette = (SDL_Palette *)SDL_malloc(sizeof(SDL_Palette));
  118.24  		if ( format->palette == NULL ) {
  118.25  			SDL_FreeFormat(format);
  118.26  			SDL_OutOfMemory();
  118.27  			return(NULL);
  118.28  		}
  118.29  		(format->palette)->ncolors = ncolors;
  118.30 -		(format->palette)->colors = (SDL_Color *)malloc(
  118.31 +		(format->palette)->colors = (SDL_Color *)SDL_malloc(
  118.32  				(format->palette)->ncolors*sizeof(SDL_Color));
  118.33  		if ( (format->palette)->colors == NULL ) {
  118.34  			SDL_FreeFormat(format);
  118.35 @@ -217,7 +217,7 @@
  118.36  			format->palette->colors[1].b = 0x00;
  118.37  		} else {
  118.38  			/* Create an empty palette */
  118.39 -			memset((format->palette)->colors, 0,
  118.40 +			SDL_memset((format->palette)->colors, 0,
  118.41  				(format->palette)->ncolors*sizeof(SDL_Color));
  118.42  		}
  118.43  	}
  118.44 @@ -255,11 +255,11 @@
  118.45  	if ( format ) {
  118.46  		if ( format->palette ) {
  118.47  			if ( format->palette->colors ) {
  118.48 -				free(format->palette->colors);
  118.49 +				SDL_free(format->palette->colors);
  118.50  			}
  118.51 -			free(format->palette);
  118.52 +			SDL_free(format->palette);
  118.53  		}
  118.54 -		free(format);
  118.55 +		SDL_free(format);
  118.56  	}
  118.57  }
  118.58  /*
  118.59 @@ -438,7 +438,7 @@
  118.60  	if ( identical ) {
  118.61  		if ( src->ncolors <= dst->ncolors ) {
  118.62  			/* If an identical palette, no need to map */
  118.63 -			if ( memcmp(src->colors, dst->colors, src->ncolors*
  118.64 +			if ( SDL_memcmp(src->colors, dst->colors, src->ncolors*
  118.65  						sizeof(SDL_Color)) == 0 ) {
  118.66  				*identical = 1;
  118.67  				return(NULL);
  118.68 @@ -446,7 +446,7 @@
  118.69  		}
  118.70  		*identical = 0;
  118.71  	}
  118.72 -	map = (Uint8 *)malloc(src->ncolors);
  118.73 +	map = (Uint8 *)SDL_malloc(src->ncolors);
  118.74  	if ( map == NULL ) {
  118.75  		SDL_OutOfMemory();
  118.76  		return(NULL);
  118.77 @@ -466,7 +466,7 @@
  118.78  	unsigned alpha;
  118.79  
  118.80  	bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
  118.81 -	map = (Uint8 *)malloc(src->ncolors*bpp);
  118.82 +	map = (Uint8 *)SDL_malloc(src->ncolors*bpp);
  118.83  	if ( map == NULL ) {
  118.84  		SDL_OutOfMemory();
  118.85  		return(NULL);
  118.86 @@ -490,7 +490,7 @@
  118.87  	
  118.88  	/* SDL_DitherColors does not initialize the 'unused' component of colors,
  118.89  	   but Map1to1 compares it against dst, so we should initialize it. */  
  118.90 -	memset(colors, 0, sizeof(colors));
  118.91 +	SDL_memset(colors, 0, sizeof(colors));
  118.92  
  118.93  	dithered.ncolors = 256;
  118.94  	SDL_DitherColors(colors, 8);
  118.95 @@ -503,21 +503,21 @@
  118.96  	SDL_BlitMap *map;
  118.97  
  118.98  	/* Allocate the empty map */
  118.99 -	map = (SDL_BlitMap *)malloc(sizeof(*map));
 118.100 +	map = (SDL_BlitMap *)SDL_malloc(sizeof(*map));
 118.101  	if ( map == NULL ) {
 118.102  		SDL_OutOfMemory();
 118.103  		return(NULL);
 118.104  	}
 118.105 -	memset(map, 0, sizeof(*map));
 118.106 +	SDL_memset(map, 0, sizeof(*map));
 118.107  
 118.108  	/* Allocate the software blit data */
 118.109 -	map->sw_data = (struct private_swaccel *)malloc(sizeof(*map->sw_data));
 118.110 +	map->sw_data = (struct private_swaccel *)SDL_malloc(sizeof(*map->sw_data));
 118.111  	if ( map->sw_data == NULL ) {
 118.112  		SDL_FreeBlitMap(map);
 118.113  		SDL_OutOfMemory();
 118.114  		return(NULL);
 118.115  	}
 118.116 -	memset(map->sw_data, 0, sizeof(*map->sw_data));
 118.117 +	SDL_memset(map->sw_data, 0, sizeof(*map->sw_data));
 118.118  
 118.119  	/* It's ready to go */
 118.120  	return(map);
 118.121 @@ -530,7 +530,7 @@
 118.122  	map->dst = NULL;
 118.123  	map->format_version = (unsigned int)-1;
 118.124  	if ( map->table ) {
 118.125 -		free(map->table);
 118.126 +		SDL_free(map->table);
 118.127  		map->table = NULL;
 118.128  	}
 118.129  }
 118.130 @@ -615,8 +615,8 @@
 118.131  	if ( map ) {
 118.132  		SDL_InvalidateMap(map);
 118.133  		if ( map->sw_data != NULL ) {
 118.134 -			free(map->sw_data);
 118.135 +			SDL_free(map->sw_data);
 118.136  		}
 118.137 -		free(map);
 118.138 +		SDL_free(map);
 118.139  	}
 118.140  }
   119.1 --- a/src/video/SDL_surface.c	Mon Feb 06 17:28:04 2006 +0000
   119.2 +++ b/src/video/SDL_surface.c	Tue Feb 07 06:59:48 2006 +0000
   119.3 @@ -77,7 +77,7 @@
   119.4  	}
   119.5  
   119.6  	/* Allocate the surface */
   119.7 -	surface = (SDL_Surface *)malloc(sizeof(*surface));
   119.8 +	surface = (SDL_Surface *)SDL_malloc(sizeof(*surface));
   119.9  	if ( surface == NULL ) {
  119.10  		SDL_OutOfMemory();
  119.11  		return(NULL);
  119.12 @@ -103,7 +103,7 @@
  119.13  	}
  119.14  	surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
  119.15  	if ( surface->format == NULL ) {
  119.16 -		free(surface);
  119.17 +		SDL_free(surface);
  119.18  		return(NULL);
  119.19  	}
  119.20  	if ( Amask ) {
  119.21 @@ -125,14 +125,14 @@
  119.22  	if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) || 
  119.23  				(video->AllocHWSurface(this, surface) < 0) ) {
  119.24  		if ( surface->w && surface->h ) {
  119.25 -			surface->pixels = malloc(surface->h*surface->pitch);
  119.26 +			surface->pixels = SDL_malloc(surface->h*surface->pitch);
  119.27  			if ( surface->pixels == NULL ) {
  119.28  				SDL_FreeSurface(surface);
  119.29  				SDL_OutOfMemory();
  119.30  				return(NULL);
  119.31  			}
  119.32  			/* This is important for bitmaps */
  119.33 -			memset(surface->pixels, 0, surface->h*surface->pitch);
  119.34 +			SDL_memset(surface->pixels, 0, surface->h*surface->pitch);
  119.35  		}
  119.36  	}
  119.37  
  119.38 @@ -615,7 +615,7 @@
  119.39  		} else {
  119.40  #ifdef __powerpc__
  119.41  			/*
  119.42 -			 * memset() on PPC (both glibc and codewarrior) uses
  119.43 +			 * SDL_memset() on PPC (both glibc and codewarrior) uses
  119.44  			 * the dcbz (Data Cache Block Zero) instruction, which
  119.45  			 * causes an alignment exception if the destination is
  119.46  			 * uncachable, so only use it on software surfaces
  119.47 @@ -627,7 +627,7 @@
  119.48  					 * efficient to uncached video memory
  119.49  					 */
  119.50  					double fill;
  119.51 -					memset(&fill, color, (sizeof fill));
  119.52 +					SDL_memset(&fill, color, (sizeof fill));
  119.53  					for(y = dstrect->h; y; y--) {
  119.54  						Uint8 *d = row;
  119.55  						unsigned n = x;
  119.56 @@ -679,7 +679,7 @@
  119.57  #endif /* __powerpc__ */
  119.58  			{
  119.59  				for(y = dstrect->h; y; y--) {
  119.60 -					memset(row, color, x);
  119.61 +					SDL_memset(row, color, x);
  119.62  					row += dst->pitch;
  119.63  				}
  119.64  			}
  119.65 @@ -711,7 +711,7 @@
  119.66  			for ( y=dstrect->h; y; --y ) {
  119.67  				Uint8 *pixels = row;
  119.68  				for ( x=dstrect->w; x; --x ) {
  119.69 -					memcpy(pixels, &color, 3);
  119.70 +					SDL_memcpy(pixels, &color, 3);
  119.71  					pixels += 3;
  119.72  				}
  119.73  				row += dst->pitch;
  119.74 @@ -832,7 +832,7 @@
  119.75  
  119.76  	/* Copy the palette if any */
  119.77  	if ( format->palette && convert->format->palette ) {
  119.78 -		memcpy(convert->format->palette->colors,
  119.79 +		SDL_memcpy(convert->format->palette->colors,
  119.80  				format->palette->colors,
  119.81  				format->palette->ncolors*sizeof(SDL_Color));
  119.82  		convert->format->palette->ncolors = format->palette->ncolors;
  119.83 @@ -934,9 +934,9 @@
  119.84  	}
  119.85  	if ( surface->pixels &&
  119.86  	     ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) {
  119.87 -		free(surface->pixels);
  119.88 +		SDL_free(surface->pixels);
  119.89  	}
  119.90 -	free(surface);
  119.91 +	SDL_free(surface);
  119.92  #ifdef CHECK_LEAKS
  119.93  	--surfaces_allocated;
  119.94  #endif
   120.1 --- a/src/video/SDL_video.c	Mon Feb 06 17:28:04 2006 +0000
   120.2 +++ b/src/video/SDL_video.c	Tue Feb 07 06:59:48 2006 +0000
   120.3 @@ -175,13 +175,13 @@
   120.4  	video = NULL;
   120.5  	if ( driver_name != NULL ) {
   120.6  #if 0	/* This will be replaced with a better driver selection API */
   120.7 -		if ( strrchr(driver_name, ':') != NULL ) {
   120.8 -			index = atoi(strrchr(driver_name, ':')+1);
   120.9 +		if ( SDL_strrchr(driver_name, ':') != NULL ) {
  120.10 +			index = atoi(SDL_strrchr(driver_name, ':')+1);
  120.11  		}
  120.12  #endif
  120.13  		for ( i=0; bootstrap[i]; ++i ) {
  120.14 -			if ( strncmp(bootstrap[i]->name, driver_name,
  120.15 -			             strlen(bootstrap[i]->name)) == 0 ) {
  120.16 +			if ( SDL_strncmp(bootstrap[i]->name, driver_name,
  120.17 +			             SDL_strlen(bootstrap[i]->name)) == 0 ) {
  120.18  				if ( bootstrap[i]->available() ) {
  120.19  					video = bootstrap[i]->create(index);
  120.20  					break;
  120.21 @@ -216,7 +216,7 @@
  120.22  	video->wm_icon  = NULL;
  120.23  	video->offset_x = 0;
  120.24  	video->offset_y = 0;
  120.25 -	memset(&video->info, 0, (sizeof video->info));
  120.26 +	SDL_memset(&video->info, 0, (sizeof video->info));
  120.27  	
  120.28  	video->displayformatalphapixel = NULL;
  120.29  
  120.30 @@ -244,7 +244,7 @@
  120.31  	video->gl_config.multisamplesamples = 0;
  120.32  	
  120.33  	/* Initialize the video subsystem */
  120.34 -	memset(&vformat, 0, sizeof(vformat));
  120.35 +	SDL_memset(&vformat, 0, sizeof(vformat));
  120.36  	if ( video->VideoInit(video, &vformat) < 0 ) {
  120.37  		SDL_VideoQuit();
  120.38  		return(-1);
  120.39 @@ -289,7 +289,7 @@
  120.40  char *SDL_VideoDriverName(char *namebuf, int maxlen)
  120.41  {
  120.42  	if ( current_video != NULL ) {
  120.43 -		strncpy(namebuf, current_video->name, maxlen-1);
  120.44 +		SDL_strncpy(namebuf, current_video->name, maxlen-1);
  120.45  		namebuf[maxlen-1] = '\0';
  120.46  		return(namebuf);
  120.47  	}
  120.48 @@ -389,7 +389,7 @@
  120.49  	}
  120.50  
  120.51  	/* Search through the list valid of modes */
  120.52 -	memset(&format, 0, sizeof(format));
  120.53 +	SDL_memset(&format, 0, sizeof(format));
  120.54  	supported = 0;
  120.55  	table = ((bpp+7)/8)-1;
  120.56  	SDL_closest_depths[table][0] = bpp;
  120.57 @@ -461,7 +461,7 @@
  120.58  	}
  120.59  
  120.60  	/* No exact size match at any depth, look for closest match */
  120.61 -	memset(&format, 0, sizeof(format));
  120.62 +	SDL_memset(&format, 0, sizeof(format));
  120.63  	supported = 0;
  120.64  	table = ((*BitsPerPixel+7)/8)-1;
  120.65  	SDL_closest_depths[table][0] = *BitsPerPixel;
  120.66 @@ -541,7 +541,7 @@
  120.67  	if ( SDL_ShadowSurface->format->palette ) {
  120.68  		SDL_ShadowSurface->flags |= SDL_HWPALETTE;
  120.69  		if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
  120.70 -			memcpy(SDL_ShadowSurface->format->palette->colors,
  120.71 +			SDL_memcpy(SDL_ShadowSurface->format->palette->colors,
  120.72  				SDL_VideoSurface->format->palette->colors,
  120.73  				SDL_VideoSurface->format->palette->ncolors*
  120.74  							sizeof(SDL_Color));
  120.75 @@ -649,12 +649,12 @@
  120.76  		SDL_FreeSurface(ready_to_go);
  120.77  	}
  120.78  	if ( video->physpal ) {
  120.79 -		free(video->physpal->colors);
  120.80 -		free(video->physpal);
  120.81 +		SDL_free(video->physpal->colors);
  120.82 +		SDL_free(video->physpal);
  120.83  		video->physpal = NULL;
  120.84  	}
  120.85  	if( video->gammacols) {
  120.86 -		free(video->gammacols);
  120.87 +		SDL_free(video->gammacols);
  120.88  		video->gammacols = NULL;
  120.89  	}
  120.90  
  120.91 @@ -797,7 +797,7 @@
  120.92  		   support the GL_UNSIGNED_SHORT_5_6_5 texture format.
  120.93  		 */
  120.94  		if ( (bpp == 16) &&
  120.95 -		     (strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
  120.96 +		     (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
  120.97  		     (atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
  120.98  		   ) {
  120.99  			video->is_32bit = 0;
 120.100 @@ -843,7 +843,7 @@
 120.101  		SDL_FreeSurface(mode);
 120.102  
 120.103  		/* Set the surface completely opaque & white by default */
 120.104 -		memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
 120.105 +		SDL_memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
 120.106  		video->glGenTextures( 1, &video->texture );
 120.107  		video->glBindTexture( GL_TEXTURE_2D, video->texture );
 120.108  		video->glTexImage2D(
 120.109 @@ -1134,7 +1134,7 @@
 120.110  	SDL_Palette *vidpal;
 120.111  
 120.112  	if ( colors != (pal->colors + firstcolor) ) {
 120.113 -		memcpy(pal->colors + firstcolor, colors,
 120.114 +		SDL_memcpy(pal->colors + firstcolor, colors,
 120.115  		       ncolors * sizeof(*colors));
 120.116  	}
 120.117  
 120.118 @@ -1146,7 +1146,7 @@
 120.119  		 * changes to its logical palette so that
 120.120  		 * updates are always identity blits
 120.121  		 */
 120.122 -		memcpy(vidpal->colors + firstcolor, colors,
 120.123 +		SDL_memcpy(vidpal->colors + firstcolor, colors,
 120.124  		       ncolors * sizeof(*colors));
 120.125  	}
 120.126  	SDL_FormatChanged(screen);
 120.127 @@ -1162,7 +1162,7 @@
 120.128  		/* We need to copy the new colors, since we haven't
 120.129  		 * already done the copy in the logical set above.
 120.130  		 */
 120.131 -		memcpy(video->physpal->colors + firstcolor,
 120.132 +		SDL_memcpy(video->physpal->colors + firstcolor,
 120.133  		       colors, ncolors * sizeof(*colors));
 120.134  	}
 120.135  	if ( screen == SDL_ShadowSurface ) {
 120.136 @@ -1187,7 +1187,7 @@
 120.137  					SDL_Palette *pp = video->physpal;
 120.138  					if(!pp)
 120.139  						pp = screen->format->palette;
 120.140 -					video->gammacols = malloc(pp->ncolors
 120.141 +					video->gammacols = SDL_malloc(pp->ncolors
 120.142  							  * sizeof(SDL_Color));
 120.143  					SDL_ApplyGamma(video->gamma,
 120.144  						       pp->colors,
 120.145 @@ -1284,18 +1284,18 @@
 120.146  		if(!video->physpal && !(which & SDL_LOGPAL) ) {
 120.147  			/* Lazy physical palette allocation */
 120.148  			int size;
 120.149 -			SDL_Palette *pp = malloc(sizeof(*pp));
 120.150 +			SDL_Palette *pp = SDL_malloc(sizeof(*pp));
 120.151  			if ( !pp ) {
 120.152  				return 0;
 120.153  			}
 120.154  			current_video->physpal = pp;
 120.155  			pp->ncolors = pal->ncolors;
 120.156  			size = pp->ncolors * sizeof(SDL_Color);
 120.157 -			pp->colors = malloc(size);
 120.158 +			pp->colors = SDL_malloc(size);
 120.159  			if ( !pp->colors ) {
 120.160  				return 0;
 120.161  			}
 120.162 -			memcpy(pp->colors, pal->colors, size);
 120.163 +			SDL_memcpy(pp->colors, pal->colors, size);
 120.164  		}
 120.165  		if ( ! SetPalette_physical(screen,
 120.166  		                           colors, firstcolor, ncolors) ) {
 120.167 @@ -1351,24 +1351,24 @@
 120.168  
 120.169  		/* Clean up miscellaneous memory */
 120.170  		if ( video->physpal ) {
 120.171 -			free(video->physpal->colors);
 120.172 -			free(video->physpal);
 120.173 +			SDL_free(video->physpal->colors);
 120.174 +			SDL_free(video->physpal);
 120.175  			video->physpal = NULL;
 120.176  		}
 120.177  		if ( video->gammacols ) {
 120.178 -			free(video->gammacols);
 120.179 +			SDL_free(video->gammacols);
 120.180  			video->gammacols = NULL;
 120.181  		}
 120.182  		if ( video->gamma ) {
 120.183 -			free(video->gamma);
 120.184 +			SDL_free(video->gamma);
 120.185  			video->gamma = NULL;
 120.186  		}
 120.187  		if ( video->wm_title != NULL ) {
 120.188 -			free(video->wm_title);
 120.189 +			SDL_free(video->wm_title);
 120.190  			video->wm_title = NULL;
 120.191  		}
 120.192  		if ( video->wm_icon != NULL ) {
 120.193 -			free(video->wm_icon);
 120.194 +			SDL_free(video->wm_icon);
 120.195  			video->wm_icon = NULL;
 120.196  		}
 120.197  
 120.198 @@ -1668,20 +1668,20 @@
 120.199  	if ( video ) {
 120.200  		if ( title ) {
 120.201  			if ( video->wm_title ) {
 120.202 -				free(video->wm_title);
 120.203 +				SDL_free(video->wm_title);
 120.204  			}
 120.205 -			video->wm_title = (char *)malloc(strlen(title)+1);
 120.206 +			video->wm_title = (char *)SDL_malloc(SDL_strlen(title)+1);
 120.207  			if ( video->wm_title != NULL ) {
 120.208 -				strcpy(video->wm_title, title);
 120.209 +				SDL_strcpy(video->wm_title, title);
 120.210  			}
 120.211  		}
 120.212  		if ( icon ) {
 120.213  			if ( video->wm_icon ) {
 120.214 -				free(video->wm_icon);
 120.215 +				SDL_free(video->wm_icon);
 120.216  			}
 120.217 -			video->wm_icon = (char *)malloc(strlen(icon)+1);
 120.218 +			video->wm_icon = (char *)SDL_malloc(SDL_strlen(icon)+1);
 120.219  			if ( video->wm_icon != NULL ) {
 120.220 -				strcpy(video->wm_icon, icon);
 120.221 +				SDL_strcpy(video->wm_icon, icon);
 120.222  			}
 120.223  		}
 120.224  		if ( (title || icon) && (video->SetCaption != NULL) ) {
 120.225 @@ -1773,18 +1773,18 @@
 120.226  		if ( mask == NULL ) {
 120.227  			int mask_len = icon->h*(icon->w+7)/8;
 120.228  			int flags = 0;
 120.229 -			mask = (Uint8 *)malloc(mask_len);
 120.230 +			mask = (Uint8 *)SDL_malloc(mask_len);
 120.231  			if ( mask == NULL ) {
 120.232  				return;
 120.233  			}
 120.234 -			memset(mask, ~0, mask_len);
 120.235 +			SDL_memset(mask, ~0, mask_len);
 120.236  			if ( icon->flags & SDL_SRCCOLORKEY ) flags |= 1;
 120.237  			if ( icon->flags & SDL_SRCALPHA ) flags |= 2;
 120.238  			if( flags ) {
 120.239  				CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
 120.240  			}
 120.241  			video->SetIcon(video, icon, mask);
 120.242 -			free(mask);
 120.243 +			SDL_free(mask);
 120.244  		} else {
 120.245  			video->SetIcon(this, icon, mask);
 120.246  		}
   121.1 --- a/src/video/SDL_yuv.c	Mon Feb 06 17:28:04 2006 +0000
   121.2 +++ b/src/video/SDL_yuv.c	Tue Feb 07 06:59:48 2006 +0000
   121.3 @@ -44,7 +44,7 @@
   121.4  	}
   121.5  
   121.6  	/* Display directly on video surface, if possible */
   121.7 -	if ( getenv("SDL_VIDEO_YUV_DIRECT") ) {
   121.8 +	if ( SDL_getenv("SDL_VIDEO_YUV_DIRECT") ) {
   121.9  		if ( (display == SDL_PublicSurface) &&
  121.10  		     ((SDL_VideoSurface->format->BytesPerPixel == 2) ||
  121.11  		      (SDL_VideoSurface->format->BytesPerPixel == 4)) ) {
  121.12 @@ -52,7 +52,7 @@
  121.13  		}
  121.14  	}
  121.15  	overlay = NULL;
  121.16 -        yuv_hwaccel = getenv("SDL_VIDEO_YUV_HWACCEL");
  121.17 +        yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL");
  121.18  	if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
  121.19  	     (!yuv_hwaccel || (*yuv_hwaccel != '0')) ) {
  121.20  		overlay = video->CreateYUVOverlay(this, w, h, format, display);
  121.21 @@ -85,6 +85,6 @@
  121.22  		if ( overlay->hwfuncs ) {
  121.23  			overlay->hwfuncs->FreeHW(current_video, overlay);
  121.24  		}
  121.25 -		free(overlay);
  121.26 +		SDL_free(overlay);
  121.27  	}
  121.28  }
   122.1 --- a/src/video/SDL_yuv_sw.c	Mon Feb 06 17:28:04 2006 +0000
   122.2 +++ b/src/video/SDL_yuv_sw.c	Tue Feb 07 06:59:48 2006 +0000
   122.3 @@ -960,12 +960,12 @@
   122.4  	}
   122.5  
   122.6  	/* Create the overlay structure */
   122.7 -	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
   122.8 +	overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay);
   122.9  	if ( overlay == NULL ) {
  122.10  		SDL_OutOfMemory();
  122.11  		return(NULL);
  122.12  	}
  122.13 -	memset(overlay, 0, (sizeof *overlay));
  122.14 +	SDL_memset(overlay, 0, (sizeof *overlay));
  122.15  
  122.16  	/* Fill in the basic members */
  122.17  	overlay->format = format;
  122.18 @@ -976,7 +976,7 @@
  122.19  	overlay->hwfuncs = &sw_yuvfuncs;
  122.20  
  122.21  	/* Create the pixel data and lookup tables */
  122.22 -	swdata = (struct private_yuvhwdata *)malloc(sizeof *swdata);
  122.23 +	swdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *swdata);
  122.24  	overlay->hwdata = swdata;
  122.25  	if ( swdata == NULL ) {
  122.26  		SDL_OutOfMemory();
  122.27 @@ -985,13 +985,13 @@
  122.28  	}
  122.29  	swdata->stretch = NULL;
  122.30  	swdata->display = display;
  122.31 -	swdata->pixels = (Uint8 *) malloc(width*height*2);
  122.32 -	swdata->colortab = (int *)malloc(4*256*sizeof(int));
  122.33 +	swdata->pixels = (Uint8 *) SDL_malloc(width*height*2);
  122.34 +	swdata->colortab = (int *)SDL_malloc(4*256*sizeof(int));
  122.35  	Cr_r_tab = &swdata->colortab[0*256];
  122.36  	Cr_g_tab = &swdata->colortab[1*256];
  122.37  	Cb_g_tab = &swdata->colortab[2*256];
  122.38  	Cb_b_tab = &swdata->colortab[3*256];
  122.39 -	swdata->rgb_2_pix = (Uint32 *)malloc(3*768*sizeof(Uint32));
  122.40 +	swdata->rgb_2_pix = (Uint32 *)SDL_malloc(3*768*sizeof(Uint32));
  122.41  	r_2_pix_alloc = &swdata->rgb_2_pix[0*768];
  122.42  	g_2_pix_alloc = &swdata->rgb_2_pix[1*768];
  122.43  	b_2_pix_alloc = &swdata->rgb_2_pix[2*768];
  122.44 @@ -1279,14 +1279,14 @@
  122.45  			SDL_FreeSurface(swdata->stretch);
  122.46  		}
  122.47  		if ( swdata->pixels ) {
  122.48 -			free(swdata->pixels);
  122.49 +			SDL_free(swdata->pixels);
  122.50  		}
  122.51  		if ( swdata->colortab ) {
  122.52 -			free(swdata->colortab);
  122.53 +			SDL_free(swdata->colortab);
  122.54  		}
  122.55  		if ( swdata->rgb_2_pix ) {
  122.56 -			free(swdata->rgb_2_pix);
  122.57 +			SDL_free(swdata->rgb_2_pix);
  122.58  		}
  122.59 -		free(swdata);
  122.60 +		SDL_free(swdata);
  122.61  	}
  122.62  }
   123.1 --- a/src/video/Xext/Xv/Xv.c	Mon Feb 06 17:28:04 2006 +0000
   123.2 +++ b/src/video/Xext/Xv/Xv.c	Tue Feb 07 06:59:48 2006 +0000
   123.3 @@ -234,7 +234,7 @@
   123.4            SyncHandle();
   123.5  	  return(XvBadAlloc);
   123.6  	}
   123.7 -      (void)strncpy(name, u.string, size);
   123.8 +      (void)SDL_strncpy(name, u.string, size);
   123.9        name[size] = '\0';
  123.10        pa->name = name;
  123.11  
  123.12 @@ -386,7 +386,7 @@
  123.13            SyncHandle();
  123.14  	  return(XvBadAlloc);
  123.15        }
  123.16 -      strncpy(name, u.string, size);
  123.17 +      SDL_strncpy(name, u.string, size);
  123.18        name[size] = '\0';
  123.19        pe->name = name;
  123.20        pe++;
  123.21 @@ -902,7 +902,7 @@
  123.22  	      ret[i].id = Info.id;	      
  123.23  	      ret[i].type = Info.type;	      
  123.24  	      ret[i].byte_order = Info.byte_order;	      
  123.25 -	      memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16);
  123.26 +	      SDL_memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16);
  123.27  	      ret[i].bits_per_pixel = Info.bpp;	      
  123.28    	      ret[i].format = Info.format;	      
  123.29     	      ret[i].num_planes = Info.num_planes;	      
  123.30 @@ -919,7 +919,7 @@
  123.31      	      ret[i].vert_y_period = Info.vert_y_period;
  123.32      	      ret[i].vert_u_period = Info.vert_u_period;
  123.33      	      ret[i].vert_v_period = Info.vert_v_period;
  123.34 -	      memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32);
  123.35 +	      SDL_memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32);
  123.36      	      ret[i].scanline_order = Info.scanline_order;
  123.37  	      (*num)++;
  123.38  	  }
   124.1 --- a/src/video/Xext/Xxf86dga/XF86DGA.c	Mon Feb 06 17:28:04 2006 +0000
   124.2 +++ b/src/video/Xext/Xxf86dga/XF86DGA.c	Tue Feb 07 06:59:48 2006 +0000
   124.3 @@ -407,12 +407,12 @@
   124.4      MapPtr *old;
   124.5  
   124.6      old = mapList;
   124.7 -    mapList = realloc(mapList, sizeof(MapPtr) * (numMaps + 1));
   124.8 +    mapList = SDL_realloc(mapList, sizeof(MapPtr) * (numMaps + 1));
   124.9      if (!mapList) {
  124.10  	mapList = old;
  124.11  	return NULL;
  124.12      }
  124.13 -    mapList[numMaps] = malloc(sizeof(MapRec));
  124.14 +    mapList[numMaps] = SDL_malloc(sizeof(MapRec));
  124.15      if (!mapList[numMaps])
  124.16  	return NULL;
  124.17      return mapList[numMaps++];
  124.18 @@ -424,12 +424,12 @@
  124.19      ScrPtr *old;
  124.20  
  124.21      old = scrList;
  124.22 -    scrList = realloc(scrList, sizeof(ScrPtr) * (numScrs + 1));
  124.23 +    scrList = SDL_realloc(scrList, sizeof(ScrPtr) * (numScrs + 1));
  124.24      if (!scrList) {
  124.25  	scrList = old;
  124.26  	return NULL;
  124.27      }
  124.28 -    scrList[numScrs] = malloc(sizeof(ScrRec));
  124.29 +    scrList[numScrs] = SDL_malloc(sizeof(ScrRec));
  124.30      if (!scrList[numScrs])
  124.31  	return NULL;
  124.32      return scrList[numScrs++];
   125.1 --- a/src/video/aalib/SDL_aavideo.c	Mon Feb 06 17:28:04 2006 +0000
   125.2 +++ b/src/video/aalib/SDL_aavideo.c	Tue Feb 07 06:59:48 2006 +0000
   125.3 @@ -70,8 +70,8 @@
   125.4  
   125.5  static void AA_DeleteDevice(SDL_VideoDevice *device)
   125.6  {
   125.7 -	free(device->hidden);
   125.8 -	free(device);
   125.9 +	SDL_free(device->hidden);
  125.10 +	SDL_free(device);
  125.11  }
  125.12  
  125.13  static SDL_VideoDevice *AA_CreateDevice(int devindex)
  125.14 @@ -79,20 +79,20 @@
  125.15  	SDL_VideoDevice *device;
  125.16  
  125.17  	/* Initialize all variables that we clean on shutdown */
  125.18 -	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  125.19 +	device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
  125.20  	if ( device ) {
  125.21 -		memset(device, 0, (sizeof *device));
  125.22 +		SDL_memset(device, 0, (sizeof *device));
  125.23  		device->hidden = (struct SDL_PrivateVideoData *)
  125.24 -				malloc((sizeof *device->hidden));
  125.25 +				SDL_malloc((sizeof *device->hidden));
  125.26  	}
  125.27  	if ( (device == NULL) || (device->hidden == NULL) ) {
  125.28  		SDL_OutOfMemory();
  125.29  		if ( device ) {
  125.30 -			free(device);
  125.31 +			SDL_free(device);
  125.32  		}
  125.33  		return(0);
  125.34  	}
  125.35 -	memset(device->hidden, 0, (sizeof *device->hidden));
  125.36 +	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
  125.37  
  125.38  	/* Set the function pointers */
  125.39  	device->VideoInit = AA_VideoInit;
  125.40 @@ -138,7 +138,7 @@
  125.41  
  125.42  	/* Initialize all variables that we clean on shutdown */
  125.43  	for ( i=0; i<SDL_NUMMODES; ++i ) {
  125.44 -		SDL_modelist[i] = malloc(sizeof(SDL_Rect));
  125.45 +		SDL_modelist[i] = SDL_malloc(sizeof(SDL_Rect));
  125.46  		SDL_modelist[i]->x = SDL_modelist[i]->y = 0;
  125.47  	}
  125.48  	/* Modes sorted largest to smallest */
  125.49 @@ -179,7 +179,7 @@
  125.50  
  125.51  	fprintf(stderr,"Using AAlib driver: %s (%s)\n", AA_context->driver->name, AA_context->driver->shortname);
  125.52  
  125.53 -	AA_in_x11 = (strcmp(AA_context->driver->shortname,"X11") == 0);
  125.54 +	AA_in_x11 = (SDL_strcmp(AA_context->driver->shortname,"X11") == 0);
  125.55  	/* Determine the screen depth (use default 8-bit depth) */
  125.56  	vformat->BitsPerPixel = 8;
  125.57  	vformat->BytesPerPixel = 1;
  125.58 @@ -252,10 +252,10 @@
  125.59  	int mode;
  125.60  
  125.61  	if ( AA_buffer ) {
  125.62 -		free( AA_buffer );
  125.63 +		SDL_free( AA_buffer );
  125.64  	}
  125.65  
  125.66 -	AA_buffer = malloc(width * height);
  125.67 +	AA_buffer = SDL_malloc(width * height);
  125.68  	if ( ! AA_buffer ) {
  125.69  		SDL_SetError("Couldn't allocate buffer for requested mode");
  125.70  		return(NULL);
  125.71 @@ -263,8 +263,8 @@
  125.72  
  125.73  /* 	printf("Setting mode %dx%d\n", width, height); */
  125.74  
  125.75 -	memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context));
  125.76 -	memset(AA_buffer, 0, width * height);
  125.77 +	SDL_memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context));
  125.78 +	SDL_memset(AA_buffer, 0, width * height);
  125.79  
  125.80  	/* Allocate the new pixel format for the screen */
  125.81  	if ( ! SDL_ReallocFormat(current, 8, 0, 0, 0, 0) ) {
  125.82 @@ -379,7 +379,7 @@
  125.83  	/* Free video mode lists */
  125.84  	for ( i=0; i<SDL_NUMMODES; ++i ) {
  125.85  		if ( SDL_modelist[i] != NULL ) {
  125.86 -			free(SDL_modelist[i]);
  125.87 +			SDL_free(SDL_modelist[i]);
  125.88  			SDL_modelist[i] = NULL;
  125.89  		}
  125.90  	}
   126.1 --- a/src/video/ataricommon/SDL_atarievents.c	Mon Feb 06 17:28:04 2006 +0000
   126.2 +++ b/src/video/ataricommon/SDL_atarievents.c	Tue Feb 07 06:59:48 2006 +0000
   126.3 @@ -82,25 +82,25 @@
   126.4  			break;
   126.5  	}
   126.6  
   126.7 -	envr = getenv("SDL_ATARI_EVENTSDRIVER");
   126.8 +	envr = SDL_getenv("SDL_ATARI_EVENTSDRIVER");
   126.9  
  126.10   	if (!envr) {
  126.11  		return;
  126.12  	}
  126.13  
  126.14 -	if (strcmp(envr, "ikbd") == 0) {
  126.15 +	if (SDL_strcmp(envr, "ikbd") == 0) {
  126.16  		this->InitOSKeymap=AtariIkbd_InitOSKeymap;
  126.17  		this->PumpEvents=AtariIkbd_PumpEvents;
  126.18  		Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
  126.19  	}
  126.20  
  126.21 -	if (strcmp(envr, "gemdos") == 0) {
  126.22 +	if (SDL_strcmp(envr, "gemdos") == 0) {
  126.23  		this->InitOSKeymap=AtariGemdos_InitOSKeymap;
  126.24  		this->PumpEvents=AtariGemdos_PumpEvents;
  126.25  		Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
  126.26  	}
  126.27  
  126.28 -	if (strcmp(envr, "bios") == 0) {
  126.29 +	if (SDL_strcmp(envr, "bios") == 0) {
  126.30  		this->InitOSKeymap=AtariBios_InitOSKeymap;
  126.31  		this->PumpEvents=AtariBios_PumpEvents;
  126.32  		Atari_ShutdownEvents=AtariBios_ShutdownEvents;
   127.1 --- a/src/video/ataricommon/SDL_atarigl.c	Mon Feb 06 17:28:04 2006 +0000
   127.2 +++ b/src/video/ataricommon/SDL_atarigl.c	Tue Feb 07 06:59:48 2006 +0000
   127.3 @@ -141,7 +141,7 @@
   127.4  	handle = SDL_LoadObject(path);
   127.5  	if (handle == NULL) {
   127.6  		/* Try to load another one */
   127.7 -		path = getenv("SDL_VIDEO_GL_DRIVER");
   127.8 +		path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
   127.9  		if ( path != NULL ) {
  127.10  			handle = SDL_LoadObject(path);
  127.11  		}
  127.12 @@ -223,10 +223,10 @@
  127.13  
  127.14  	this->gl_config.dll_handle = handle;
  127.15  	if ( path ) {
  127.16 -		strncpy(this->gl_config.driver_path, path,
  127.17 +		SDL_strncpy(this->gl_config.driver_path, path,
  127.18  			sizeof(this->gl_config.driver_path)-1);
  127.19  	} else {
  127.20 -		strcpy(this->gl_config.driver_path, "");
  127.21 +		SDL_strcpy(this->gl_config.driver_path, "");
  127.22  	}
  127.23  
  127.24  #endif
  127.25 @@ -697,7 +697,7 @@
  127.26  	}
  127.27  
  127.28  	for (y=0; y<surface->h; y++) {
  127.29 -		memcpy(dstline, srcline, srcpitch);
  127.30 +		SDL_memcpy(dstline, srcline, srcpitch);
  127.31  
  127.32  		srcline += srcpitch;
  127.33  		dstline += dstpitch;
   128.1 --- a/src/video/ataricommon/SDL_biosevents.c	Mon Feb 06 17:28:04 2006 +0000
   128.2 +++ b/src/video/ataricommon/SDL_biosevents.c	Tue Feb 07 06:59:48 2006 +0000
   128.3 @@ -70,8 +70,8 @@
   128.4  	int i, vectors_mask;
   128.5  	unsigned long dummy;
   128.6  
   128.7 -	memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
   128.8 -	memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
   128.9 +	SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
  128.10 +	SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
  128.11  
  128.12  	/* Initialize keymap */
  128.13  	for ( i=0; i<sizeof(keymap); i++ )
  128.14 @@ -117,7 +117,7 @@
  128.15  	SDL_keysym keysym;
  128.16  
  128.17  	/* Update pressed keys */
  128.18 -	memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
  128.19 +	SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
  128.20  
  128.21  	while (Bconstat(_CON)) {
  128.22  		unsigned long key_pressed;
  128.23 @@ -151,7 +151,7 @@
  128.24  	SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE);
  128.25  
  128.26  	/* Will be previous table */
  128.27 -	memcpy(bios_previouskeyboard, bios_currentkeyboard, ATARIBIOS_MAXKEYS);
  128.28 +	SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, ATARIBIOS_MAXKEYS);
  128.29  }
  128.30  
  128.31  static void UpdateSpecialKeys(int special_keys_state)
   129.1 --- a/src/video/ataricommon/SDL_gemdosevents.c	Mon Feb 06 17:28:04 2006 +0000
   129.2 +++ b/src/video/ataricommon/SDL_gemdosevents.c	Tue Feb 07 06:59:48 2006 +0000
   129.3 @@ -75,8 +75,8 @@
   129.4  	int i, vectors_mask;
   129.5  	unsigned long dummy;
   129.6  
   129.7 -	memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
   129.8 -	memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
   129.9 +	SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
  129.10 +	SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
  129.11  
  129.12  	/* Initialize keymap */
  129.13  	for ( i=0; i<sizeof(keymap); i++ )
  129.14 @@ -122,7 +122,7 @@
  129.15  	SDL_keysym keysym;
  129.16  
  129.17  	/* Update pressed keys */
  129.18 -	memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
  129.19 +	SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
  129.20  
  129.21  	while (Cconis()!=DEV_BUSY) {
  129.22  		unsigned long key_pressed;
  129.23 @@ -156,7 +156,7 @@
  129.24  	SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE);
  129.25  
  129.26  	/* Will be previous table */
  129.27 -	memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
  129.28 +	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
  129.29  }
  129.30  
  129.31  static void UpdateSpecialKeys(int special_keys_state)
   130.1 --- a/src/video/ataricommon/SDL_ikbdevents.c	Mon Feb 06 17:28:04 2006 +0000
   130.2 +++ b/src/video/ataricommon/SDL_ikbdevents.c	Tue Feb 07 06:59:48 2006 +0000
   130.3 @@ -78,7 +78,7 @@
   130.4  {
   130.5  	int i;
   130.6  
   130.7 -	memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS);
   130.8 +	SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS);
   130.9  
  130.10  	/* Initialize keymap */
  130.11  	for ( i=0; i<sizeof(keymap); i++ )
   131.1 --- a/src/video/bwindow/SDL_BWin.h	Mon Feb 06 17:28:04 2006 +0000
   131.2 +++ b/src/video/bwindow/SDL_BWin.h	Tue Feb 07 06:59:48 2006 +0000
   131.3 @@ -331,7 +331,7 @@
   131.4  
   131.5  		if ((uchar)buf[0] > 127) {
   131.6  			state = 0;
   131.7 -			srclen = strlen(buf);
   131.8 +			srclen = SDL_strlen(buf);
   131.9  			dstlen = sizeof(destbuf);
  131.10  			convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, (char *)destbuf, &dstlen, &state);
  131.11  			unicode = destbuf[0];
   132.1 --- a/src/video/bwindow/SDL_sysmouse.cc	Mon Feb 06 17:28:04 2006 +0000
   132.2 +++ b/src/video/bwindow/SDL_sysmouse.cc	Tue Feb 07 06:59:48 2006 +0000
   132.3 @@ -60,14 +60,14 @@
   132.4  	}
   132.5  
   132.6  	/* Allocate the cursor */
   132.7 -	cursor = (WMcursor *)malloc(sizeof(WMcursor));
   132.8 +	cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor));
   132.9  	if ( cursor == NULL ) {
  132.10  		SDL_OutOfMemory();
  132.11  		return(NULL);
  132.12  	}
  132.13 -	cursor->bits = (char *)malloc(4+2*((allowed_x/8)*allowed_y));
  132.14 +	cursor->bits = (char *)SDL_malloc(4+2*((allowed_x/8)*allowed_y));
  132.15  	if ( cursor->bits == NULL ) {
  132.16 -		free(cursor);
  132.17 +		SDL_free(cursor);
  132.18  		SDL_OutOfMemory();
  132.19  		return(NULL);
  132.20  	}
  132.21 @@ -81,13 +81,13 @@
  132.22  	run = PADDED_BITS(w);
  132.23  	pad = PADDED_BITS(allowed_x)-run;
  132.24  	for ( i=0; i<h; ++i ) {
  132.25 -		memcpy(cptr, data, run);
  132.26 -		memset(cptr+run, 0, pad);
  132.27 +		SDL_memcpy(cptr, data, run);
  132.28 +		SDL_memset(cptr+run, 0, pad);
  132.29  		data += run;
  132.30  		cptr += (run+pad);
  132.31  	}
  132.32  	for ( ; i<allowed_y; ++i ) {
  132.33 -		memset(cptr, 0, run+pad);
  132.34 +		SDL_memset(cptr, 0, run+pad);
  132.35  		cptr += (run+pad);
  132.36  	}
  132.37  	for ( i=0; i<h; ++i ) {
  132.38 @@ -95,13 +95,13 @@
  132.39  		   inverted color pixels black, since inverted color pixels
  132.40  		   aren't supported under BeOS.
  132.41  		 */
  132.42 -		memcpy(cptr, mask, run);
  132.43 -		memset(cptr+run, 0, pad);
  132.44 +		SDL_memcpy(cptr, mask, run);
  132.45 +		SDL_memset(cptr+run, 0, pad);
  132.46  		mask += run;
  132.47  		cptr += (run+pad);
  132.48  	}
  132.49  	for ( ; i<allowed_y; ++i ) {
  132.50 -		memset(cptr, 0, run+pad);
  132.51 +		SDL_memset(cptr, 0, run+pad);
  132.52  		cptr += (run+pad);
  132.53  	}
  132.54  	return(cursor);
  132.55 @@ -124,8 +124,8 @@
  132.56  
  132.57  void BE_FreeWMCursor(_THIS, WMcursor *cursor)
  132.58  {
  132.59 -	free(cursor->bits);
  132.60 -	free(cursor);
  132.61 +	SDL_free(cursor->bits);
  132.62 +	SDL_free(cursor);
  132.63  }
  132.64  
  132.65  /* Implementation by Christian Bauer <cbauer@student.physik.uni-mainz.de> */
   133.1 --- a/src/video/bwindow/SDL_sysvideo.cc	Mon Feb 06 17:28:04 2006 +0000
   133.2 +++ b/src/video/bwindow/SDL_sysvideo.cc	Tue Feb 07 06:59:48 2006 +0000
   133.3 @@ -82,8 +82,8 @@
   133.4  
   133.5  static void BE_DeleteDevice(SDL_VideoDevice *device)
   133.6  {
   133.7 -	free(device->hidden);
   133.8 -	free(device);
   133.9 +	SDL_free(device->hidden);
  133.10 +	SDL_free(device);
  133.11  }
  133.12  
  133.13  static SDL_VideoDevice *BE_CreateDevice(int devindex)
  133.14 @@ -91,20 +91,20 @@
  133.15  	SDL_VideoDevice *device;
  133.16  
  133.17  	/* Initialize all variables that we clean on shutdown */
  133.18 -	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  133.19 +	device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
  133.20  	if ( device ) {
  133.21 -		memset(device, 0, (sizeof *device));
  133.22 +		SDL_memset(device, 0, (sizeof *device));
  133.23  		device->hidden = (struct SDL_PrivateVideoData *)
  133.24 -				malloc((sizeof *device->hidden));
  133.25 +				SDL_malloc((sizeof *device->hidden));
  133.26  	}
  133.27  	if ( (device == NULL) || (device->hidden == NULL) ) {
  133.28  		SDL_OutOfMemory();
  133.29  		if ( device ) {
  133.30 -			free(device);
  133.31 +			SDL_free(device);
  133.32  		}
  133.33  		return(0);
  133.34  	}
  133.35 -	memset(device->hidden, 0, (sizeof *device->hidden));
  133.36 +	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
  133.37  
  133.38  	/* Set the function pointers */
  133.39  	/* Initialization/Query functions */
  133.40 @@ -233,7 +233,7 @@
  133.41  	}
  133.42  
  133.43  	/* Set up the new video mode rectangle */
  133.44 -	mode = (SDL_Rect *)malloc(sizeof *mode);
  133.45 +	mode = (SDL_Rect *)SDL_malloc(sizeof *mode);
  133.46  	if ( mode == NULL ) {
  133.47  		SDL_OutOfMemory();
  133.48  		return(-1);
  133.49 @@ -249,11 +249,11 @@
  133.50  	/* Allocate the new list of modes, and fill in the new mode */
  133.51  	next_mode = SDL_nummodes[index];
  133.52  	SDL_modelist[index] = (SDL_Rect **)
  133.53 -	       realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
  133.54 +	       SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
  133.55  	if ( SDL_modelist[index] == NULL ) {
  133.56  		SDL_OutOfMemory();
  133.57  		SDL_nummodes[index] = 0;
  133.58 -		free(mode);
  133.59 +		SDL_free(mode);
  133.60  		return(-1);
  133.61  	}
  133.62  	SDL_modelist[index][next_mode] = mode;
  133.63 @@ -642,7 +642,7 @@
  133.64  				if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) {
  133.65  					_this->gl_config.dll_handle = (void*)cookie;
  133.66  					_this->gl_config.driver_loaded = 1;
  133.67 -					strncpy(_this->gl_config.driver_path, "libGL.so", sizeof(_this->gl_config.driver_path)-1);
  133.68 +					SDL_strncpy(_this->gl_config.driver_path, "libGL.so", sizeof(_this->gl_config.driver_path)-1);
  133.69  				}
  133.70  			}
  133.71  		}
  133.72 @@ -670,7 +670,7 @@
  133.73  
  133.74  		if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) {
  133.75  			_this->gl_config.driver_loaded = 1;
  133.76 -			strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path)-1);
  133.77 +			SDL_strncpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path)-1);
  133.78  		}*/
  133.79  	}
  133.80  
  133.81 @@ -679,7 +679,7 @@
  133.82  	} else {
  133.83  		_this->gl_config.dll_handle = NULL;
  133.84  		_this->gl_config.driver_loaded = 0;
  133.85 -		strcpy(_this->gl_config.driver_path, "");
  133.86 +		SDL_strcpy(_this->gl_config.driver_path, "");
  133.87  		return -1;
  133.88  	}
  133.89  }
  133.90 @@ -805,9 +805,9 @@
  133.91  	for ( i=0; i<NUM_MODELISTS; ++i ) {
  133.92  		if ( SDL_modelist[i] ) {
  133.93  			for ( j=0; SDL_modelist[i][j]; ++j ) {
  133.94 -				free(SDL_modelist[i][j]);
  133.95 +				SDL_free(SDL_modelist[i][j]);
  133.96  			}
  133.97 -			free(SDL_modelist[i]);
  133.98 +			SDL_free(SDL_modelist[i]);
  133.99  			SDL_modelist[i] = NULL;
 133.100  		}
 133.101  	}
   134.1 --- a/src/video/bwindow/SDL_sysyuv.cc	Mon Feb 06 17:28:04 2006 +0000
   134.2 +++ b/src/video/bwindow/SDL_sysyuv.cc	Tue Feb 07 06:59:48 2006 +0000
   134.3 @@ -312,7 +312,7 @@
   134.4  
   134.5  	delete overlay->hwdata->bbitmap;
   134.6  
   134.7 -    free(overlay->hwdata);
   134.8 +    SDL_free(overlay->hwdata);
   134.9  }
  134.10  
  134.11  }; // extern "C"
   135.1 --- a/src/video/cybergfx/SDL_amigamouse.c	Mon Feb 06 17:28:04 2006 +0000
   135.2 +++ b/src/video/cybergfx/SDL_amigamouse.c	Tue Feb 07 06:59:48 2006 +0000
   135.3 @@ -90,7 +90,7 @@
   135.4  						&mouse_accel.numerator, 
   135.5  						&mouse_accel.denominator,
   135.6  						&mouse_accel.threshold);
   135.7 -			use_mouse_accel = getenv("SDL_VIDEO_X11_MOUSEACCEL");
   135.8 +			use_mouse_accel = SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL");
   135.9  			if ( use_mouse_accel ) {
  135.10  				SetMouseAccel(this, use_mouse_accel);
  135.11  			}
   136.1 --- a/src/video/cybergfx/SDL_cgxaccel.c	Mon Feb 06 17:28:04 2006 +0000
   136.2 +++ b/src/video/cybergfx/SDL_cgxaccel.c	Tue Feb 07 06:59:48 2006 +0000
   136.3 @@ -52,14 +52,14 @@
   136.4  	if(surface->hwdata)
   136.5  	{
   136.6  		if(surface->hwdata->mask)
   136.7 -			free(surface->hwdata->mask);
   136.8 +			SDL_free(surface->hwdata->mask);
   136.9  
  136.10 -		if(surface->hwdata->mask=malloc(RASSIZE(surface->w,surface->h)))
  136.11 +		if(surface->hwdata->mask=SDL_malloc(RASSIZE(surface->w,surface->h)))
  136.12  		{
  136.13  			Uint32 pitch,ok=0;
  136.14  			APTR lock;
  136.15  
  136.16 -			memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h));
  136.17 +			SDL_memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h));
  136.18  
  136.19  			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));
  136.20  
  136.21 @@ -155,7 +155,7 @@
  136.22  					break;
  136.23  					default:
  136.24  						D(bug("Pixel mode non supported for color key..."));
  136.25 -						free(surface->hwdata->mask);
  136.26 +						SDL_free(surface->hwdata->mask);
  136.27  						surface->hwdata->mask=NULL;
  136.28  						ok=-1;
  136.29  				}
   137.1 --- a/src/video/cybergfx/SDL_cgximage.c	Mon Feb 06 17:28:04 2006 +0000
   137.2 +++ b/src/video/cybergfx/SDL_cgximage.c	Tue Feb 07 06:59:48 2006 +0000
   137.3 @@ -57,7 +57,7 @@
   137.4  		ULONG pitch;
   137.5  
   137.6  		if(!screen->hwdata) {
   137.7 -			if(!(screen->hwdata=malloc(sizeof(struct private_hwdata))))
   137.8 +			if(!(screen->hwdata=SDL_malloc(sizeof(struct private_hwdata))))
   137.9  				return -1;
  137.10  
  137.11  			D(bug("Creating system accel struct\n"));
  137.12 @@ -71,7 +71,7 @@
  137.13  		if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap,
  137.14  				LBMI_BASEADDRESS,(ULONG)&screen->pixels,
  137.15  				LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) {
  137.16 -			free(screen->hwdata);
  137.17 +			SDL_free(screen->hwdata);
  137.18  			screen->hwdata=NULL;
  137.19  			return -1;
  137.20  		}
  137.21 @@ -88,7 +88,7 @@
  137.22  		return 0;
  137.23  	}
  137.24  
  137.25 -	screen->pixels = malloc(screen->h*screen->pitch);
  137.26 +	screen->pixels = SDL_malloc(screen->h*screen->pitch);
  137.27  
  137.28  	if ( screen->pixels == NULL ) {
  137.29  		SDL_OutOfMemory();
  137.30 @@ -110,14 +110,14 @@
  137.31  void CGX_DestroyImage(_THIS, SDL_Surface *screen)
  137.32  {
  137.33  	if ( SDL_Ximage ) {
  137.34 -		free(SDL_Ximage);
  137.35 +		SDL_free(SDL_Ximage);
  137.36  		SDL_Ximage = NULL;
  137.37  	}
  137.38  	if ( screen ) {
  137.39  		screen->pixels = NULL;
  137.40  
  137.41  		if(screen->hwdata) {
  137.42 -			free(screen->hwdata);
  137.43 +			SDL_free(screen->hwdata);
  137.44  			screen->hwdata=NULL;
  137.45  		}
  137.46  	}
  137.47 @@ -163,7 +163,7 @@
  137.48  
  137.49  	if(!surface->hwdata)
  137.50  	{
  137.51 -		if(!(surface->hwdata=malloc(sizeof(struct private_hwdata))))
  137.52 +		if(!(surface->hwdata=SDL_malloc(sizeof(struct private_hwdata))))
  137.53  			return -1;
  137.54  	}
  137.55  
  137.56 @@ -181,7 +181,7 @@
  137.57  	}
  137.58  	else
  137.59  	{
  137.60 -		free(surface->hwdata);
  137.61 +		SDL_free(surface->hwdata);
  137.62  		surface->hwdata=NULL;
  137.63  	}
  137.64  
  137.65 @@ -194,12 +194,12 @@
  137.66  		D(bug("Free hw surface.\n"));
  137.67  
  137.68  		if(surface->hwdata->mask)
  137.69 -			free(surface->hwdata->mask);
  137.70 +			SDL_free(surface->hwdata->mask);
  137.71  
  137.72  		if(surface->hwdata->bmap&&surface->hwdata->allocated)
  137.73  			FreeBitMap(surface->hwdata->bmap);
  137.74  
  137.75 -		free(surface->hwdata);
  137.76 +		SDL_free(surface->hwdata);
  137.77  		surface->hwdata=NULL;
  137.78  		surface->pixels=NULL;
  137.79  		D(bug("end of free hw surface\n"));
  137.80 @@ -654,7 +654,7 @@
  137.81  
  137.82  				for(j=rects[i].h;j;--j)
  137.83  				{
  137.84 -					memcpy(dest,src,srcwidth);
  137.85 +					SDL_memcpy(dest,src,srcwidth);
  137.86  					src+=this->screen->pitch;
  137.87  					dest+=destpitch;
  137.88  				}
  137.89 @@ -883,13 +883,13 @@
  137.90  
  137.91  			if(this->screen->pitch==destpitch)
  137.92  			{
  137.93 -				memcpy(dest,src,this->screen->pitch*this->screen->h);
  137.94 +				SDL_memcpy(dest,src,this->screen->pitch*this->screen->h);
  137.95  			}
  137.96  			else
  137.97  			{
  137.98  				for(j=this->screen->h;j;--j)
  137.99  				{
 137.100 -					memcpy(dest,src,this->screen->pitch);
 137.101 +					SDL_memcpy(dest,src,this->screen->pitch);
 137.102  					src+=this->screen->pitch;
 137.103  					dest+=destpitch;
 137.104  				}
   138.1 --- a/src/video/cybergfx/SDL_cgxmodes.c	Mon Feb 06 17:28:04 2006 +0000
   138.2 +++ b/src/video/cybergfx/SDL_cgxmodes.c	Tue Feb 07 06:59:48 2006 +0000
   138.3 @@ -137,12 +137,12 @@
   138.4  					{
   138.5  						nmodes++;
   138.6  
   138.7 -						SDL_modelist = (SDL_Rect **)realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *));
   138.8 +						SDL_modelist = (SDL_Rect **)SDL_realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *));
   138.9  						SDL_modelist[nmodes]=NULL;
  138.10  
  138.11  						if ( SDL_modelist )
  138.12  						{
  138.13 -							SDL_modelist[nmodes-1] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
  138.14 +							SDL_modelist[nmodes-1] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
  138.15  
  138.16  							if ( SDL_modelist[nmodes-1] == NULL )
  138.17  								break;
  138.18 @@ -175,10 +175,10 @@
  138.19  	}
  138.20  
  138.21      if ( SDL_modelist == NULL ) {
  138.22 -        SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *));
  138.23 +        SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *));
  138.24          i = 0;
  138.25          if ( SDL_modelist ) {
  138.26 -            SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
  138.27 +            SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
  138.28              if ( SDL_modelist[i] ) {
  138.29                  SDL_modelist[i]->x = 0;
  138.30                  SDL_modelist[i]->y = 0;
  138.31 @@ -238,9 +238,9 @@
  138.32  
  138.33      if ( SDL_modelist ) {
  138.34          for ( i=0; SDL_modelist[i]; ++i ) {
  138.35 -            free(SDL_modelist[i]);
  138.36 +            SDL_free(SDL_modelist[i]);
  138.37          }
  138.38 -        free(SDL_modelist);
  138.39 +        SDL_free(SDL_modelist);
  138.40          SDL_modelist = NULL;
  138.41      }
  138.42  }
   139.1 --- a/src/video/cybergfx/SDL_cgxvideo.c	Mon Feb 06 17:28:04 2006 +0000
   139.2 +++ b/src/video/cybergfx/SDL_cgxvideo.c	Tue Feb 07 06:59:48 2006 +0000
   139.3 @@ -149,7 +149,7 @@
   139.4  			this->hidden->SB[0]=this->hidden->SB[1]=NULL;
   139.5  
   139.6  			if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort)
   139.7 -				free(SDL_RastPort);
   139.8 +				SDL_free(SDL_RastPort);
   139.9  
  139.10  			SDL_RastPort=NULL;
  139.11  		}
  139.12 @@ -181,12 +181,12 @@
  139.13  {
  139.14  	if ( device ) {
  139.15  		if ( device->hidden ) {
  139.16 -			free(device->hidden);
  139.17 +			SDL_free(device->hidden);
  139.18  		}
  139.19  		if ( device->gl_data ) {
  139.20 -			free(device->gl_data);
  139.21 +			SDL_free(device->gl_data);
  139.22  		}
  139.23 -		free(device);
  139.24 +		SDL_free(device);
  139.25  	}
  139.26  }
  139.27  
  139.28 @@ -195,13 +195,13 @@
  139.29  	SDL_VideoDevice *device;
  139.30  
  139.31  	/* Initialize all variables that we clean on shutdown */
  139.32 -	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  139.33 +	device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
  139.34  	if ( device ) {
  139.35 -		memset(device, 0, (sizeof *device));
  139.36 +		SDL_memset(device, 0, (sizeof *device));
  139.37  		device->hidden = (struct SDL_PrivateVideoData *)
  139.38 -				malloc((sizeof *device->hidden));
  139.39 +				SDL_malloc((sizeof *device->hidden));
  139.40  		device->gl_data = (struct SDL_PrivateGLData *)
  139.41 -				malloc((sizeof *device->gl_data));
  139.42 +				SDL_malloc((sizeof *device->gl_data));
  139.43  	}
  139.44  	if ( (device == NULL) || (device->hidden == NULL) ||
  139.45  	                         (device->gl_data == NULL) ) {
  139.46 @@ -210,8 +210,8 @@
  139.47  		CGX_DeleteDevice(device);
  139.48  		return(0);
  139.49  	}
  139.50 -	memset(device->hidden, 0, sizeof(*device->hidden));
  139.51 -	memset(device->gl_data, 0, sizeof(*device->gl_data));
  139.52 +	SDL_memset(device->hidden, 0, sizeof(*device->hidden));
  139.53 +	SDL_memset(device->gl_data, 0, sizeof(*device->gl_data));
  139.54  
  139.55  	/* Set the driver flags */
  139.56  	device->handles_any_size = 1;
  139.57 @@ -581,7 +581,7 @@
  139.58  	}
  139.59  
  139.60  	/* See if we have been passed a window to use */
  139.61 -/*	SDL_windowid = getenv("SDL_WINDOWID"); */
  139.62 +/*	SDL_windowid = SDL_getenv("SDL_WINDOWID"); */
  139.63  	SDL_windowid=NULL;
  139.64  
  139.65  	/* Create the blank cursor */
  139.66 @@ -649,7 +649,7 @@
  139.67  					}
  139.68  				}
  139.69  			}
  139.70 -			free(SDL_XPixels);
  139.71 +			SDL_free(SDL_XPixels);
  139.72  			SDL_XPixels = NULL;
  139.73  		}
  139.74  	}
  139.75 @@ -664,7 +664,7 @@
  139.76  	}
  139.77  	if ( flags & SDL_FULLSCREEN ) {
  139.78  		flags&=~SDL_RESIZABLE;
  139.79 -	} else if ( getenv("SDL_VIDEO_CENTERED") ) {
  139.80 +	} else if ( SDL_getenv("SDL_VIDEO_CENTERED") ) {
  139.81  		int display_w, display_h;
  139.82  
  139.83  		display_w = SDL_Display->Width;
  139.84 @@ -777,7 +777,7 @@
  139.85  	    else
  139.86  		ncolors = 1 << screen->format->BitsPerPixel;
  139.87  
  139.88 -	    SDL_XPixels = (Sint32 *)malloc(ncolors * sizeof(Sint32));
  139.89 +	    SDL_XPixels = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32));
  139.90  
  139.91  	    if(SDL_XPixels == NULL) {
  139.92  		SDL_OutOfMemory();
  139.93 @@ -836,7 +836,7 @@
  139.94  
  139.95  	if(screen->flags & SDL_DOUBLEBUF)
  139.96  	{
  139.97 -		if(SDL_RastPort=malloc(sizeof(struct RastPort)))
  139.98 +		if(SDL_RastPort=SDL_malloc(sizeof(struct RastPort)))
  139.99  		{
 139.100  			InitRastPort(SDL_RastPort);
 139.101  			SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap;
   140.1 --- a/src/video/cybergfx/SDL_cgxwm.c	Mon Feb 06 17:28:04 2006 +0000
   140.2 +++ b/src/video/cybergfx/SDL_cgxwm.c	Tue Feb 07 06:59:48 2006 +0000
   140.3 @@ -78,7 +78,7 @@
   140.4  	   copy them */
   140.5  	if(SDL_Visual == dvis && SDL_XColorMap == SDL_DisplayColormap
   140.6  	   && this->screen->format->palette && sicon->format->palette) {
   140.7 -	    memcpy(sicon->format->palette->colors,
   140.8 +	    SDL_memcpy(sicon->format->palette->colors,
   140.9  		   this->screen->format->palette->colors,
  140.10  		   this->screen->format->palette->ncolors * sizeof(SDL_Color));
  140.11  	}
  140.12 @@ -98,21 +98,21 @@
  140.13  		XColor wanted;
  140.14  
  140.15  		palette = sicon->format->palette;
  140.16 -		color_tried = malloc(palette->ncolors);
  140.17 +		color_tried = SDL_malloc(palette->ncolors);
  140.18  		if ( color_tried == NULL ) {
  140.19  			goto done;
  140.20  		}
  140.21  		if ( SDL_iconcolors != NULL ) {
  140.22 -			free(SDL_iconcolors);
  140.23 +			SDL_free(SDL_iconcolors);
  140.24  		}
  140.25 -		SDL_iconcolors = malloc(palette->ncolors
  140.26 +		SDL_iconcolors = SDL_malloc(palette->ncolors
  140.27  					* sizeof(*SDL_iconcolors));
  140.28  		if ( SDL_iconcolors == NULL ) {
  140.29 -			free(color_tried);
  140.30 +			SDL_free(color_tried);
  140.31  			goto done;
  140.32  		}
  140.33 -		memset(color_tried, 0, palette->ncolors);
  140.34 -		memset(SDL_iconcolors, 0,
  140.35 +		SDL_memset(color_tried, 0, palette->ncolors);
  140.36 +		SDL_memset(SDL_iconcolors, 0,
  140.37  		       palette->ncolors * sizeof(*SDL_iconcolors));
  140.38  
  140.39  		p = (Uint8 *)sicon->pixels; 
  140.40 @@ -132,16 +132,16 @@
  140.41  		}
  140.42  	}
  140.43  	if ( color_tried != NULL ) {
  140.44 -		free(color_tried);
  140.45 +		SDL_free(color_tried);
  140.46  	}
  140.47  
  140.48  	/* Translate mask data to LSB order and set the icon mask */
  140.49  	i = (sicon->w/8)*sicon->h;
  140.50 -	LSBmask = (Uint8 *)malloc(i);
  140.51 +	LSBmask = (Uint8 *)SDL_malloc(i);
  140.52  	if ( LSBmask == NULL ) {
  140.53  		goto done;
  140.54  	}
  140.55 -	memset(LSBmask, 0, i);
  140.56 +	SDL_memset(LSBmask, 0, i);
  140.57  	while ( --i >= 0 ) {
  140.58  		for ( b=0; b<8; ++b )
  140.59  			LSBmask[i] |= (((mask[i]>>b)&0x01)<<(7-b));
  140.60 @@ -163,7 +163,7 @@
  140.61  					0, 0, 0, 0, sicon->w, sicon->h);
  140.62  	XFreeGC(SDL_Display, GC);
  140.63  	XDestroyImage(icon_image);
  140.64 -	free(LSBmask);
  140.65 +	SDL_free(LSBmask);
  140.66  	sicon->pixels = NULL;
  140.67  
  140.68  #ifdef USE_ICON_WINDOW
   141.1 --- a/src/video/cybergfx/SDL_cgxyuv.c	Mon Feb 06 17:28:04 2006 +0000
   141.2 +++ b/src/video/cybergfx/SDL_cgxyuv.c	Tue Feb 07 06:59:48 2006 +0000
   141.3 @@ -89,12 +89,12 @@
   141.4  	}
   141.5  
   141.6  	/* Create the overlay structure */
   141.7 -	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
   141.8 +	overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay);
   141.9  	if ( overlay == NULL ) {
  141.10  		SDL_OutOfMemory();
  141.11  		return(NULL);
  141.12  	}
  141.13 -	memset(overlay, 0, (sizeof *overlay));
  141.14 +	SDL_memset(overlay, 0, (sizeof *overlay));
  141.15  
  141.16  	/* Fill in the basic members */
  141.17  	overlay->format = format;
  141.18 @@ -105,7 +105,7 @@
  141.19  	overlay->hwfuncs = &x11_yuvfuncs;
  141.20  
  141.21  	/* Create the pixel data and lookup tables */
  141.22 -	hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
  141.23 +	hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata);
  141.24  	overlay->hwdata = hwdata;
  141.25  	if ( hwdata == NULL ) {
  141.26  		SDL_OutOfMemory();
  141.27 @@ -113,7 +113,7 @@
  141.28  		return(NULL);
  141.29  	}
  141.30  	yuvshm = &hwdata->yuvshm;
  141.31 -	memset(yuvshm, 0, sizeof(*yuvshm));
  141.32 +	SDL_memset(yuvshm, 0, sizeof(*yuvshm));
  141.33  	hwdata->port = xv_port;
  141.34  	hwdata->image = XvShmCreateImage(GFX_Display, xv_port, format,
  141.35  	                                 0, width, height, yuvshm);
  141.36 @@ -179,7 +179,7 @@
  141.37  		if ( hwdata->image ) {
  141.38  			XFree(hwdata->image);
  141.39  		}
  141.40 -		free(hwdata);
  141.41 +		SDL_free(hwdata);
  141.42  	}
  141.43  }
  141.44  
   142.1 --- a/src/video/dc/SDL_dcevents.c	Mon Feb 06 17:28:04 2006 +0000
   142.2 +++ b/src/video/dc/SDL_dcevents.c	Tue Feb 07 06:59:48 2006 +0000
   142.3 @@ -107,7 +107,7 @@
   142.4  
   142.5  	if (addr!=old_addr) {
   142.6  		old_addr = addr;
   142.7 -		memset(&old_state,0,sizeof(old_state));
   142.8 +		SDL_memset(&old_state,0,sizeof(old_state));
   142.9  	}
  142.10  
  142.11  	maple_raddr(addr,&port,&unit);
   143.1 --- a/src/video/dc/SDL_dcvideo.c	Mon Feb 06 17:28:04 2006 +0000
   143.2 +++ b/src/video/dc/SDL_dcvideo.c	Tue Feb 07 06:59:48 2006 +0000
   143.3 @@ -76,8 +76,8 @@
   143.4  
   143.5  static void DC_DeleteDevice(SDL_VideoDevice *device)
   143.6  {
   143.7 -	free(device->hidden);
   143.8 -	free(device);
   143.9 +	SDL_free(device->hidden);
  143.10 +	SDL_free(device);
  143.11  }
  143.12  
  143.13  static SDL_VideoDevice *DC_CreateDevice(int devindex)
  143.14 @@ -85,20 +85,20 @@
  143.15  	SDL_VideoDevice *device;
  143.16  
  143.17  	/* Initialize all variables that we clean on shutdown */
  143.18 -	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  143.19 +	device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
  143.20  	if ( device ) {
  143.21 -		memset(device, 0, (sizeof *device));
  143.22 +		SDL_memset(device, 0, (sizeof *device));
  143.23  		device->hidden = (struct SDL_PrivateVideoData *)
  143.24 -				malloc((sizeof *device->hidden));
  143.25 +				SDL_malloc((sizeof *device->hidden));
  143.26  	}
  143.27  	if ( (device == NULL) || (device->hidden == NULL) ) {
  143.28  		SDL_OutOfMemory();
  143.29  		if ( device ) {
  143.30 -			free(device);
  143.31 +			SDL_free(device);
  143.32  		}
  143.33  		return(0);
  143.34  	}
  143.35 -	memset(device->hidden, 0, (sizeof *device->hidden));
  143.36 +	SDL_memset(device->hidden, 0, (sizeof *device->hidden));
  143.37  
  143.38  	/* Set the function pointers */
  143.39  	device->VideoInit = DC_VideoInit;
  143.40 @@ -386,7 +386,7 @@
  143.41  	if (ret) return ret;
  143.42  
  143.43  	for(i=0;i<sizeof(glfuncs)/sizeof(glfuncs[0]);i++) {
  143.44 -		if (strcmp(proc,glfuncs[i].name)==0) return glfuncs[i].addr;
  143.45 +		if (SDL_strcmp(proc,glfuncs[i].name)==0) return glfuncs[i].addr;
  143.46  	}
  143.47  
  143.48  	return NULL;
   144.1 --- a/src/video/dga/SDL_dgavideo.c	Mon Feb 06 17:28:04 2006 +0000
   144.2 +++ b/src/video/dga/SDL_dgavideo.c	Tue Feb 07 06:59:48 2006 +0000
   144.3 @@ -78,8 +78,8 @@
   144.4  	   and the DGA 2.0+ extension is available, and we can map mem.
   144.5  	*/
   144.6  	if ( SDL_X11_LoadSymbols() ) {
   144.7 -		if ( (strncmp(pXDisplayName(display), ":", 1) == 0) ||
   144.8 -		     (strncmp(pXDisplayName(display), "unix:", 5) == 0) ) {
   144.9 +		if ( (SDL_strncmp(pXDisplayName(display), ":", 1) == 0) ||
  144.10 +		     (SDL_strncmp(pXDisplayName(display), "unix:", 5) == 0) ) {
  144.11  			dpy = pXOpenDisplay(display);
  144.12  			if ( dpy ) {
  144.13  				int events, errors, major, minor;
  144.14 @@ -106,8 +106,8 @@
  144.15  static void DGA_DeleteDevice(SDL_VideoDevice *device)
  144.16  {
  144.17  	if (device != NULL) {
  144.18 -		free(device->hidden);
  144.19 -		free(device);
  144.20 +		SDL_free(device->hidden);
  144.21 +		SDL_free(device);
  144.22  		SDL_X11_UnloadSymbols();
  144.23  	}
  144.24  }
  144.25 @@ -118,21 +118,21 @@
  144.26  
  144.27  	/* Initialize all variables that we clean on shutdown */
  144.28  	if (SDL_X11_LoadSymbols()) {
  144.29 -		device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  144.30 +		device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
  144.31  		if ( device ) {
  144.32 -			memset(device, 0, (sizeof *device));
  144.33 +			SDL_memset(device, 0, (sizeof *device));
  144.34  			device->hidden = (struct SDL_PrivateVideoData *)
  144.35 -					malloc((sizeof *device->hidden));
  144.36 +					SDL_malloc((sizeof *device->hidden));
  144.37  		}
  144.38  		if ( (device == NULL) || (device->hidden == NULL) ) {
  144.39  			SDL_OutOfMemory();
  144.40  			if ( device ) {
  144.41 -				free(device);
  144.42 +				SDL_free(device);
  144.43  			}
  144.44  			SDL_X11_UnloadSymbols();
  144.45  			return(0);
  144.46  		}
  144.47 -		memset(device->hidden, 0, (sizeof *device->hidden));
  144.48 +		SDL_memset(device->hidden, 0, (sizeof *device->hidden));
  144.49  
  144.50  		/* Set the function pointers */
  144.51  		device->VideoInit = DGA_VideoInit;
  144.52 @@ -190,7 +190,7 @@
  144.53  	}
  144.54  
  144.55  	/* Set up the new video mode rectangle */
  144.56 -	mode = (SDL_Rect *)malloc(sizeof *mode);
  144.57 +	mode = (SDL_Rect *)SDL_malloc(sizeof *mode);
  144.58  	if ( mode == NULL ) {
  144.59  		SDL_OutOfMemory();
  144.60  		return(-1);
  144.61 @@ -203,11 +203,11 @@
  144.62  	/* Allocate the new list of modes, and fill in the new mode */
  144.63  	next_mode = SDL_nummodes[index];
  144.64  	SDL_modelist[index] = (SDL_Rect **)
  144.65 -	       realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
  144.66 +	       SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
  144.67  	if ( SDL_modelist[index] == NULL ) {
  144.68  		SDL_OutOfMemory();
  144.69  		SDL_nummodes[index] = 0;
  144.70 -		free(mode);
  144.71 +		SDL_free(mode);
  144.72  		return(-1);
  144.73  	}
  144.74  	SDL_modelist[index][next_mode] = mode;
  144.75 @@ -233,7 +233,7 @@
  144.76  	proc = fopen("/proc/self/maps", "r");
  144.77  	if ( proc ) {
  144.78  		while ( fgets(line, sizeof(line)-1, proc) ) {
  144.79 -			sscanf(line, "%x-%x", &start, &stop);
  144.80 +			SDL_sscanf(line, "%x-%x", &start, &stop);
  144.81  			if ( start == mem ) {
  144.82  				size = (Uint32)((stop-start)/1024);
  144.83  				break;
  144.84 @@ -605,7 +605,7 @@
  144.85  	surfaces_memleft = size;
  144.86  
  144.87  	if ( surfaces_memleft > 0 ) {
  144.88 -		bucket = (vidmem_bucket *)malloc(sizeof(*bucket));
  144.89 +		bucket = (vidmem_bucket *)SDL_malloc(sizeof(*bucket));
  144.90  		if ( bucket == NULL ) {
  144.91  			SDL_OutOfMemory();
  144.92  			return(-1);
  144.93 @@ -637,7 +637,7 @@
  144.94  	while ( bucket ) {
  144.95  		freeable = bucket;
  144.96  		bucket = bucket->next;
  144.97 -		free(freeable);
  144.98 +		SDL_free(freeable);
  144.99  	}
 144.100  	surfaces.next = NULL;
 144.101  }
 144.102 @@ -714,7 +714,7 @@
 144.103  #ifdef DGA_DEBUG
 144.104  	fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
 144.105  #endif
 144.106 -		newbucket = (vidmem_bucket *)malloc(sizeof(*newbucket));
 144.107 +		newbucket = (vidmem_bucket *)SDL_malloc(sizeof(*newbucket));
 144.108  		if ( newbucket == NULL ) {
 144.109  			SDL_OutOfMemory();
 144.110  			retval = -1;
 144.111 @@ -775,7 +775,7 @@
 144.112  			if ( bucket->next ) {
 144.113  				bucket->next->prev = bucket;
 144.114  			}
 144.115 -			free(freeable);
 144.116 +			SDL_free(freeable);
 144.117  		}
 144.118  		if ( bucket->prev && ! bucket->prev->used ) {
 144.119  #ifdef DGA_DEBUG
 144.120 @@ -787,7 +787,7 @@
 144.121  			if ( bucket->next ) {
 144.122  				bucket->next->prev = bucket->prev;
 144.123  			}
 144.124 -			free(freeable);
 144.125 +			SDL_free(freeable);
 144.126  		}
 144.127  	}
 144.128  	surface->pixels = NULL;
 144.129 @@ -1053,9 +1053,9 @@
 144.130  		for ( i=0; i<NUM_MODELISTS; ++i ) {
 144.131  			if ( SDL_modelist[i] != NULL ) {
 144.132  				for ( j=0; SDL_modelist[i][j]; ++j ) {