Removed uses of stdlib.h and string.h
authorSam Lantinga <slouken@libsdl.org>
Tue, 07 Feb 2006 09:29:18 +0000
changeset 1338604d73db6802
parent 1337 c687f06c7473
child 1339 62802d9d7c87
Removed uses of stdlib.h and string.h
src/SDL.c
src/SDL_error.c
src/audio/SDL_audiodev.c
src/audio/SDL_audiomem.c
src/audio/SDL_wave.c
src/audio/alsa/SDL_alsa_audio.c
src/audio/amigaos/SDL_ahiaudio.h
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_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/mme/SDL_mmeaudio.h
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/aix/SDL_syscdrom.c
src/cdrom/beos/SDL_syscdrom.cc
src/cdrom/bsdi/SDL_syscdrom.c
src/cdrom/dc/SDL_syscdrom.c
src/cdrom/freebsd/SDL_syscdrom.c
src/cdrom/linux/SDL_syscdrom.c
src/cdrom/macosx/AudioFileReaderThread.c
src/cdrom/macosx/SDLOSXCAGuard.c
src/cdrom/macosx/SDL_syscdrom.c
src/cdrom/mint/SDL_syscdrom.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/file/SDL_rwops.c
src/joystick/SDL_joystick.c
src/joystick/amigaos/SDL_sysjoystick.c
src/joystick/beos/SDL_bejoystick.cc
src/joystick/bsd/SDL_sysjoystick.c
src/joystick/darwin/SDL_sysjoystick.c
src/joystick/dc/SDL_sysjoystick.c
src/joystick/linux/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/macosx/SDL_loadso.c
src/main/beos/SDL_BeApp.cc
src/main/macos/SDL_main.c
src/stdlib/SDL_malloc.c
src/stdlib/SDL_string.c
src/thread/SDL_thread.c
src/thread/amigaos/SDL_systhread.c
src/thread/amigaos/SDL_systhread_c.h
src/thread/amigaos/SDL_thread.c
src/thread/bsdi/SDL_syssem.c
src/thread/dc/SDL_syscond.c
src/thread/dc/SDL_sysmutex.c
src/thread/dc/SDL_syssem.c
src/thread/epoc/SDL_sysmutex.cpp
src/thread/epoc/SDL_syssem.cpp
src/thread/epoc/SDL_systhread.cpp
src/thread/generic/SDL_syscond.c
src/thread/generic/SDL_sysmutex.c
src/thread/generic/SDL_syssem.c
src/thread/irix/SDL_systhread.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/video/SDL_RLEaccel.c
src/video/SDL_blit_N.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_xbiosevents.c
src/video/bwindow/SDL_sysmouse.cc
src/video/bwindow/SDL_sysvideo.cc
src/video/bwindow/SDL_sysyuv.cc
src/video/cybergfx/SDL_cgximage.c
src/video/cybergfx/SDL_cgxmodes.c
src/video/cybergfx/SDL_cgxvideo.c
src/video/cybergfx/SDL_cgxvideo.h
src/video/cybergfx/SDL_cgxyuv.c
src/video/dc/SDL_dcvideo.c
src/video/dga/SDL_dgavideo.c
src/video/directfb/SDL_DirectFB_events.c
src/video/directfb/SDL_DirectFB_video.c
src/video/directfb/SDL_DirectFB_yuv.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_gemmouse.c
src/video/gem/SDL_gemvideo.c
src/video/ggi/SDL_ggievents.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/nanox/SDL_nximage.c
src/video/nanox/SDL_nxmodes.c
src/video/nanox/SDL_nxmouse.c
src/video/nanox/SDL_nxvideo.c
src/video/nanox/SDL_nxwm.c
src/video/os2fslib/SDL_os2fslib.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_pgvideo.c
src/video/ps2gs/SDL_gsevents.c
src/video/ps2gs/SDL_gsmouse.c
src/video/ps2gs/SDL_gsvideo.c
src/video/ps2gs/SDL_gsyuv.c
src/video/qtopia/SDL_sysmouse.cc
src/video/qtopia/SDL_sysvideo.cc
src/video/quartz/SDL_QuartzEvents.m
src/video/riscos/SDL_riscosFullScreenVideo.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_wimpvideo.c
src/video/svga/SDL_svgaevents.c
src/video/svga/SDL_svgavideo.c
src/video/vgl/SDL_vglvideo.c
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_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/src/SDL.c	Tue Feb 07 07:03:29 2006 +0000
     1.2 +++ b/src/SDL.c	Tue Feb 07 09:29:18 2006 +0000
     1.3 @@ -27,9 +27,9 @@
     1.4  #endif
     1.5  
     1.6  #include "SDL.h"
     1.7 +#include "SDL_stdlib.h"
     1.8  #include "SDL_endian.h"
     1.9  #include "SDL_fatal.h"
    1.10 -#include "SDL_stdlib.h"
    1.11  #ifndef DISABLE_VIDEO
    1.12  #include "SDL_leaks.h"
    1.13  #endif
     2.1 --- a/src/SDL_error.c	Tue Feb 07 07:03:29 2006 +0000
     2.2 +++ b/src/SDL_error.c	Tue Feb 07 09:29:18 2006 +0000
     2.3 @@ -22,9 +22,9 @@
     2.4  
     2.5  /* Simple error handling in SDL */
     2.6  
     2.7 -#include "SDL_types.h"
     2.8  #include "SDL_stdlib.h"
     2.9  #include "SDL_string.h"
    2.10 +#include "SDL_types.h"
    2.11  #include "SDL_error.h"
    2.12  #include "SDL_error_c.h"
    2.13  #ifndef DISABLE_THREADS
     3.1 --- a/src/audio/SDL_audiodev.c	Tue Feb 07 07:03:29 2006 +0000
     3.2 +++ b/src/audio/SDL_audiodev.c	Tue Feb 07 09:29:18 2006 +0000
     3.3 @@ -24,13 +24,12 @@
     3.4  
     3.5  #if defined(unix) || defined(__unix__) || defined(__riscos__)
     3.6  
     3.7 -#include <stdlib.h>
     3.8 -#include <stdio.h>
     3.9  #include <fcntl.h>
    3.10  #include <sys/types.h>
    3.11  #include <sys/stat.h>
    3.12 -#include <string.h>
    3.13  
    3.14 +#include "SDL_stdlib.h"
    3.15 +#include "SDL_string.h"
    3.16  #include "SDL_audiodev_c.h"
    3.17  
    3.18  #ifndef _PATH_DEV_DSP
    3.19 @@ -80,7 +79,8 @@
    3.20  
    3.21  		instance = 1;
    3.22  		do { /* Don't use errno ENOENT - it may not be thread-safe */
    3.23 -			sprintf(audiopath, "%s%d", audiodev, instance++);
    3.24 +			SDL_snprintf(audiopath, SDL_arraysize(audiopath),
    3.25 +			             "%s%d", audiodev, instance++);
    3.26  			exists = 0;
    3.27  			if ( stat(audiopath, &sb) == 0 ) {
    3.28  				exists = 1;
    3.29 @@ -100,11 +100,11 @@
    3.30  
    3.31  /* Get the name of the audio device we use for output */
    3.32  
    3.33 -#include <stdlib.h>
    3.34  #include <sys/types.h>
    3.35  #include <sys/stat.h>
    3.36 -#include <string.h>
    3.37  
    3.38 +#include "SDL_stdlib.h"
    3.39 +#include "SDL_string.h"
    3.40  #include "SDL_audiodev_c.h"
    3.41  
    3.42  #ifndef _PATH_DEV_DSP
    3.43 @@ -158,7 +158,7 @@
    3.44  
    3.45      cycle    = 0;
    3.46      while( devsettings[cycle][0] != '\0' ) {
    3.47 -        sprintf( audiopath,
    3.48 +        SDL_snprintf( audiopath, SDL_arraysize(audiopath),
    3.49                   _PATH_DEV_DSP,
    3.50                   devsettings[cycle][0],
    3.51                   devsettings[cycle][1],
     4.1 --- a/src/audio/SDL_audiomem.c	Tue Feb 07 07:03:29 2006 +0000
     4.2 +++ b/src/audio/SDL_audiomem.c	Tue Feb 07 09:29:18 2006 +0000
     4.3 @@ -31,8 +31,8 @@
     4.4  #include <stddef.h>
     4.5  #endif
     4.6  
     4.7 +#include "SDL_stdlib.h"
     4.8  #include "SDL_audiomem.h"
     4.9 -#include "SDL_stdlib.h"
    4.10  
    4.11  /* Allocate memory that will be shared between threads (freed on exit) */
    4.12  void *SDL_AllocAudioMem(int size)
     5.1 --- a/src/audio/SDL_wave.c	Tue Feb 07 07:03:29 2006 +0000
     5.2 +++ b/src/audio/SDL_wave.c	Tue Feb 07 09:29:18 2006 +0000
     5.3 @@ -24,10 +24,10 @@
     5.4  
     5.5  /* Microsoft WAVE file loading routines */
     5.6  
     5.7 +#include "SDL_stdlib.h"
     5.8 +#include "SDL_string.h"
     5.9  #include "SDL_error.h"
    5.10  #include "SDL_audio.h"
    5.11 -#include "SDL_stdlib.h"
    5.12 -#include "SDL_string.h"
    5.13  #include "SDL_wave.h"
    5.14  #include "SDL_endian.h"
    5.15  
     6.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Tue Feb 07 07:03:29 2006 +0000
     6.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Feb 07 09:29:18 2006 +0000
     6.3 @@ -24,16 +24,11 @@
     6.4  
     6.5  /* Allow access to a raw mixing buffer */
     6.6  
     6.7 -#include <stdlib.h>
     6.8 -#include <stdio.h>
     6.9 -#include <string.h>
    6.10 -#include <errno.h>
    6.11 -#include <unistd.h>
    6.12 -#include <fcntl.h>
    6.13 -#include <signal.h>
    6.14  #include <sys/types.h>
    6.15 -#include <sys/time.h>
    6.16 +#include <signal.h>	/* For kill() */
    6.17  
    6.18 +#include "SDL_stdlib.h"
    6.19 +#include "SDL_string.h"
    6.20  #include "SDL_audio.h"
    6.21  #include "SDL_error.h"
    6.22  #include "SDL_audiomem.h"
     7.1 --- a/src/audio/amigaos/SDL_ahiaudio.h	Tue Feb 07 07:03:29 2006 +0000
     7.2 +++ b/src/audio/amigaos/SDL_ahiaudio.h	Tue Feb 07 09:29:18 2006 +0000
     7.3 @@ -30,8 +30,6 @@
     7.4  #else
     7.5  #include <inline/exec.h>
     7.6  #endif
     7.7 -#include <stdlib.h>
     7.8 -#include <string.h>
     7.9  
    7.10  #include <devices/ahi.h>
    7.11  #include "mydebug.h"
     8.1 --- a/src/audio/arts/SDL_artsaudio.c	Tue Feb 07 07:03:29 2006 +0000
     8.2 +++ b/src/audio/arts/SDL_artsaudio.c	Tue Feb 07 09:29:18 2006 +0000
     8.3 @@ -22,14 +22,8 @@
     8.4  
     8.5  /* Allow access to a raw mixing buffer */
     8.6  
     8.7 -#include <sys/types.h>
     8.8 -#include <stdlib.h>
     8.9 -#include <stdio.h>
    8.10 -#include <string.h>
    8.11 -#include <errno.h>
    8.12 -#include <signal.h>
    8.13 -#include <unistd.h>
    8.14 -
    8.15 +#include "SDL_stdlib.h"
    8.16 +#include "SDL_string.h"
    8.17  #include "SDL_audio.h"
    8.18  #include "SDL_error.h"
    8.19  #include "SDL_audiomem.h"
     9.1 --- a/src/audio/baudio/SDL_beaudio.cc	Tue Feb 07 07:03:29 2006 +0000
     9.2 +++ b/src/audio/baudio/SDL_beaudio.cc	Tue Feb 07 09:29:18 2006 +0000
     9.3 @@ -22,15 +22,14 @@
     9.4  
     9.5  /* Allow access to the audio stream on BeOS */
     9.6  
     9.7 -#include <stdlib.h>
     9.8 -#include <stdio.h>
     9.9 -#include <string.h>
    9.10  #include <SoundPlayer.h>
    9.11  
    9.12  #include "SDL_BeApp.h"
    9.13  
    9.14  extern "C" {
    9.15  
    9.16 +#include "SDL_stdlib.h"
    9.17 +#include "SDL_string.h"
    9.18  #include "SDL_audio.h"
    9.19  #include "SDL_audio_c.h"
    9.20  #include "SDL_sysaudio.h"
    10.1 --- a/src/audio/dart/SDL_dart.c	Tue Feb 07 07:03:29 2006 +0000
    10.2 +++ b/src/audio/dart/SDL_dart.c	Tue Feb 07 09:29:18 2006 +0000
    10.3 @@ -22,10 +22,8 @@
    10.4  
    10.5  /* Allow access to a raw mixing buffer */
    10.6  
    10.7 -#include <stdio.h>
    10.8 -#include <stdlib.h>
    10.9 -#include <string.h>
   10.10 -
   10.11 +#include "SDL_stdlib.h"
   10.12 +#include "SDL_string.h"
   10.13  #include "SDL_types.h"
   10.14  #include "SDL_error.h"
   10.15  #include "SDL_timer.h"
    11.1 --- a/src/audio/dc/SDL_dcaudio.c	Tue Feb 07 07:03:29 2006 +0000
    11.2 +++ b/src/audio/dc/SDL_dcaudio.c	Tue Feb 07 09:29:18 2006 +0000
    11.3 @@ -23,10 +23,6 @@
    11.4  
    11.5  /* Output dreamcast aica */
    11.6  
    11.7 -#include <stdlib.h>
    11.8 -#include <stdio.h>
    11.9 -#include <string.h>
   11.10 -#include <errno.h>
   11.11  #include <unistd.h>
   11.12  #include <sys/stat.h>
   11.13  #include <sys/types.h>
   11.14 @@ -34,6 +30,8 @@
   11.15  #include <fcntl.h>
   11.16  
   11.17  
   11.18 +#include "SDL_stdlib.h"
   11.19 +#include "SDL_string.h"
   11.20  #include "SDL_audio.h"
   11.21  #include "SDL_error.h"
   11.22  #include "SDL_audiomem.h"
    12.1 --- a/src/audio/disk/SDL_diskaudio.c	Tue Feb 07 07:03:29 2006 +0000
    12.2 +++ b/src/audio/disk/SDL_diskaudio.c	Tue Feb 07 09:29:18 2006 +0000
    12.3 @@ -25,9 +25,7 @@
    12.4  
    12.5  /* Output raw audio data to a file. */
    12.6  
    12.7 -#include <stdlib.h>
    12.8  #include <stdio.h>
    12.9 -#include <string.h>
   12.10  #include <errno.h>
   12.11  #include <unistd.h>
   12.12  #include <sys/stat.h>
   12.13 @@ -36,6 +34,8 @@
   12.14  #include <fcntl.h>
   12.15  
   12.16  
   12.17 +#include "SDL_stdlib.h"
   12.18 +#include "SDL_string.h"
   12.19  #include "SDL_audio.h"
   12.20  #include "SDL_error.h"
   12.21  #include "SDL_audiomem.h"
    13.1 --- a/src/audio/dma/SDL_dmaaudio.c	Tue Feb 07 07:03:29 2006 +0000
    13.2 +++ b/src/audio/dma/SDL_dmaaudio.c	Tue Feb 07 09:29:18 2006 +0000
    13.3 @@ -22,9 +22,7 @@
    13.4  
    13.5  /* Allow access to a raw mixing buffer */
    13.6  
    13.7 -#include <stdlib.h>
    13.8  #include <stdio.h>
    13.9 -#include <string.h>
   13.10  #include <errno.h>
   13.11  #include <unistd.h>
   13.12  #include <fcntl.h>
   13.13 @@ -46,6 +44,8 @@
   13.14  #define MAP_FAILED	((Uint8 *)-1)
   13.15  #endif
   13.16  
   13.17 +#include "SDL_stdlib.h"
   13.18 +#include "SDL_string.h"
   13.19  #include "SDL_audio.h"
   13.20  #include "SDL_error.h"
   13.21  #include "SDL_audiomem.h"
    14.1 --- a/src/audio/dmedia/SDL_irixaudio.c	Tue Feb 07 07:03:29 2006 +0000
    14.2 +++ b/src/audio/dmedia/SDL_irixaudio.c	Tue Feb 07 09:29:18 2006 +0000
    14.3 @@ -23,8 +23,8 @@
    14.4  /* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */
    14.5  /* patch for IRIX 5 by Georg Schwarz 18/07/2004 */
    14.6  
    14.7 -#include <stdlib.h>
    14.8 -
    14.9 +#include "SDL_stdlib.h"
   14.10 +#include "SDL_string.h"
   14.11  #include "SDL_endian.h"
   14.12  #include "SDL_timer.h"
   14.13  #include "SDL_audio.h"
    15.1 --- a/src/audio/dsp/SDL_dspaudio.c	Tue Feb 07 07:03:29 2006 +0000
    15.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Tue Feb 07 09:29:18 2006 +0000
    15.3 @@ -25,9 +25,7 @@
    15.4  
    15.5  /* Allow access to a raw mixing buffer */
    15.6  
    15.7 -#include <stdlib.h>
    15.8 -#include <stdio.h>
    15.9 -#include <string.h>
   15.10 +#include <stdio.h>	/* For perror() ... should we really do this? */
   15.11  #include <errno.h>
   15.12  #include <unistd.h>
   15.13  #include <fcntl.h>
   15.14 @@ -43,6 +41,8 @@
   15.15  #include <sys/soundcard.h>
   15.16  #endif
   15.17  
   15.18 +#include "SDL_stdlib.h"
   15.19 +#include "SDL_string.h"
   15.20  #include "SDL_audio.h"
   15.21  #include "SDL_error.h"
   15.22  #include "SDL_audiomem.h"
   15.23 @@ -303,7 +303,6 @@
   15.24  #endif
   15.25  	if ( ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0 ) {
   15.26  		perror("SNDCTL_DSP_SETFRAGMENT");
   15.27 -		fprintf(stderr, "Warning: Couldn't set audio fragment size\n");
   15.28  	}
   15.29  #ifdef DEBUG_AUDIO
   15.30  	{ audio_buf_info info;
    16.1 --- a/src/audio/esd/SDL_esdaudio.c	Tue Feb 07 07:03:29 2006 +0000
    16.2 +++ b/src/audio/esd/SDL_esdaudio.c	Tue Feb 07 09:29:18 2006 +0000
    16.3 @@ -24,15 +24,12 @@
    16.4  
    16.5  #ifdef ESD_SUPPORT
    16.6  
    16.7 -#include <stdlib.h>
    16.8 -#include <stdio.h>
    16.9 -#include <string.h>
   16.10  #include <errno.h>
   16.11 -#include <signal.h>
   16.12 -#include <unistd.h>
   16.13  
   16.14  #include <esd.h>
   16.15  
   16.16 +#include "SDL_stdlib.h"
   16.17 +#include "SDL_string.h"
   16.18  #include "SDL_audio.h"
   16.19  #include "SDL_error.h"
   16.20  #include "SDL_audiomem.h"
   16.21 @@ -257,7 +254,7 @@
   16.22  	FILE *fp;
   16.23  	static char temp[BUFSIZ];
   16.24  
   16.25 -	sprintf(temp, "/proc/%d/cmdline", getpid());
   16.26 +	SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid());
   16.27  	fp = fopen(temp, "r");
   16.28  	if ( fp != NULL ) {
   16.29  		if ( fgets(temp, sizeof(temp)-1, fp) ) {
    17.1 --- a/src/audio/macosx/SDL_coreaudio.c	Tue Feb 07 07:03:29 2006 +0000
    17.2 +++ b/src/audio/macosx/SDL_coreaudio.c	Tue Feb 07 09:29:18 2006 +0000
    17.3 @@ -22,11 +22,8 @@
    17.4  
    17.5  #include <AudioUnit/AudioUnit.h>
    17.6  
    17.7 -#include <assert.h>
    17.8 -#include <stdlib.h>
    17.9 -#include <stdio.h>
   17.10 -#include <string.h>
   17.11 -
   17.12 +#include "SDL_stdlib.h"
   17.13 +#include "SDL_string.h"
   17.14  #include "SDL_endian.h"
   17.15  #include "SDL_audio.h"
   17.16  #include "SDL_audio_c.h"
   17.17 @@ -113,8 +110,10 @@
   17.18      /* No SDL conversion should be needed here, ever, since we accept
   17.19         any input format in OpenAudio, and leave the conversion to CoreAudio.
   17.20       */
   17.21 +    /*
   17.22      assert(!this->convert.needed);
   17.23      assert(this->spec.channels == ioData->mNumberChannels);
   17.24 +     */
   17.25      
   17.26      remaining = ioData->mDataByteSize;
   17.27      ptr = ioData->mData;
   17.28 @@ -270,8 +269,7 @@
   17.29      /* Allocate a sample buffer */
   17.30      bufferOffset = bufferSize = this->spec.size;
   17.31      buffer = SDL_malloc(bufferSize);
   17.32 -    assert(buffer);
   17.33 -    
   17.34 +
   17.35      /* Finally, start processing of the audio unit */
   17.36      result = AudioOutputUnitStart (outputAudioUnit);
   17.37      CHECK_RESULT("AudioOutputUnitStart")    
    18.1 --- a/src/audio/macrom/SDL_romaudio.c	Tue Feb 07 07:03:29 2006 +0000
    18.2 +++ b/src/audio/macrom/SDL_romaudio.c	Tue Feb 07 09:29:18 2006 +0000
    18.3 @@ -30,9 +30,6 @@
    18.4  #  include <DriverServices.h>
    18.5  #endif
    18.6  
    18.7 -#include <stdlib.h>
    18.8 -#include <stdio.h>
    18.9 -
   18.10  #if !defined(NewSndCallBackUPP) && (UNIVERSAL_INTERFACES_VERSION < 0x0335)
   18.11  #if !defined(NewSndCallBackProc) /* avoid circular redefinition... */
   18.12  #define NewSndCallBackUPP NewSndCallBackProc
   18.13 @@ -42,6 +39,8 @@
   18.14  #endif
   18.15  #endif
   18.16  
   18.17 +#include "SDL_stdlib.h"
   18.18 +#include "SDL_string.h"
   18.19  #include "SDL_endian.h"
   18.20  #include "SDL_audio.h"
   18.21  #include "SDL_audio_c.h"
   18.22 @@ -455,7 +454,7 @@
   18.23  
   18.24      /* allocate the 2 double-back buffers */
   18.25      for ( i=0; i<2; ++i ) {
   18.26 -        audio_buf[i] = calloc(1, sizeof(SndDoubleBuffer)+spec->size);
   18.27 +        audio_buf[i] = SDL_calloc(1, sizeof(SndDoubleBuffer)+spec->size);
   18.28          if ( audio_buf[i] == NULL ) {
   18.29              SDL_OutOfMemory();
   18.30              return(-1);
    19.1 --- a/src/audio/mint/SDL_mintaudio_dma8.c	Tue Feb 07 07:03:29 2006 +0000
    19.2 +++ b/src/audio/mint/SDL_mintaudio_dma8.c	Tue Feb 07 09:29:18 2006 +0000
    19.3 @@ -27,15 +27,13 @@
    19.4  	Patrice Mandin
    19.5  */
    19.6  
    19.7 -#include <stdlib.h>
    19.8 -#include <stdio.h>
    19.9 -#include <string.h>
   19.10 -
   19.11  /* Mint includes */
   19.12  #include <mint/osbind.h>
   19.13  #include <mint/falcon.h>
   19.14  #include <mint/cookie.h>
   19.15  
   19.16 +#include "SDL_stdlib.h"
   19.17 +#include "SDL_string.h"
   19.18  #include "SDL_endian.h"
   19.19  #include "SDL_audio.h"
   19.20  #include "SDL_audio_c.h"
    20.1 --- a/src/audio/mint/SDL_mintaudio_gsxb.c	Tue Feb 07 07:03:29 2006 +0000
    20.2 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c	Tue Feb 07 09:29:18 2006 +0000
    20.3 @@ -27,15 +27,13 @@
    20.4  	Patrice Mandin
    20.5  */
    20.6  
    20.7 -#include <stdlib.h>
    20.8 -#include <stdio.h>
    20.9 -#include <string.h>
   20.10 -
   20.11  /* Mint includes */
   20.12  #include <mint/osbind.h>
   20.13  #include <mint/falcon.h>
   20.14  #include <mint/cookie.h>
   20.15  
   20.16 +#include "SDL_stdlib.h"
   20.17 +#include "SDL_string.h"
   20.18  #include "SDL_endian.h"
   20.19  #include "SDL_audio.h"
   20.20  #include "SDL_audio_c.h"
    21.1 --- a/src/audio/mint/SDL_mintaudio_mcsn.c	Tue Feb 07 07:03:29 2006 +0000
    21.2 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c	Tue Feb 07 09:29:18 2006 +0000
    21.3 @@ -27,9 +27,6 @@
    21.4  	Patrice Mandin
    21.5  */
    21.6  
    21.7 -#include <stdlib.h>
    21.8 -#include <stdio.h>
    21.9 -#include <string.h>
   21.10  #include <support.h>
   21.11  
   21.12  /* Mint includes */
   21.13 @@ -37,6 +34,8 @@
   21.14  #include <mint/falcon.h>
   21.15  #include <mint/cookie.h>
   21.16  
   21.17 +#include "SDL_stdlib.h"
   21.18 +#include "SDL_string.h"
   21.19  #include "SDL_endian.h"
   21.20  #include "SDL_audio.h"
   21.21  #include "SDL_audio_c.h"
    22.1 --- a/src/audio/mint/SDL_mintaudio_stfa.c	Tue Feb 07 07:03:29 2006 +0000
    22.2 +++ b/src/audio/mint/SDL_mintaudio_stfa.c	Tue Feb 07 09:29:18 2006 +0000
    22.3 @@ -27,15 +27,13 @@
    22.4  	Patrice Mandin
    22.5  */
    22.6  
    22.7 -#include <stdlib.h>
    22.8 -#include <stdio.h>
    22.9 -#include <string.h>
   22.10 -
   22.11  /* Mint includes */
   22.12  #include <mint/osbind.h>
   22.13  #include <mint/falcon.h>
   22.14  #include <mint/cookie.h>
   22.15  
   22.16 +#include "SDL_stdlib.h"
   22.17 +#include "SDL_string.h"
   22.18  #include "SDL_endian.h"
   22.19  #include "SDL_audio.h"
   22.20  #include "SDL_audio_c.h"
    23.1 --- a/src/audio/mint/SDL_mintaudio_xbios.c	Tue Feb 07 07:03:29 2006 +0000
    23.2 +++ b/src/audio/mint/SDL_mintaudio_xbios.c	Tue Feb 07 09:29:18 2006 +0000
    23.3 @@ -27,9 +27,6 @@
    23.4  	Patrice Mandin, Didier Méquignon
    23.5  */
    23.6  
    23.7 -#include <stdlib.h>
    23.8 -#include <stdio.h>
    23.9 -#include <string.h>
   23.10  #include <unistd.h>
   23.11  #include <support.h>
   23.12  
   23.13 @@ -38,6 +35,8 @@
   23.14  #include <mint/falcon.h>
   23.15  #include <mint/cookie.h>
   23.16  
   23.17 +#include "SDL_stdlib.h"
   23.18 +#include "SDL_string.h"
   23.19  #include "SDL_endian.h"
   23.20  #include "SDL_audio.h"
   23.21  #include "SDL_audio_c.h"
    24.1 --- a/src/audio/mme/SDL_mmeaudio.c	Tue Feb 07 07:03:29 2006 +0000
    24.2 +++ b/src/audio/mme/SDL_mmeaudio.c	Tue Feb 07 09:29:18 2006 +0000
    24.3 @@ -91,7 +91,7 @@
    24.4      int len;
    24.5      char errbuf[MAXERRORLENGTH];
    24.6  
    24.7 -    sprintf(errbuf, "%s: ", function);
    24.8 +    SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
    24.9      len = SDL_strlen(errbuf);
   24.10      waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len);
   24.11      SDL_SetError("%s",errbuf);
    25.1 --- a/src/audio/mme/SDL_mmeaudio.h	Tue Feb 07 07:03:29 2006 +0000
    25.2 +++ b/src/audio/mme/SDL_mmeaudio.h	Tue Feb 07 09:29:18 2006 +0000
    25.3 @@ -22,9 +22,6 @@
    25.4  
    25.5  /* Allow access to a raw mixing buffer */
    25.6  
    25.7 -#include <stdio.h>
    25.8 -#include <stdlib.h>
    25.9 -#include <string.h>
   25.10  #include <mme_api.h>
   25.11  
   25.12  #include "SDL_audio.h"
    26.1 --- a/src/audio/nas/SDL_nasaudio.c	Tue Feb 07 07:03:29 2006 +0000
    26.2 +++ b/src/audio/nas/SDL_nasaudio.c	Tue Feb 07 09:29:18 2006 +0000
    26.3 @@ -26,13 +26,11 @@
    26.4  
    26.5  /* Allow access to a raw mixing buffer */
    26.6  
    26.7 -#include <stdlib.h>
    26.8 -#include <stdio.h>
    26.9 -#include <string.h>
   26.10 -#include <errno.h>
   26.11  #include <signal.h>
   26.12  #include <unistd.h>
   26.13  
   26.14 +#include "SDL_stdlib.h"
   26.15 +#include "SDL_string.h"
   26.16  #include "SDL_audio.h"
   26.17  #include "SDL_error.h"
   26.18  #include "SDL_audiomem.h"
    27.1 --- a/src/audio/nto/SDL_nto_audio.c	Tue Feb 07 07:03:29 2006 +0000
    27.2 +++ b/src/audio/nto/SDL_nto_audio.c	Tue Feb 07 09:29:18 2006 +0000
    27.3 @@ -20,9 +20,6 @@
    27.4      slouken@libsdl.org
    27.5  */
    27.6  
    27.7 -#include <stdlib.h>
    27.8 -#include <stdio.h>
    27.9 -#include <string.h>
   27.10  #include <errno.h>
   27.11  #include <unistd.h>
   27.12  #include <fcntl.h>
   27.13 @@ -34,6 +31,8 @@
   27.14  #include <sys/neutrino.h>
   27.15  #include <sys/asoundlib.h>
   27.16  
   27.17 +#include "SDL_stdlib.h"
   27.18 +#include "SDL_string.h"
   27.19  #include "SDL_audio.h"
   27.20  #include "SDL_error.h"
   27.21  #include "SDL_audiomem.h"
    28.1 --- a/src/audio/openbsd/SDL_openbsdaudio.c	Tue Feb 07 07:03:29 2006 +0000
    28.2 +++ b/src/audio/openbsd/SDL_openbsdaudio.c	Tue Feb 07 09:29:18 2006 +0000
    28.3 @@ -25,19 +25,17 @@
    28.4   * vedge@vedge.com.ar.
    28.5   */
    28.6  
    28.7 -#include <stdlib.h>
    28.8 -#include <stdio.h>
    28.9 -#include <string.h>
   28.10  #include <errno.h>
   28.11  #include <unistd.h>
   28.12  #include <fcntl.h>
   28.13 -#include <signal.h>
   28.14  #include <sys/time.h>
   28.15  #include <sys/ioctl.h>
   28.16  #include <sys/stat.h>
   28.17  #include <sys/types.h>
   28.18  #include <sys/audioio.h>
   28.19  
   28.20 +#include "SDL_stdlib.h"
   28.21 +#include "SDL_string.h"
   28.22  #include "SDL_audio.h"
   28.23  #include "SDL_error.h"
   28.24  #include "SDL_audiomem.h"
    29.1 --- a/src/audio/paudio/SDL_paudio.c	Tue Feb 07 07:03:29 2006 +0000
    29.2 +++ b/src/audio/paudio/SDL_paudio.c	Tue Feb 07 09:29:18 2006 +0000
    29.3 @@ -24,9 +24,6 @@
    29.4  
    29.5  /* Allow access to a raw mixing buffer */
    29.6  
    29.7 -#include <stdlib.h>
    29.8 -#include <stdio.h>
    29.9 -#include <string.h>
   29.10  #include <errno.h>
   29.11  #include <unistd.h>
   29.12  #include <fcntl.h>
   29.13 @@ -34,6 +31,8 @@
   29.14  #include <sys/ioctl.h>
   29.15  #include <sys/stat.h>
   29.16  
   29.17 +#include "SDL_stdlib.h"
   29.18 +#include "SDL_string.h"
   29.19  #include "SDL_audio.h"
   29.20  #include "SDL_error.h"
   29.21  #include "SDL_audiomem.h"
    30.1 --- a/src/audio/sun/SDL_sunaudio.c	Tue Feb 07 07:03:29 2006 +0000
    30.2 +++ b/src/audio/sun/SDL_sunaudio.c	Tue Feb 07 09:29:18 2006 +0000
    30.3 @@ -22,11 +22,8 @@
    30.4  
    30.5  /* Allow access to a raw mixing buffer */
    30.6  
    30.7 -#include <stdlib.h>
    30.8 -#include <stdio.h>
    30.9  #include <fcntl.h>
   30.10  #include <errno.h>
   30.11 -#include <string.h>
   30.12  #ifdef __NetBSD__
   30.13  #include <sys/ioctl.h>
   30.14  #include <sys/audioio.h>
   30.15 @@ -39,6 +36,8 @@
   30.16  #endif
   30.17  #include <unistd.h>
   30.18  
   30.19 +#include "SDL_stdlib.h"
   30.20 +#include "SDL_string.h"
   30.21  #include "SDL_endian.h"
   30.22  #include "SDL_audio.h"
   30.23  #include "SDL_audiomem.h"
    31.1 --- a/src/audio/ums/SDL_umsaudio.c	Tue Feb 07 07:03:29 2006 +0000
    31.2 +++ b/src/audio/ums/SDL_umsaudio.c	Tue Feb 07 09:29:18 2006 +0000
    31.3 @@ -24,9 +24,6 @@
    31.4  
    31.5  /* Allow access to a raw mixing buffer */
    31.6  
    31.7 -#include <stdlib.h>
    31.8 -#include <stdio.h>
    31.9 -#include <string.h>
   31.10  #include <errno.h>
   31.11  #include <unistd.h>
   31.12  #include <fcntl.h>
   31.13 @@ -36,6 +33,8 @@
   31.14  #include <sys/stat.h>
   31.15  #include <sys/mman.h>
   31.16  
   31.17 +#include "SDL_stdlib.h"
   31.18 +#include "SDL_string.h"
   31.19  #include "SDL_audio.h"
   31.20  #include "SDL_error.h"
   31.21  #include "SDL_audio_c.h"
    32.1 --- a/src/audio/windib/SDL_dibaudio.c	Tue Feb 07 07:03:29 2006 +0000
    32.2 +++ b/src/audio/windib/SDL_dibaudio.c	Tue Feb 07 09:29:18 2006 +0000
    32.3 @@ -25,11 +25,11 @@
    32.4  #include "SDL_windows.h"
    32.5  #include <mmsystem.h>
    32.6  
    32.7 +#include "SDL_stdlib.h"
    32.8 +#include "SDL_string.h"
    32.9  #include "SDL_audio.h"
   32.10  #include "SDL_mutex.h"
   32.11  #include "SDL_timer.h"
   32.12 -#include "SDL_stdlib.h"
   32.13 -#include "SDL_string.h"
   32.14  #include "SDL_audio_c.h"
   32.15  #include "SDL_dibaudio.h"
   32.16  #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
    33.1 --- a/src/audio/windx5/SDL_dx5audio.c	Tue Feb 07 07:03:29 2006 +0000
    33.2 +++ b/src/audio/windx5/SDL_dx5audio.c	Tue Feb 07 09:29:18 2006 +0000
    33.3 @@ -22,12 +22,12 @@
    33.4  
    33.5  /* Allow access to a raw mixing buffer */
    33.6  
    33.7 +#include "SDL_stdlib.h"
    33.8 +#include "SDL_string.h"
    33.9  #include "SDL_types.h"
   33.10  #include "SDL_error.h"
   33.11  #include "SDL_timer.h"
   33.12  #include "SDL_audio.h"
   33.13 -#include "SDL_stdlib.h"
   33.14 -#include "SDL_string.h"
   33.15  #include "SDL_audio_c.h"
   33.16  #include "SDL_dx5audio.h"
   33.17  
    34.1 --- a/src/cdrom/SDL_cdrom.c	Tue Feb 07 07:03:29 2006 +0000
    34.2 +++ b/src/cdrom/SDL_cdrom.c	Tue Feb 07 09:29:18 2006 +0000
    34.3 @@ -22,10 +22,10 @@
    34.4  
    34.5  /* This is the CD-audio control API for Simple DirectMedia Layer */
    34.6  
    34.7 +#include "SDL_stdlib.h"
    34.8 +#include "SDL_string.h"
    34.9  #include "SDL_error.h"
   34.10  #include "SDL_cdrom.h"
   34.11 -#include "SDL_stdlib.h"
   34.12 -#include "SDL_string.h"
   34.13  #include "SDL_syscdrom.h"
   34.14  
   34.15  #if !defined(macintosh)
    35.1 --- a/src/cdrom/aix/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    35.2 +++ b/src/cdrom/aix/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    35.3 @@ -27,11 +27,8 @@
    35.4  #define DEBUG_CDROM 1
    35.5  
    35.6  #include <sys/types.h>
    35.7 -#include <stdlib.h>
    35.8  #include <sys/stat.h>
    35.9  #include <fcntl.h>
   35.10 -#include <stdio.h>
   35.11 -#include <string.h>
   35.12  #include <errno.h>
   35.13  #include <unistd.h>
   35.14  
   35.15 @@ -43,6 +40,8 @@
   35.16  #include <fstab.h>
   35.17  #include <sys/scdisk.h>
   35.18  
   35.19 +#include "SDL_stdlib.h"
   35.20 +#include "SDL_string.h"
   35.21  #include "SDL_error.h"
   35.22  #include "SDL_cdrom.h"
   35.23  #include "SDL_syscdrom.h"
    36.1 --- a/src/cdrom/beos/SDL_syscdrom.cc	Tue Feb 07 07:03:29 2006 +0000
    36.2 +++ b/src/cdrom/beos/SDL_syscdrom.cc	Tue Feb 07 09:29:18 2006 +0000
    36.3 @@ -25,10 +25,7 @@
    36.4   */
    36.5  
    36.6  #include <sys/types.h>
    36.7 -#include <stdlib.h>
    36.8  #include <sys/stat.h>
    36.9 -#include <stdio.h>
   36.10 -#include <string.h>
   36.11  #include <unistd.h>
   36.12  
   36.13  #include <scsi.h>
   36.14 @@ -36,6 +33,8 @@
   36.15  #include <Entry.h>
   36.16  #include <Path.h>
   36.17  
   36.18 +#include "SDL_stdlib.h"
   36.19 +#include "SDL_string.h"
   36.20  #include "SDL_error.h"
   36.21  #include "SDL_cdrom.h"
   36.22  extern "C" {
    37.1 --- a/src/cdrom/bsdi/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    37.2 +++ b/src/cdrom/bsdi/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    37.3 @@ -29,18 +29,16 @@
    37.4  */
    37.5  
    37.6  #include <sys/types.h>
    37.7 -#include <stdlib.h>
    37.8  #include <sys/stat.h>
    37.9  #include <fcntl.h>
   37.10 -#include <stdio.h>
   37.11 -#include <string.h>
   37.12 -#include <errno.h>
   37.13  #include <err.h>
   37.14  #include <unistd.h>
   37.15  #include <sys/ioctl.h>
   37.16  #include </sys/dev/scsi/scsi.h>
   37.17  #include </sys/dev/scsi/scsi_ioctl.h>
   37.18  
   37.19 +#include "SDL_stdlib.h"
   37.20 +#include "SDL_string.h"
   37.21  #include "SDL_error.h"
   37.22  #include "SDL_cdrom.h"
   37.23  #include "SDL_syscdrom.h"
   37.24 @@ -303,7 +301,7 @@
   37.25  			char *insert;
   37.26  			exists = 1;
   37.27  			for ( j=checklist[i][1]; exists; ++j ) {
   37.28 -				sprintf(drive, "/dev/%sc", &checklist[i][3]);
   37.29 +				SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc", &checklist[i][3]);
   37.30  				insert = SDL_strchr(drive, '?');
   37.31  				if ( insert != NULL ) {
   37.32  					*insert = j;
   37.33 @@ -323,7 +321,7 @@
   37.34  				}
   37.35  			}
   37.36  		} else {
   37.37 -			sprintf(drive, "/dev/%s", checklist[i]);
   37.38 +			SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]);
   37.39  			if ( CheckDrive(drive, &stbuf) > 0 ) {
   37.40  				AddDrive(drive, &stbuf);
   37.41  			}
    38.1 --- a/src/cdrom/dc/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    38.2 +++ b/src/cdrom/dc/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    38.3 @@ -22,8 +22,6 @@
    38.4  
    38.5  /* Functions for system-level CD-ROM audio control */
    38.6  
    38.7 -#include <stdlib.h>
    38.8 -#include <stdio.h>
    38.9  #include <dc/cdrom.h>
   38.10  #include <dc/spu.h>
   38.11  
    39.1 --- a/src/cdrom/freebsd/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    39.2 +++ b/src/cdrom/freebsd/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    39.3 @@ -23,15 +23,14 @@
    39.4  /* Functions for system-level CD-ROM audio control */
    39.5  
    39.6  #include <sys/types.h>
    39.7 -#include <stdlib.h>
    39.8  #include <sys/stat.h>
    39.9  #include <fcntl.h>
   39.10 -#include <stdio.h>
   39.11 -#include <string.h>
   39.12  #include <errno.h>
   39.13  #include <unistd.h>
   39.14  #include <sys/cdio.h>
   39.15  
   39.16 +#include "SDL_stdlib.h"
   39.17 +#include "SDL_string.h"
   39.18  #include "SDL_error.h"
   39.19  #include "SDL_cdrom.h"
   39.20  #include "SDL_syscdrom.h"
   39.21 @@ -189,7 +188,7 @@
   39.22  			char *insert;
   39.23  			exists = 1;
   39.24  			for ( j=checklist[i][1]; exists; ++j ) {
   39.25 -				sprintf(drive, "/dev/%sc", &checklist[i][3]);
   39.26 +				SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc", &checklist[i][3]);
   39.27  				insert = SDL_strchr(drive, '?');
   39.28  				if ( insert != NULL ) {
   39.29  					*insert = j;
   39.30 @@ -209,7 +208,7 @@
   39.31  				}
   39.32  			}
   39.33  		} else {
   39.34 -			sprintf(drive, "/dev/%s", checklist[i]);
   39.35 +			SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]);
   39.36  			if ( CheckDrive(drive, &stbuf) > 0 ) {
   39.37  				AddDrive(drive, &stbuf);
   39.38  			}
    40.1 --- a/src/cdrom/linux/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    40.2 +++ b/src/cdrom/linux/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    40.3 @@ -23,12 +23,9 @@
    40.4  /* Functions for system-level CD-ROM audio control */
    40.5  
    40.6  #include <sys/types.h>
    40.7 -#include <stdlib.h>
    40.8  #include <sys/stat.h>
    40.9  #include <sys/ioctl.h>
   40.10  #include <fcntl.h>
   40.11 -#include <stdio.h>
   40.12 -#include <string.h>
   40.13  #include <errno.h>
   40.14  #include <unistd.h>
   40.15  #ifdef __linux__
   40.16 @@ -83,6 +80,8 @@
   40.17  #endif
   40.18  #endif /* USE_MNTENT */
   40.19  
   40.20 +#include "SDL_stdlib.h"
   40.21 +#include "SDL_string.h"
   40.22  #include "SDL_error.h"
   40.23  #include "SDL_cdrom.h"
   40.24  #include "SDL_syscdrom.h"
   40.25 @@ -336,7 +335,7 @@
   40.26  			char *insert;
   40.27  			exists = 1;
   40.28  			for ( j=checklist[i][1]; exists; ++j ) {
   40.29 -				sprintf(drive, "/dev/%s", &checklist[i][3]);
   40.30 +				SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", &checklist[i][3]);
   40.31  				insert = SDL_strchr(drive, '?');
   40.32  				if ( insert != NULL ) {
   40.33  					*insert = j;
   40.34 @@ -359,7 +358,7 @@
   40.35  				}
   40.36  			}
   40.37  		} else {
   40.38 -			sprintf(drive, "/dev/%s", checklist[i]);
   40.39 +			SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]);
   40.40  #ifdef DEBUG_CDROM
   40.41    fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive);
   40.42  #endif
    41.1 --- a/src/cdrom/macosx/AudioFileReaderThread.c	Tue Feb 07 07:03:29 2006 +0000
    41.2 +++ b/src/cdrom/macosx/AudioFileReaderThread.c	Tue Feb 07 09:29:18 2006 +0000
    41.3 @@ -546,7 +546,7 @@
    41.4  {
    41.5      if (afm != NULL) {
    41.6          if (afm->mFileBuffer) {
    41.7 -            free (afm->mFileBuffer);
    41.8 +            free(afm->mFileBuffer);
    41.9          }
   41.10  
   41.11          SDL_free(afm);
   41.12 @@ -594,7 +594,7 @@
   41.13      afm->mBufferOffset = inChunkSize;
   41.14      afm->mChunkSize = inChunkSize;
   41.15      afm->mFileLength = inFileLength;
   41.16 -    afm->mFileBuffer = (char*) malloc (afm->mChunkSize * 2);
   41.17 +    afm->mFileBuffer = (char*) SDL_malloc(afm->mChunkSize * 2);
   41.18      FSGetForkPosition(afm->mForkRefNum, &afm->mAudioDataOffset);
   41.19      assert (afm->mFileBuffer != NULL);
   41.20      return afm;
    42.1 --- a/src/cdrom/macosx/SDLOSXCAGuard.c	Tue Feb 07 07:03:29 2006 +0000
    42.2 +++ b/src/cdrom/macosx/SDLOSXCAGuard.c	Tue Feb 07 09:29:18 2006 +0000
    42.3 @@ -68,12 +68,19 @@
    42.4  //  Includes
    42.5  //=============================================================================
    42.6  
    42.7 +/*
    42.8  #include <stdio.h>
    42.9  #include <stdlib.h>
   42.10  #include <string.h>
   42.11 +*/
   42.12 +#include "SDL_stdlib.h"
   42.13 +#include "SDL_string.h"
   42.14  
   42.15  //#define NDEBUG 1
   42.16 +/*
   42.17  #include <assert.h>
   42.18 +*/
   42.19 +#define assert(X)
   42.20  
   42.21  
   42.22  #include "SDLOSXCAGuard.h"
    43.1 --- a/src/cdrom/macosx/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    43.2 +++ b/src/cdrom/macosx/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    43.3 @@ -58,7 +58,7 @@
    43.4          return 0;
    43.5          
    43.6      /* Allocate memory for tracks */
    43.7 -    tracks[cdrom->id] = (FSRef*) calloc (1, sizeof(**tracks) * cdrom->numtracks);
    43.8 +    tracks[cdrom->id] = (FSRef*) SDL_calloc (1, sizeof(**tracks) * cdrom->numtracks);
    43.9      if (tracks[cdrom->id] == NULL) {
   43.10          SDL_OutOfMemory ();
   43.11          return -1;
   43.12 @@ -203,14 +203,14 @@
   43.13      }
   43.14      
   43.15      /* Allocate space for volumes */
   43.16 -    volumes = (FSVolumeRefNum*) calloc (1, sizeof(*volumes) * SDL_numcds);
   43.17 +    volumes = (FSVolumeRefNum*) SDL_calloc (1, sizeof(*volumes) * SDL_numcds);
   43.18      if (volumes == NULL) {
   43.19          SDL_OutOfMemory ();
   43.20          return -1;
   43.21      }
   43.22      
   43.23      /* Allocate space for tracks */
   43.24 -    tracks = (FSRef**) calloc (1, sizeof(*tracks) * (SDL_numcds + 1));
   43.25 +    tracks = (FSRef**) SDL_calloc (1, sizeof(*tracks) * (SDL_numcds + 1));
   43.26      if (tracks == NULL) {
   43.27          SDL_OutOfMemory ();
   43.28          return -1;
    44.1 --- a/src/cdrom/mint/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    44.2 +++ b/src/cdrom/mint/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    44.3 @@ -27,9 +27,6 @@
    44.4  */
    44.5  
    44.6  #include <errno.h>
    44.7 -#include <stdio.h>
    44.8 -#include <stdlib.h>
    44.9 -#include <string.h>
   44.10  
   44.11  #include <cdromio.h>
   44.12  #include <metados.h>
    45.1 --- a/src/cdrom/openbsd/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    45.2 +++ b/src/cdrom/openbsd/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    45.3 @@ -24,16 +24,15 @@
    45.4  
    45.5  #include <sys/types.h>
    45.6  #include <sys/ioctl.h>
    45.7 -#include <stdlib.h>
    45.8  #include <sys/stat.h>
    45.9  #include <fcntl.h>
   45.10 -#include <stdio.h>
   45.11 -#include <string.h>
   45.12  #include <errno.h>
   45.13  #include <unistd.h>
   45.14  #include <sys/ioctl.h>
   45.15  #include <sys/cdio.h>
   45.16  
   45.17 +#include "SDL_stdlib.h"
   45.18 +#include "SDL_string.h"
   45.19  #include "SDL_error.h"
   45.20  #include "SDL_cdrom.h"
   45.21  #include "SDL_syscdrom.h"
   45.22 @@ -198,7 +197,7 @@
   45.23  			char *insert;
   45.24  			exists = 1;
   45.25  			for ( j=checklist[i][1]; exists; ++j ) {
   45.26 -				sprintf(drive, "/dev/%s", &checklist[i][3]);
   45.27 +				SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", &checklist[i][3]);
   45.28  				insert = SDL_strchr(drive, '?');
   45.29  				if ( insert != NULL ) {
   45.30  					*insert = j;
   45.31 @@ -218,7 +217,7 @@
   45.32  				}
   45.33  			}
   45.34  		} else {
   45.35 -			sprintf(drive, "/dev/%s", checklist[i]);
   45.36 +			SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]);
   45.37  			if ( CheckDrive(drive, &stbuf) > 0 ) {
   45.38  				AddDrive(drive, &stbuf);
   45.39  			}
    46.1 --- a/src/cdrom/os2/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    46.2 +++ b/src/cdrom/os2/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    46.3 @@ -25,10 +25,9 @@
    46.4  #define INCL_MCIOS2
    46.5  #include <os2.h>
    46.6  #include <os2me.h>
    46.7 -#include <stdio.h>
    46.8 -#include <stdlib.h>
    46.9 -#include <string.h>
   46.10  
   46.11 +#include "SDL_stdlib.h"
   46.12 +#include "SDL_string.h"
   46.13  #include "SDL_error.h"
   46.14  #include "SDL_cdrom.h"
   46.15  #include "SDL_syscdrom.h"
    47.1 --- a/src/cdrom/osf/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    47.2 +++ b/src/cdrom/osf/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    47.3 @@ -31,12 +31,9 @@
    47.4  #include <io/cam/cdrom.h>
    47.5  #include <io/cam/rzdisk.h>
    47.6  #include <io/common/devgetinfo.h>
    47.7 -#include <alloca.h>
    47.8 -#include <stdlib.h>
    47.9 -#include <stdio.h>
   47.10 -#include <string.h>
   47.11 -#include <errno.h>
   47.12  
   47.13 +#include "SDL_stdlib.h"
   47.14 +#include "SDL_string.h"
   47.15  #include "SDL_error.h"
   47.16  #include "SDL_cdrom.h"
   47.17  #include "SDL_syscdrom.h"
   47.18 @@ -218,7 +215,7 @@
   47.19  	    while (devent = readdir(devdir))
   47.20  		if (SDL_memcmp(checklist[i].name, devent->d_name, name_len) == 0)
   47.21  		    if (devent->d_name[devent->d_namlen-1] == 'c') {
   47.22 -			sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name);
   47.23 +			SDL_snprintf(drive, SDL_arraysize(drive), "%s/%s", checklist[i].dir, devent->d_name);
   47.24  #ifdef DEBUG_CDROM
   47.25  			fprintf(stderr, "Try to add drive: %s\n", drive);
   47.26  #endif
    48.1 --- a/src/cdrom/qnx/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    48.2 +++ b/src/cdrom/qnx/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    48.3 @@ -23,17 +23,16 @@
    48.4  /* Functions for system-level CD-ROM audio control */
    48.5  
    48.6  #include <sys/types.h>
    48.7 -#include <stdlib.h>
    48.8  #include <sys/stat.h>
    48.9  #include <sys/ioctl.h>
   48.10  #include <fcntl.h>
   48.11 -#include <stdio.h>
   48.12  #include <errno.h>
   48.13 -#include <string.h>
   48.14  #include <unistd.h>
   48.15  #include <sys/cdrom.h>
   48.16  #include <sys/dcmd_cam.h>
   48.17  
   48.18 +#include "SDL_stdlib.h"
   48.19 +#include "SDL_string.h"
   48.20  #include "SDL_error.h"
   48.21  #include "SDL_cdrom.h"
   48.22  #include "SDL_timer.h"
   48.23 @@ -218,7 +217,7 @@
   48.24  
   48.25              for ( j=checklist[i][1]; exists; ++j )
   48.26              {
   48.27 -                sprintf(drive, "/dev/%s", &checklist[i][3]);
   48.28 +                SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", &checklist[i][3]);
   48.29                  insert = SDL_strchr(drive, '?');
   48.30                  if (insert != NULL)
   48.31                  {
   48.32 @@ -242,7 +241,7 @@
   48.33          }
   48.34          else
   48.35          {
   48.36 -            sprintf(drive, "/dev/%s", checklist[i]);
   48.37 +            SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]);
   48.38              if (CheckDrive(drive, &stbuf) > 0)
   48.39              {
   48.40                  AddDrive(drive, &stbuf);
    49.1 --- a/src/cdrom/win32/SDL_syscdrom.c	Tue Feb 07 07:03:29 2006 +0000
    49.2 +++ b/src/cdrom/win32/SDL_syscdrom.c	Tue Feb 07 09:29:18 2006 +0000
    49.3 @@ -25,10 +25,10 @@
    49.4  #include "SDL_windows.h"
    49.5  #include <mmsystem.h>
    49.6  
    49.7 +#include "SDL_stdlib.h"
    49.8 +#include "SDL_string.h"
    49.9  #include "SDL_error.h"
   49.10  #include "SDL_cdrom.h"
   49.11 -#include "SDL_stdlib.h"
   49.12 -#include "SDL_string.h"
   49.13  #include "SDL_syscdrom.h"
   49.14  
   49.15  /* This really broken?? */
    50.1 --- a/src/file/SDL_rwops.c	Tue Feb 07 07:03:29 2006 +0000
    50.2 +++ b/src/file/SDL_rwops.c	Tue Feb 07 09:29:18 2006 +0000
    50.3 @@ -24,10 +24,10 @@
    50.4     data sources.  It can easily be extended to files, memory, etc.
    50.5  */
    50.6  
    50.7 +#include "SDL_stdlib.h"
    50.8 +#include "SDL_string.h"
    50.9  #include "SDL_error.h"
   50.10  #include "SDL_rwops.h"
   50.11 -#include "SDL_stdlib.h"
   50.12 -#include "SDL_string.h"
   50.13  
   50.14  #ifdef HAVE_STDIO_H
   50.15  
    51.1 --- a/src/joystick/SDL_joystick.c	Tue Feb 07 07:03:29 2006 +0000
    51.2 +++ b/src/joystick/SDL_joystick.c	Tue Feb 07 09:29:18 2006 +0000
    51.3 @@ -22,10 +22,10 @@
    51.4  
    51.5  /* This is the joystick API for Simple DirectMedia Layer */
    51.6  
    51.7 +#include "SDL_stdlib.h"
    51.8 +#include "SDL_string.h"
    51.9  #include "SDL_error.h"
   51.10  #include "SDL_events.h"
   51.11 -#include "SDL_stdlib.h"
   51.12 -#include "SDL_string.h"
   51.13  #ifndef DISABLE_EVENTS
   51.14  #include "SDL_events_c.h"
   51.15  #endif
    52.1 --- a/src/joystick/amigaos/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    52.2 +++ b/src/joystick/amigaos/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    52.3 @@ -23,8 +23,6 @@
    52.4  
    52.5  /* This is the system specific header for the SDL joystick API */
    52.6  
    52.7 -#include <stdio.h>		/* For the definition of NULL */
    52.8 -
    52.9  #include <libraries/lowlevel.h>
   52.10  #if defined(__SASC) || defined(STORMC4_WOS)
   52.11  #include <proto/exec.h>
   52.12 @@ -39,8 +37,8 @@
   52.13  
   52.14  extern struct ExecBase *SysBase;
   52.15  extern struct GfxBase *GfxBase;
   52.16 -#include <stdlib.h>
   52.17  
   52.18 +#include "SDL_stdlib.h"
   52.19  #include "SDL_error.h"
   52.20  #include "SDL_joystick.h"
   52.21  #include "SDL_sysjoystick.h"
    53.1 --- a/src/joystick/beos/SDL_bejoystick.cc	Tue Feb 07 07:03:29 2006 +0000
    53.2 +++ b/src/joystick/beos/SDL_bejoystick.cc	Tue Feb 07 09:29:18 2006 +0000
    53.3 @@ -22,15 +22,13 @@
    53.4  
    53.5  /* This is the system specific header for the SDL joystick API */
    53.6  
    53.7 -#include <stdio.h>
    53.8 -#include <stdlib.h>
    53.9 -#include <string.h>
   53.10 -
   53.11  #include <be/support/String.h>
   53.12  #include <be/device/Joystick.h>
   53.13  
   53.14  extern "C" {
   53.15  
   53.16 +#include "SDL_stdlib.h"
   53.17 +#include "SDL_string.h"
   53.18  #include "SDL_error.h"
   53.19  #include "SDL_joystick.h"
   53.20  #include "SDL_sysjoystick.h"
    54.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    54.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    54.3 @@ -29,11 +29,8 @@
    54.4  
    54.5  #include <sys/param.h>
    54.6  
    54.7 -#include <stdio.h>
    54.8 -#include <stdlib.h>
    54.9  #include <unistd.h>
   54.10  #include <fcntl.h>
   54.11 -#include <string.h>
   54.12  #include <errno.h>
   54.13  
   54.14  #if defined(HAVE_USB_H)
   54.15 @@ -59,6 +56,8 @@
   54.16  #include <machine/joystick.h>
   54.17  #endif
   54.18  
   54.19 +#include "SDL_stdlib.h"
   54.20 +#include "SDL_string.h"
   54.21  #include "SDL_error.h"
   54.22  #include "SDL_joystick.h"
   54.23  #include "SDL_sysjoystick.h"
   54.24 @@ -145,7 +144,7 @@
   54.25  	for (i = 0; i < MAX_UHID_JOYS; i++) {
   54.26  		SDL_Joystick nj;
   54.27  
   54.28 -		sprintf(s, "/dev/uhid%d", i);
   54.29 +		SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i);
   54.30  
   54.31  		nj.index = SDL_numjoysticks;
   54.32  		joynames[nj.index] = strdup(s);
   54.33 @@ -159,7 +158,7 @@
   54.34  		}
   54.35  	}
   54.36  	for (i = 0; i < MAX_JOY_JOYS; i++) {
   54.37 -		sprintf(s, "/dev/joy%d", i);
   54.38 +		SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i);
   54.39  		fd = open(s, O_RDONLY);
   54.40  		if (fd != -1) {
   54.41  			joynames[SDL_numjoysticks++] = strdup(s);
   54.42 @@ -312,7 +311,7 @@
   54.43  				case HUG_GAME_PAD:
   54.44  					s = hid_usage_in_page(hitem.usage);
   54.45  					sp = SDL_malloc(SDL_strlen(s) + 5);
   54.46 -					sprintf(sp, "%s (%d)", s,
   54.47 +					SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)", s,
   54.48  					    joy->index);
   54.49  					joydevnames[joy->index] = sp;
   54.50  				}
    55.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    55.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    55.3 @@ -23,11 +23,8 @@
    55.4  /* SDL joystick driver for Darwin / MacOS X, based on the IOKit HID API */
    55.5  /* Written 2001 by Max Horn */
    55.6  
    55.7 -#include <stdio.h>
    55.8 -#include <stdlib.h>
    55.9  #include <unistd.h>
   55.10  #include <ctype.h>
   55.11 -#include <sys/errno.h>
   55.12  #include <sysexits.h>
   55.13  #include <mach/mach.h>
   55.14  #include <mach/mach_error.h>
    56.1 --- a/src/joystick/dc/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    56.2 +++ b/src/joystick/dc/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    56.3 @@ -22,9 +22,8 @@
    56.4  
    56.5  /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
    56.6  
    56.7 -#include <stdlib.h>
    56.8 -#include <stdio.h>		/* For the definition of NULL */
    56.9 -
   56.10 +#include "SDL_stdlib.h"
   56.11 +#include "SDL_string.h"
   56.12  #include "SDL_error.h"
   56.13  #include "SDL_joystick.h"
   56.14  #include "SDL_sysjoystick.h"
    57.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    57.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    57.3 @@ -22,9 +22,6 @@
    57.4  
    57.5  /* This is the system specific header for the SDL joystick API */
    57.6  
    57.7 -#include <stdio.h>		/* For the definition of NULL */
    57.8 -#include <stdlib.h>		/* For SDL_getenv() prototype */
    57.9 -#include <string.h>
   57.10  #include <sys/stat.h>
   57.11  #include <unistd.h>
   57.12  #include <fcntl.h>
   57.13 @@ -38,6 +35,8 @@
   57.14  #include <linux/input.h>
   57.15  #endif
   57.16  
   57.17 +#include "SDL_stdlib.h"
   57.18 +#include "SDL_string.h"
   57.19  #include "SDL_error.h"
   57.20  #include "SDL_joystick.h"
   57.21  #include "SDL_sysjoystick.h"
   57.22 @@ -325,7 +324,7 @@
   57.23  
   57.24  	for ( i=0; i<SDL_TABLESIZE(joydev_pattern); ++i ) {
   57.25  		for ( j=0; j < MAX_JOYSTICKS; ++j ) {
   57.26 -			sprintf(path, joydev_pattern[i], j);
   57.27 +			SDL_snprintf(path, SDL_arraysize(path), joydev_pattern[i], j);
   57.28  
   57.29  			/* rcg06302000 replaced access(F_OK) call with stat().
   57.30  			 * stat() will fail if the file doesn't exist, so it's
    58.1 --- a/src/joystick/mint/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    58.2 +++ b/src/joystick/mint/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    58.3 @@ -26,13 +26,11 @@
    58.4   *	Patrice Mandin
    58.5   */
    58.6  
    58.7 -#include <stdio.h>
    58.8 -#include <stdlib.h>
    58.9 -#include <string.h>
   58.10 -
   58.11  #include <mint/cookie.h>
   58.12  #include <mint/osbind.h>
   58.13  
   58.14 +#include "SDL_stdlib.h"
   58.15 +#include "SDL_string.h"
   58.16  #include "SDL_types.h"
   58.17  #include "SDL_error.h"
   58.18  #include "SDL_joystick.h"
    59.1 --- a/src/joystick/os2/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    59.2 +++ b/src/joystick/os2/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    59.3 @@ -22,8 +22,6 @@
    59.4  
    59.5  /* OS/2 Joystick driver, contributed by Daniel Caetano */
    59.6  
    59.7 -#include <stdlib.h>
    59.8 -#include <stdio.h>
    59.9  #include <mem.h>
   59.10  
   59.11  #define INCL_DOSDEVICES
   59.12 @@ -32,6 +30,8 @@
   59.13  #include <os2.h>
   59.14  #include "joyos2.h"
   59.15  
   59.16 +#include "SDL_stdlib.h"
   59.17 +#include "SDL_string.h"
   59.18  #include "SDL_error.h"
   59.19  #include "SDL_joystick.h"
   59.20  #include "SDL_sysjoystick.h"
   59.21 @@ -217,7 +217,7 @@
   59.22  		if (joycfg.buttons>=7) SYS_JoyData[0].buttoncalc[2]=((axis[2]->upper+axis[3]->centre)>>1);
   59.23  		if (joycfg.buttons>=8) SYS_JoyData[0].buttoncalc[3]=((axis[3]->upper+axis[3]->centre)>>1);
   59.24  		/* Intialize Joystick Name */
   59.25 -		strcpy (SYS_JoyData[0].szDeviceName,joycfg.name);
   59.26 +		SDL_strcpy (SYS_JoyData[0].szDeviceName,joycfg.name);
   59.27  		}
   59.28  	/* Default Init ... autoconfig */
   59.29  	else
   59.30 @@ -294,7 +294,8 @@
   59.31  			}
   59.32  		/* Hack to define Joystick Port Names */
   59.33  		if ( numdevs > maxdevs ) numdevs = maxdevs;
   59.34 -		for (i=0; i<numdevs; i++) sprintf (SYS_JoyData[i].szDeviceName,"Default Joystick %c",'A'+SYS_JoyData[i].id);
   59.35 +		for (i=0; i<numdevs; i++) {
   59.36 +			SDL_sprintf (SYS_JoyData[i].szDeviceName, SDL_arraysize(szDeviceName), "Default Joystick %c", 'A'+SYS_JoyData[i].id);
   59.37  		}
   59.38  	}
   59.39  /* Return the number of devices found */
    60.1 --- a/src/joystick/riscos/SDL_sysjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    60.2 +++ b/src/joystick/riscos/SDL_sysjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    60.3 @@ -29,9 +29,8 @@
    60.4  
    60.5  /* This is the system specific header for the SDL joystick API */
    60.6  
    60.7 -#include <stdio.h>		/* For the definition of NULL */
    60.8 -#include <stdlib.h>
    60.9 -
   60.10 +#include "SDL_stdlib.h"
   60.11 +#include "SDL_string.h"
   60.12  #include "SDL_error.h"
   60.13  #include "SDL_joystick.h"
   60.14  #include "SDL_sysjoystick.h"
    61.1 --- a/src/joystick/win32/SDL_mmjoystick.c	Tue Feb 07 07:03:29 2006 +0000
    61.2 +++ b/src/joystick/win32/SDL_mmjoystick.c	Tue Feb 07 09:29:18 2006 +0000
    61.3 @@ -22,11 +22,11 @@
    61.4  
    61.5  /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
    61.6  
    61.7 +#include "SDL_stdlib.h"
    61.8 +#include "SDL_string.h"
    61.9  #include "SDL_error.h"
   61.10  #include "SDL_events.h"
   61.11  #include "SDL_joystick.h"
   61.12 -#include "SDL_stdlib.h"
   61.13 -#include "SDL_string.h"
   61.14  #include "SDL_sysjoystick.h"
   61.15  #include "SDL_joystick_c.h"
   61.16  
    62.1 --- a/src/loadso/macosx/SDL_loadso.c	Tue Feb 07 07:03:29 2006 +0000
    62.2 +++ b/src/loadso/macosx/SDL_loadso.c	Tue Feb 07 09:29:18 2006 +0000
    62.3 @@ -62,9 +62,6 @@
    62.4  */
    62.5  
    62.6  #include <pthread.h>
    62.7 -#include <stdio.h>
    62.8 -#include <stdlib.h>
    62.9 -#include <string.h>
   62.10  #include <sys/types.h>
   62.11  #include <sys/stat.h>
   62.12  #include <stdarg.h>
   62.13 @@ -73,6 +70,9 @@
   62.14  #include <mach-o/nlist.h>
   62.15  #include <mach-o/getsect.h>
   62.16  
   62.17 +#include "SDL_stdlib.h"
   62.18 +#include "SDL_string.h"
   62.19 +
   62.20  /* Just playing to see if it would compile with the freebsd headers, it does,
   62.21   * but because of the different values for RTLD_LOCAL etc, it would break binary
   62.22   * compat... oh well
   62.23 @@ -390,14 +390,14 @@
   62.24  	}
   62.25  	if (!path)
   62.26  	{
   62.27 -		path = (char **)calloc(MAX_SEARCH_PATHS, sizeof(char **));
   62.28 +		path = (char **)SDL_calloc(MAX_SEARCH_PATHS, sizeof(char **));
   62.29  	}
   62.30  	if (!list && !end)
   62.31  		list = searchList();
   62.32  	if (i >= (numsize))
   62.33  	{
   62.34  		debug("Increasing size for long PATH");
   62.35 -		tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **));
   62.36 +		tmp = (char **)SDL_calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **));
   62.37  		if (tmp)
   62.38  		{
   62.39  			SDL_memcpy(tmp, path, sizeof(char **) * numsize);
   62.40 @@ -515,7 +515,7 @@
   62.41  		dls = dls->next;
   62.42  	if (!dls)
   62.43  #endif
   62.44 -		dls = calloc(sizeof(*dls),1);
   62.45 +		dls = SDL_calloc(sizeof(*dls),1);
   62.46  	return dls;
   62.47  }
   62.48  
   62.49 @@ -1017,7 +1017,7 @@
   62.50  	malloc_sym = SDL_malloc(sym_len + 2);
   62.51  	if (malloc_sym)
   62.52  	{
   62.53 -		sprintf(malloc_sym, "_%s", symbol);
   62.54 +		SDL_sprintf(malloc_sym, sym_len+2, "_%s", symbol);
   62.55  		value = dlsymIntern(handle, malloc_sym, 1);
   62.56  		SDL_free(malloc_sym);
   62.57  	}
   62.58 @@ -1062,7 +1062,7 @@
   62.59  	malloc_sym = SDL_malloc(sym_len + 2);
   62.60  	if (malloc_sym)
   62.61  	{
   62.62 -		sprintf(malloc_sym, "_%s", symbol);
   62.63 +		SDL_snprintf(malloc_sym, sym_len+2, "_%s", symbol);
   62.64  		value = dlsymIntern(handle, malloc_sym, 1);
   62.65  		SDL_free(malloc_sym);
   62.66  	}
   62.67 @@ -1347,7 +1347,7 @@
   62.68  	malloc_sym = SDL_malloc(sym_len + 2);
   62.69  	if (malloc_sym)
   62.70  	{
   62.71 -		sprintf(malloc_sym, "_%s", symbol);
   62.72 +		SDL_snprintf(malloc_sym, sym_len+2, "_%s", symbol);
   62.73  		rv.d = dlsymIntern(handle, malloc_sym, 1);
   62.74  		SDL_free(malloc_sym);
   62.75  	}
    63.1 --- a/src/main/beos/SDL_BeApp.cc	Tue Feb 07 07:03:29 2006 +0000
    63.2 +++ b/src/main/beos/SDL_BeApp.cc	Tue Feb 07 09:29:18 2006 +0000
    63.3 @@ -25,8 +25,6 @@
    63.4  #include <AppKit.h>
    63.5  #include <storage/Path.h>
    63.6  #include <storage/Entry.h>
    63.7 -#include <stdlib.h>
    63.8 -#include <string.h>
    63.9  #include <unistd.h>
   63.10  
   63.11  #include "SDL_BeApp.h"
    64.1 --- a/src/main/macos/SDL_main.c	Tue Feb 07 07:03:29 2006 +0000
    64.2 +++ b/src/main/macos/SDL_main.c	Tue Feb 07 09:29:18 2006 +0000
    64.3 @@ -589,7 +589,7 @@
    64.4  
    64.5      /* Parse C-string into argv and argc */
    64.6      nargs = ParseCommandLine (commandLine, NULL);
    64.7 -    args = (char **)SDL_malloc((nargs+1)*(sizeof *args));
    64.8 +    args = (char **)malloc((nargs+1)*(sizeof *args));
    64.9      if ( args == NULL ) {
   64.10  		exit(-1);
   64.11  	}
    65.1 --- a/src/stdlib/SDL_malloc.c	Tue Feb 07 07:03:29 2006 +0000
    65.2 +++ b/src/stdlib/SDL_malloc.c	Tue Feb 07 09:29:18 2006 +0000
    65.3 @@ -29,19 +29,14 @@
    65.4  #ifndef HAVE_MALLOC
    65.5  
    65.6  #define LACKS_STDIO_H
    65.7 -#define LACKS_UNISTD_H
    65.8 -#define LACKS_FCNTL_H
    65.9 -#define LACKS_SYS_PARAM_H
   65.10 -#define LACKS_SYS_MMAN_H
   65.11  #define LACKS_STRINGS_H
   65.12  #define LACKS_STRING_H
   65.13 -#define LACKS_SYS_TYPES_H
   65.14 -#define LACKS_ERRNO_H
   65.15  #define LACKS_STDLIB_H
   65.16  #define ABORT
   65.17  #define memset	SDL_memset
   65.18  #define memcpy	SDL_memcpy
   65.19  #define malloc	SDL_malloc
   65.20 +#define calloc	SDL_calloc
   65.21  #define realloc	SDL_realloc
   65.22  #define free	SDL_free
   65.23  
    66.1 --- a/src/stdlib/SDL_string.c	Tue Feb 07 07:03:29 2006 +0000
    66.2 +++ b/src/stdlib/SDL_string.c	Tue Feb 07 09:29:18 2006 +0000
    66.3 @@ -343,7 +343,8 @@
    66.4  {
    66.5      char *bufp = string;
    66.6      while ( *bufp ) {
    66.7 -        *bufp++ = toupper(*bufp);
    66.8 +        *bufp = toupper(*bufp);
    66.9 +	++bufp;
   66.10      }
   66.11      return string;
   66.12  }
   66.13 @@ -354,7 +355,8 @@
   66.14  {
   66.15      char *bufp = string;
   66.16      while ( *bufp ) {
   66.17 -        *bufp++ = tolower(*bufp);
   66.18 +        *bufp = tolower(*bufp);
   66.19 +	++bufp;
   66.20      }
   66.21      return string;
   66.22  }
   66.23 @@ -367,6 +369,7 @@
   66.24          if ( *string == c ) {
   66.25              return (char *)string;
   66.26          }
   66.27 +	++string;
   66.28      }
   66.29      return NULL;
   66.30  }
   66.31 @@ -380,6 +383,7 @@
   66.32          if ( *bufp == c ) {
   66.33              return (char *)bufp;
   66.34          }
   66.35 +	--bufp;
   66.36      }
   66.37      return NULL;
   66.38  }
   66.39 @@ -393,6 +397,7 @@
   66.40          if ( SDL_strncmp(haystack, needle, length) == 0 ) {
   66.41              return (char *)haystack;
   66.42          }
   66.43 +	++haystack;
   66.44      }
   66.45      return NULL;
   66.46  }
    67.1 --- a/src/thread/SDL_thread.c	Tue Feb 07 07:03:29 2006 +0000
    67.2 +++ b/src/thread/SDL_thread.c	Tue Feb 07 09:29:18 2006 +0000
    67.3 @@ -22,11 +22,11 @@
    67.4  
    67.5  /* System independent thread management routines for SDL */
    67.6  
    67.7 +#include "SDL_stdlib.h"
    67.8 +#include "SDL_string.h"
    67.9  #include "SDL_error.h"
   67.10  #include "SDL_mutex.h"
   67.11  #include "SDL_thread.h"
   67.12 -#include "SDL_stdlib.h"
   67.13 -#include "SDL_string.h"
   67.14  #include "SDL_thread_c.h"
   67.15  #include "SDL_systhread.h"
   67.16  
    68.1 --- a/src/thread/amigaos/SDL_systhread.c	Tue Feb 07 07:03:29 2006 +0000
    68.2 +++ b/src/thread/amigaos/SDL_systhread.c	Tue Feb 07 09:29:18 2006 +0000
    68.3 @@ -102,7 +102,7 @@
    68.4  	D(bug("Sending %lx to the new thread...\n",args));
    68.5  
    68.6  	if(args)
    68.7 -		sprintf(buffer,"%ld",args);
    68.8 +		SDL_snprintf(buffer, SDL_arraysize(buffer),"%ld",args);
    68.9  
   68.10  	#ifdef STORMC4_WOS
   68.11  	thread->handle=CreateTaskPPCTags(TASKATTR_CODE,	RunThread,
    69.1 --- a/src/thread/amigaos/SDL_systhread_c.h	Tue Feb 07 07:03:29 2006 +0000
    69.2 +++ b/src/thread/amigaos/SDL_systhread_c.h	Tue Feb 07 09:29:18 2006 +0000
    69.3 @@ -31,9 +31,6 @@
    69.4  #include <inline/exec.h>
    69.5  #endif
    69.6  
    69.7 -#include <stdio.h>
    69.8 -#include <stdlib.h>
    69.9 -#include <string.h>
   69.10  #include "mydebug.h"
   69.11  
   69.12  extern struct ExecBase *SysBase;
    70.1 --- a/src/thread/amigaos/SDL_thread.c	Tue Feb 07 07:03:29 2006 +0000
    70.2 +++ b/src/thread/amigaos/SDL_thread.c	Tue Feb 07 09:29:18 2006 +0000
    70.3 @@ -22,10 +22,8 @@
    70.4  
    70.5  /* System independent thread management routines for SDL */
    70.6  
    70.7 -#include <stdio.h>
    70.8 -#include <stdlib.h>
    70.9 -#include <string.h>
   70.10 -
   70.11 +#include "SDL_stdlib.h"
   70.12 +#include "SDL_string.h"
   70.13  #include "SDL_error.h"
   70.14  #include "SDL_mutex.h"
   70.15  #include "SDL_thread.h"
    71.1 --- a/src/thread/bsdi/SDL_syssem.c	Tue Feb 07 07:03:29 2006 +0000
    71.2 +++ b/src/thread/bsdi/SDL_syssem.c	Tue Feb 07 09:29:18 2006 +0000
    71.3 @@ -20,15 +20,13 @@
    71.4      slouken@libsdl.org
    71.5  */
    71.6  
    71.7 -#include <stdlib.h>
    71.8 +#include "SDL_stdlib.h"
    71.9  #include "SDL_error.h"
   71.10  #include "SDL_thread.h"
   71.11  #include "SDL_timer.h"
   71.12  
   71.13  #ifdef SDL_USE_PTHREADS
   71.14  
   71.15 -#include <stdio.h>
   71.16 -#include <stdlib.h>
   71.17  #include <unistd.h>			/* For getpid() */
   71.18  #include <pthread.h>
   71.19  
    72.1 --- a/src/thread/dc/SDL_syscond.c	Tue Feb 07 07:03:29 2006 +0000
    72.2 +++ b/src/thread/dc/SDL_syscond.c	Tue Feb 07 09:29:18 2006 +0000
    72.3 @@ -26,9 +26,7 @@
    72.4     implementation, written by Christopher Tate and Owen Smith.  Thanks!
    72.5   */
    72.6  
    72.7 -#include <stdio.h>
    72.8 -#include <stdlib.h>
    72.9 -
   72.10 +#include "SDL_stdlib.h"
   72.11  #include "SDL_error.h"
   72.12  #include "SDL_thread.h"
   72.13  
    73.1 --- a/src/thread/dc/SDL_sysmutex.c	Tue Feb 07 07:03:29 2006 +0000
    73.2 +++ b/src/thread/dc/SDL_sysmutex.c	Tue Feb 07 09:29:18 2006 +0000
    73.3 @@ -22,9 +22,7 @@
    73.4  
    73.5  /* An implementation of mutexes using semaphores */
    73.6  
    73.7 -#include <stdio.h>
    73.8 -#include <stdlib.h>
    73.9 -
   73.10 +#include "SDL_stdlib.h"
   73.11  #include "SDL_error.h"
   73.12  #include "SDL_thread.h"
   73.13  #include "SDL_systhread_c.h"
    74.1 --- a/src/thread/dc/SDL_syssem.c	Tue Feb 07 07:03:29 2006 +0000
    74.2 +++ b/src/thread/dc/SDL_syssem.c	Tue Feb 07 09:29:18 2006 +0000
    74.3 @@ -22,8 +22,6 @@
    74.4  
    74.5  /* An implementation of semaphores using mutexes and condition variables */
    74.6  
    74.7 -#include <stdlib.h>
    74.8 -
    74.9  #include "SDL_error.h"
   74.10  #include "SDL_timer.h"
   74.11  #include "SDL_thread.h"
    75.1 --- a/src/thread/epoc/SDL_sysmutex.cpp	Tue Feb 07 07:03:29 2006 +0000
    75.2 +++ b/src/thread/epoc/SDL_sysmutex.cpp	Tue Feb 07 09:29:18 2006 +0000
    75.3 @@ -29,9 +29,6 @@
    75.4  
    75.5  /* Mutex functions using the Win32 API */
    75.6  
    75.7 -//#include <stdio.h>
    75.8 -//#include <stdlib.h>
    75.9 -
   75.10  #include<e32std.h>
   75.11  
   75.12  #include "SDL_error.h"
    76.1 --- a/src/thread/epoc/SDL_syssem.cpp	Tue Feb 07 07:03:29 2006 +0000
    76.2 +++ b/src/thread/epoc/SDL_syssem.cpp	Tue Feb 07 09:29:18 2006 +0000
    76.3 @@ -28,8 +28,6 @@
    76.4  
    76.5  /* Semaphore functions using the Win32 API */
    76.6  
    76.7 -//#include <stdio.h>
    76.8 -//#include <stdlib.h>
    76.9  #include <e32std.h>
   76.10  
   76.11  #include "SDL_error.h"
    77.1 --- a/src/thread/epoc/SDL_systhread.cpp	Tue Feb 07 07:03:29 2006 +0000
    77.2 +++ b/src/thread/epoc/SDL_systhread.cpp	Tue Feb 07 09:29:18 2006 +0000
    77.3 @@ -28,10 +28,6 @@
    77.4  */
    77.5  
    77.6  
    77.7 -//#include <stdlib.h>
    77.8 -//#include <stdio.h>
    77.9 -
   77.10 -
   77.11  extern "C" {
   77.12  #undef NULL
   77.13  #include "SDL_error.h"
    78.1 --- a/src/thread/generic/SDL_syscond.c	Tue Feb 07 07:03:29 2006 +0000
    78.2 +++ b/src/thread/generic/SDL_syscond.c	Tue Feb 07 09:29:18 2006 +0000
    78.3 @@ -26,9 +26,9 @@
    78.4     implementation, written by Christopher Tate and Owen Smith.  Thanks!
    78.5   */
    78.6  
    78.7 +#include "SDL_stdlib.h"
    78.8  #include "SDL_error.h"
    78.9  #include "SDL_thread.h"
   78.10 -#include "SDL_stdlib.h"
   78.11  
   78.12  struct SDL_cond
   78.13  {
    79.1 --- a/src/thread/generic/SDL_sysmutex.c	Tue Feb 07 07:03:29 2006 +0000
    79.2 +++ b/src/thread/generic/SDL_sysmutex.c	Tue Feb 07 09:29:18 2006 +0000
    79.3 @@ -22,9 +22,9 @@
    79.4  
    79.5  /* An implementation of mutexes using semaphores */
    79.6  
    79.7 +#include "SDL_stdlib.h"
    79.8  #include "SDL_error.h"
    79.9  #include "SDL_thread.h"
   79.10 -#include "SDL_stdlib.h"
   79.11  #include "SDL_systhread_c.h"
   79.12  
   79.13  
    80.1 --- a/src/thread/generic/SDL_syssem.c	Tue Feb 07 07:03:29 2006 +0000
    80.2 +++ b/src/thread/generic/SDL_syssem.c	Tue Feb 07 09:29:18 2006 +0000
    80.3 @@ -22,10 +22,10 @@
    80.4  
    80.5  /* An implementation of semaphores using mutexes and condition variables */
    80.6  
    80.7 +#include "SDL_stdlib.h"
    80.8  #include "SDL_error.h"
    80.9  #include "SDL_timer.h"
   80.10  #include "SDL_thread.h"
   80.11 -#include "SDL_stdlib.h"
   80.12  #include "SDL_systhread_c.h"
   80.13  
   80.14  
    81.1 --- a/src/thread/irix/SDL_systhread.c	Tue Feb 07 07:03:29 2006 +0000
    81.2 +++ b/src/thread/irix/SDL_systhread.c	Tue Feb 07 09:29:18 2006 +0000
    81.3 @@ -22,7 +22,6 @@
    81.4  
    81.5  /* IRIX thread management routines for SDL */
    81.6  
    81.7 -#include <stdlib.h>
    81.8  #include <errno.h>
    81.9  #include <signal.h>
   81.10  #include <sys/types.h>
    82.1 --- a/src/thread/linux/SDL_syscond.c	Tue Feb 07 07:03:29 2006 +0000
    82.2 +++ b/src/thread/linux/SDL_syscond.c	Tue Feb 07 09:29:18 2006 +0000
    82.3 @@ -40,9 +40,9 @@
    82.4  #include <sys/time.h>
    82.5  #include <unistd.h>
    82.6  #include <errno.h>
    82.7 -#include <stdlib.h>
    82.8  #include <pthread.h>
    82.9  
   82.10 +#include "SDL_stdlib.h"
   82.11  #include "SDL_error.h"
   82.12  #include "SDL_thread.h"
   82.13  #include "SDL_sysmutex_c.h"
    83.1 --- a/src/thread/linux/SDL_sysmutex.c	Tue Feb 07 07:03:29 2006 +0000
    83.2 +++ b/src/thread/linux/SDL_sysmutex.c	Tue Feb 07 09:29:18 2006 +0000
    83.3 @@ -37,10 +37,9 @@
    83.4  
    83.5  #ifdef SDL_USE_PTHREADS
    83.6  
    83.7 -#include <stdlib.h>
    83.8 -#include <stdio.h>
    83.9  #include <pthread.h>
   83.10  
   83.11 +#include "SDL_stdlib.h"
   83.12  #include "SDL_error.h"
   83.13  #include "SDL_thread.h"
   83.14  
   83.15 @@ -59,7 +58,7 @@
   83.16  	pthread_mutexattr_t attr;
   83.17  
   83.18  	/* Allocate the structure */
   83.19 -	mutex = (SDL_mutex *)calloc(1, sizeof(*mutex));
   83.20 +	mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex));
   83.21  	if ( mutex ) {
   83.22  		pthread_mutexattr_init(&attr);
   83.23  #if defined(PTHREAD_RECURSIVE_MUTEX)
    84.1 --- a/src/thread/linux/SDL_syssem.c	Tue Feb 07 07:03:29 2006 +0000
    84.2 +++ b/src/thread/linux/SDL_syssem.c	Tue Feb 07 09:29:18 2006 +0000
    84.3 @@ -20,7 +20,7 @@
    84.4      slouken@libsdl.org
    84.5  */
    84.6  
    84.7 -#include <stdlib.h>
    84.8 +#include "SDL_stdlib.h"
    84.9  #include "SDL_error.h"
   84.10  #include "SDL_thread.h"
   84.11  #include "SDL_timer.h"
   84.12 @@ -46,9 +46,6 @@
   84.13  #include "generic/SDL_syssem.c"
   84.14  #else
   84.15  
   84.16 -#include <stdio.h>
   84.17 -#include <stdlib.h>
   84.18 -#include <unistd.h>			/* For getpid() */
   84.19  #include <pthread.h>
   84.20  #include <semaphore.h>
   84.21  
   84.22 @@ -74,7 +71,7 @@
   84.23  		static int semnum = 0;
   84.24  		char name[32];
   84.25  
   84.26 -		sprintf(name, "/SDL_sem-%d-%4.4d", getpid(), semnum++);
   84.27 +		SDL_snprintf(name, SDL_arraysize(name), "/SDL_sem-%d-%4.4d", getpid(), semnum++);
   84.28  		sem->sem = sem_open(name, O_CREAT, 0600, initial_value);
   84.29  		if ( sem->sem == (sem_t *)SEM_FAILED ) {
   84.30  			SDL_SetError("sem_open(%s) failed", name);
    85.1 --- a/src/thread/linux/SDL_systhread.c	Tue Feb 07 07:03:29 2006 +0000
    85.2 +++ b/src/thread/linux/SDL_systhread.c	Tue Feb 07 09:29:18 2006 +0000
    85.3 @@ -22,6 +22,7 @@
    85.4  
    85.5  /* Linux thread management routines for SDL */
    85.6  
    85.7 +#include "SDL_stdlib.h"
    85.8  #include "SDL_error.h"
    85.9  #include "SDL_thread.h"
   85.10  #include "SDL_systhread.h"
   85.11 @@ -138,7 +139,6 @@
   85.12  
   85.13  #else /* Linux-specific clone() based implementation */
   85.14  
   85.15 -#include <stdlib.h>
   85.16  #include <errno.h>
   85.17  #include <unistd.h>
   85.18  #include <sys/wait.h>
   85.19 @@ -227,7 +227,7 @@
   85.20  	*/
   85.21  	char command[1024];
   85.22  
   85.23 -	sprintf(command,
   85.24 +	SDL_snprintf(command, SDL_arraysize(command),
   85.25  		"ps ax|fgrep -v fgrep|fgrep -v '<zombie>'|fgrep %d >/dev/null",
   85.26  								thread->handle);
   85.27  	while ( system(command) == 0 )
    86.1 --- a/src/thread/os2/SDL_syscond.c	Tue Feb 07 07:03:29 2006 +0000
    86.2 +++ b/src/thread/os2/SDL_syscond.c	Tue Feb 07 09:29:18 2006 +0000
    86.3 @@ -26,9 +26,7 @@
    86.4     implementation, written by Christopher Tate and Owen Smith.  Thanks!
    86.5   */
    86.6  
    86.7 -#include <stdio.h>
    86.8 -#include <stdlib.h>
    86.9 -
   86.10 +#include "SDL_stdlib.h"
   86.11  #include "SDL_error.h"
   86.12  #include "SDL_thread.h"
   86.13  
    87.1 --- a/src/thread/os2/SDL_sysmutex.c	Tue Feb 07 07:03:29 2006 +0000
    87.2 +++ b/src/thread/os2/SDL_sysmutex.c	Tue Feb 07 09:29:18 2006 +0000
    87.3 @@ -22,12 +22,11 @@
    87.4  
    87.5  /* Mutex functions using the OS/2 API */
    87.6  
    87.7 -#include <stdio.h>
    87.8 -#include <stdlib.h>
    87.9  #define INCL_DOSERRORS
   87.10  #define INCL_DOSSEMAPHORES
   87.11  #include <os2.h>
   87.12  
   87.13 +#include "SDL_stdlib.h"
   87.14  #include "SDL_error.h"
   87.15  #include "SDL_mutex.h"
   87.16  
    88.1 --- a/src/thread/os2/SDL_syssem.c	Tue Feb 07 07:03:29 2006 +0000
    88.2 +++ b/src/thread/os2/SDL_syssem.c	Tue Feb 07 09:29:18 2006 +0000
    88.3 @@ -22,13 +22,12 @@
    88.4  
    88.5  /* Semaphore functions using the OS/2 API */
    88.6  
    88.7 -#include <stdio.h>
    88.8 -#include <stdlib.h>
    88.9  #define INCL_DOS
   88.10  #define INCL_DOSERRORS
   88.11  #define INCL_DOSSEMAPHORES
   88.12  #include <os2.h>
   88.13  
   88.14 +#include "SDL_stdlib.h"
   88.15  #include "SDL_error.h"
   88.16  #include "SDL_thread.h"
   88.17  #include "SDL_timer.h"
    89.1 --- a/src/thread/os2/SDL_systhread.c	Tue Feb 07 07:03:29 2006 +0000
    89.2 +++ b/src/thread/os2/SDL_systhread.c	Tue Feb 07 09:29:18 2006 +0000
    89.3 @@ -22,13 +22,12 @@
    89.4  
    89.5  /* OS/2 thread management routines for SDL */
    89.6  
    89.7 -#include <stdio.h>
    89.8 -#include <stdlib.h>
    89.9  #include <process.h>
   89.10  #define INCL_DOSERRORS
   89.11  #define INCL_DOSPROCESS
   89.12  #include <os2.h>
   89.13  
   89.14 +#include "SDL_stdlib.h"
   89.15  #include "SDL_error.h"
   89.16  #include "SDL_thread.h"
   89.17  #include "SDL_systhread.h"
    90.1 --- a/src/thread/pth/SDL_syscond.c	Tue Feb 07 07:03:29 2006 +0000
    90.2 +++ b/src/thread/pth/SDL_syscond.c	Tue Feb 07 09:29:18 2006 +0000
    90.3 @@ -4,10 +4,9 @@
    90.4   *	Patrice Mandin
    90.5   */
    90.6  
    90.7 -#include <stdio.h>
    90.8 -#include <stdlib.h>
    90.9  #include <pth.h>
   90.10  
   90.11 +#include "SDL_stdlib.h"
   90.12  #include "SDL_error.h"
   90.13  #include "SDL_thread.h"
   90.14  #include "SDL_syscond_c.h"
    91.1 --- a/src/thread/pth/SDL_sysmutex.c	Tue Feb 07 07:03:29 2006 +0000
    91.2 +++ b/src/thread/pth/SDL_sysmutex.c	Tue Feb 07 09:29:18 2006 +0000
    91.3 @@ -4,10 +4,9 @@
    91.4   *	Patrice Mandin
    91.5   */
    91.6  
    91.7 -#include <stdio.h>
    91.8 -#include <stdlib.h>
    91.9  #include <pth.h>
   91.10  
   91.11 +#include "SDL_stdlib.h"
   91.12  #include "SDL_error.h"
   91.13  #include "SDL_mutex.h"
   91.14  #include "SDL_sysmutex_c.h"
    92.1 --- a/src/thread/riscos/SDL_syscond.c	Tue Feb 07 07:03:29 2006 +0000
    92.2 +++ b/src/thread/riscos/SDL_syscond.c	Tue Feb 07 09:29:18 2006 +0000
    92.3 @@ -27,10 +27,9 @@
    92.4  #else
    92.5  #include <sys/time.h>
    92.6  #include <unistd.h>
    92.7 -#include <errno.h>
    92.8 -#include <stdlib.h>
    92.9  #include <pthread.h>
   92.10  
   92.11 +#include "SDL_stdlib.h"
   92.12  #include "SDL_error.h"
   92.13  #include "SDL_thread.h"
   92.14  #include "SDL_sysmutex_c.h"
    93.1 --- a/src/thread/riscos/SDL_sysmutex.c	Tue Feb 07 07:03:29 2006 +0000
    93.2 +++ b/src/thread/riscos/SDL_sysmutex.c	Tue Feb 07 09:29:18 2006 +0000
    93.3 @@ -26,10 +26,9 @@
    93.4  #include "../generic/SDL_sysmutex.c"
    93.5  #else
    93.6  
    93.7 -#include <stdlib.h>
    93.8 -#include <stdio.h>
    93.9  #include <pthread.h>
   93.10  
   93.11 +#include "SDL_stdlib.h"
   93.12  #include "SDL_error.h"
   93.13  #include "SDL_thread.h"
   93.14  
   93.15 @@ -47,7 +46,7 @@
   93.16  	pthread_mutexattr_t attr;
   93.17  
   93.18  	/* Allocate the structure */
   93.19 -	mutex = (SDL_mutex *)calloc(1, sizeof(*mutex));
   93.20 +	mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex));
   93.21  	if ( mutex ) {
   93.22  		pthread_mutexattr_init(&attr);
   93.23  #ifdef PTHREAD_NO_RECURSIVE_MUTEX
    94.1 --- a/src/thread/riscos/SDL_syssem.c	Tue Feb 07 07:03:29 2006 +0000
    94.2 +++ b/src/thread/riscos/SDL_syssem.c	Tue Feb 07 09:29:18 2006 +0000
    94.3 @@ -23,12 +23,10 @@
    94.4  /* RISC OS semiphores based on linux code */
    94.5  
    94.6  
    94.7 -#include <stdlib.h>
    94.8 -
    94.9 +#include "SDL_stdlib.h"
   94.10  #include "SDL_error.h"
   94.11  #include "SDL_timer.h"
   94.12  #include "SDL_thread.h"
   94.13 -
   94.14  #include "SDL_systhread_c.h"
   94.15  
   94.16  #ifdef DISABLE_THREADS
   94.17 @@ -76,8 +74,6 @@
   94.18  #else
   94.19  
   94.20  
   94.21 -#include <stdio.h>
   94.22 -#include <stdlib.h>
   94.23  #include <unistd.h>			/* For getpid() */
   94.24  #include <pthread.h>
   94.25  #include <semaphore.h>
    95.1 --- a/src/thread/win32/SDL_sysmutex.c	Tue Feb 07 07:03:29 2006 +0000
    95.2 +++ b/src/thread/win32/SDL_sysmutex.c	Tue Feb 07 09:29:18 2006 +0000
    95.3 @@ -24,9 +24,9 @@
    95.4  
    95.5  #include "SDL_windows.h"
    95.6  
    95.7 +#include "SDL_stdlib.h"
    95.8  #include "SDL_error.h"
    95.9  #include "SDL_mutex.h"
   95.10 -#include "SDL_stdlib.h"
   95.11  
   95.12  
   95.13  struct SDL_mutex {
    96.1 --- a/src/thread/win32/SDL_syssem.c	Tue Feb 07 07:03:29 2006 +0000
    96.2 +++ b/src/thread/win32/SDL_syssem.c	Tue Feb 07 09:29:18 2006 +0000
    96.3 @@ -24,9 +24,9 @@
    96.4  
    96.5  #include "SDL_windows.h"
    96.6  
    96.7 +#include "SDL_stdlib.h"
    96.8  #include "SDL_error.h"
    96.9  #include "SDL_thread.h"
   96.10 -#include "SDL_stdlib.h"
   96.11  #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
   96.12  #include "win_ce_semaphore.h"
   96.13  #endif
    97.1 --- a/src/thread/win32/SDL_systhread.c	Tue Feb 07 07:03:29 2006 +0000
    97.2 +++ b/src/thread/win32/SDL_systhread.c	Tue Feb 07 09:29:18 2006 +0000
    97.3 @@ -24,9 +24,9 @@
    97.4  
    97.5  #include "SDL_windows.h"
    97.6  
    97.7 +#include "SDL_stdlib.h"
    97.8  #include "SDL_error.h"
    97.9  #include "SDL_thread.h"
   97.10 -#include "SDL_stdlib.h"
   97.11  #include "SDL_systhread.h"
   97.12  
   97.13  typedef struct ThreadStartParms
    98.1 --- a/src/timer/SDL_timer.c	Tue Feb 07 07:03:29 2006 +0000
    98.2 +++ b/src/timer/SDL_timer.c	Tue Feb 07 09:29:18 2006 +0000
    98.3 @@ -20,9 +20,9 @@
    98.4      slouken@libsdl.org
    98.5  */
    98.6  
    98.7 +#include "SDL_stdlib.h"
    98.8  #include "SDL_error.h"
    98.9  #include "SDL_timer.h"
   98.10 -#include "SDL_stdlib.h"
   98.11  #include "SDL_timer_c.h"
   98.12  #include "SDL_mutex.h"
   98.13  #include "SDL_systimer.h"
    99.1 --- a/src/video/SDL_RLEaccel.c	Tue Feb 07 07:03:29 2006 +0000
    99.2 +++ b/src/video/SDL_RLEaccel.c	Tue Feb 07 09:29:18 2006 +0000
    99.3 @@ -86,10 +86,10 @@
    99.4   */
    99.5  
    99.6  #include "SDL_types.h"
    99.7 +#include "SDL_stdlib.h"
    99.8 +#include "SDL_string.h"
    99.9  #include "SDL_video.h"
   99.10  #include "SDL_error.h"
   99.11 -#include "SDL_stdlib.h"
   99.12 -#include "SDL_string.h"
   99.13  #include "SDL_sysvideo.h"
   99.14  #include "SDL_blit.h"
   99.15  #include "SDL_RLEaccel_c.h"
   100.1 --- a/src/video/SDL_blit_N.c	Tue Feb 07 07:03:29 2006 +0000
   100.2 +++ b/src/video/SDL_blit_N.c	Tue Feb 07 09:29:18 2006 +0000
   100.3 @@ -32,8 +32,7 @@
   100.4  #ifdef HAVE_ALTIVEC_H
   100.5  #include <altivec.h>
   100.6  #endif
   100.7 -#include <assert.h>
   100.8 -#include <stdlib.h>
   100.9 +#define assert(X)
  100.10  #ifdef MACOSX
  100.11  #include <sys/sysctl.h>
  100.12  static size_t GetL3CacheSize( void )
  100.13 @@ -235,7 +234,6 @@
  100.14  
  100.15          assert(width == 0);
  100.16  
  100.17 -
  100.18          /* do scalar until we can align... */
  100.19          ONE_PIXEL_BLEND((extrawidth), extrawidth);
  100.20  #undef ONE_PIXEL_BLEND
   101.1 --- a/src/video/SDL_cursor.c	Tue Feb 07 07:03:29 2006 +0000
   101.2 +++ b/src/video/SDL_cursor.c	Tue Feb 07 09:29:18 2006 +0000
   101.3 @@ -22,12 +22,12 @@
   101.4  
   101.5  /* General cursor handling code for SDL */
   101.6  
   101.7 +#include "SDL_stdlib.h"
   101.8 +#include "SDL_string.h"
   101.9  #include "SDL_mutex.h"
  101.10  #include "SDL_error.h"
  101.11  #include "SDL_video.h"
  101.12  #include "SDL_mouse.h"
  101.13 -#include "SDL_stdlib.h"
  101.14 -#include "SDL_string.h"
  101.15  #include "SDL_blit.h"
  101.16  #include "SDL_events_c.h"
  101.17  #include "SDL_sysvideo.h"
   102.1 --- a/src/video/SDL_gamma.c	Tue Feb 07 07:03:29 2006 +0000
   102.2 +++ b/src/video/SDL_gamma.c	Tue Feb 07 09:29:18 2006 +0000
   102.3 @@ -36,9 +36,9 @@
   102.4  #define log(x)		__ieee754_log(x)
   102.5  #endif
   102.6  
   102.7 -#include "SDL_error.h"
   102.8  #include "SDL_stdlib.h"
   102.9  #include "SDL_string.h"
  102.10 +#include "SDL_error.h"
  102.11  #include "SDL_sysvideo.h"
  102.12  
  102.13  
   103.1 --- a/src/video/SDL_pixels.c	Tue Feb 07 07:03:29 2006 +0000
   103.2 +++ b/src/video/SDL_pixels.c	Tue Feb 07 09:29:18 2006 +0000
   103.3 @@ -22,11 +22,11 @@
   103.4  
   103.5  /* General (mostly internal) pixel/color manipulation routines for SDL */
   103.6  
   103.7 +#include "SDL_stdlib.h"
   103.8 +#include "SDL_string.h"
   103.9  #include "SDL_error.h"
  103.10  #include "SDL_endian.h"
  103.11  #include "SDL_video.h"
  103.12 -#include "SDL_stdlib.h"
  103.13 -#include "SDL_string.h"
  103.14  #include "SDL_sysvideo.h"
  103.15  #include "SDL_blit.h"
  103.16  #include "SDL_pixels_c.h"
   104.1 --- a/src/video/SDL_surface.c	Tue Feb 07 07:03:29 2006 +0000
   104.2 +++ b/src/video/SDL_surface.c	Tue Feb 07 09:29:18 2006 +0000
   104.3 @@ -20,10 +20,10 @@
   104.4      slouken@libsdl.org
   104.5  */
   104.6  
   104.7 +#include "SDL_stdlib.h"
   104.8 +#include "SDL_string.h"
   104.9  #include "SDL_error.h"
  104.10  #include "SDL_video.h"
  104.11 -#include "SDL_stdlib.h"
  104.12 -#include "SDL_string.h"
  104.13  #include "SDL_sysvideo.h"
  104.14  #include "SDL_cursor_c.h"
  104.15  #include "SDL_blit.h"
   105.1 --- a/src/video/SDL_video.c	Tue Feb 07 07:03:29 2006 +0000
   105.2 +++ b/src/video/SDL_video.c	Tue Feb 07 09:29:18 2006 +0000
   105.3 @@ -23,12 +23,12 @@
   105.4  /* The high-level video driver subsystem */
   105.5  
   105.6  #include "SDL.h"
   105.7 +#include "SDL_stdlib.h"
   105.8 +#include "SDL_string.h"
   105.9  #include "SDL_error.h"
  105.10  #include "SDL_video.h"
  105.11  #include "SDL_events.h"
  105.12  #include "SDL_mutex.h"
  105.13 -#include "SDL_stdlib.h"
  105.14 -#include "SDL_string.h"
  105.15  #include "SDL_sysvideo.h"
  105.16  #include "SDL_sysevents.h"
  105.17  #include "SDL_blit.h"
   106.1 --- a/src/video/SDL_yuv.c	Tue Feb 07 07:03:29 2006 +0000
   106.2 +++ b/src/video/SDL_yuv.c	Tue Feb 07 09:29:18 2006 +0000
   106.3 @@ -22,9 +22,9 @@
   106.4  
   106.5  /* This is the implementation of the YUV video surface support */
   106.6  
   106.7 +#include "SDL_stdlib.h"
   106.8  #include "SDL_video.h"
   106.9  #include "SDL_error.h"
  106.10 -#include "SDL_stdlib.h"
  106.11  #include "SDL_sysvideo.h"
  106.12  #include "SDL_yuvfuncs.h"
  106.13  #include "SDL_yuv_sw_c.h"
   107.1 --- a/src/video/SDL_yuv_sw.c	Tue Feb 07 07:03:29 2006 +0000
   107.2 +++ b/src/video/SDL_yuv_sw.c	Tue Feb 07 09:29:18 2006 +0000
   107.3 @@ -82,11 +82,11 @@
   107.4   * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
   107.5   */
   107.6  
   107.7 +#include "SDL_stdlib.h"
   107.8 +#include "SDL_string.h"
   107.9  #include "SDL_error.h"
  107.10  #include "SDL_video.h"
  107.11  #include "SDL_cpuinfo.h"
  107.12 -#include "SDL_stdlib.h"
  107.13 -#include "SDL_string.h"
  107.14  #include "SDL_stretch_c.h"
  107.15  #include "SDL_yuvfuncs.h"
  107.16  #include "SDL_yuv_sw_c.h"
   108.1 --- a/src/video/Xext/Xv/Xv.c	Tue Feb 07 07:03:29 2006 +0000
   108.2 +++ b/src/video/Xext/Xv/Xv.c	Tue Feb 07 09:29:18 2006 +0000
   108.3 @@ -234,7 +234,7 @@
   108.4            SyncHandle();
   108.5  	  return(XvBadAlloc);
   108.6  	}
   108.7 -      (void)SDL_strncpy(name, u.string, size);
   108.8 +      (void)strncpy(name, u.string, size);
   108.9        name[size] = '\0';
  108.10        pa->name = name;
  108.11  
  108.12 @@ -386,7 +386,7 @@
  108.13            SyncHandle();
  108.14  	  return(XvBadAlloc);
  108.15        }
  108.16 -      SDL_strncpy(name, u.string, size);
  108.17 +      strncpy(name, u.string, size);
  108.18        name[size] = '\0';
  108.19        pe->name = name;
  108.20        pe++;
  108.21 @@ -902,7 +902,7 @@
  108.22  	      ret[i].id = Info.id;	      
  108.23  	      ret[i].type = Info.type;	      
  108.24  	      ret[i].byte_order = Info.byte_order;	      
  108.25 -	      SDL_memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16);
  108.26 +	      memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16);
  108.27  	      ret[i].bits_per_pixel = Info.bpp;	      
  108.28    	      ret[i].format = Info.format;	      
  108.29     	      ret[i].num_planes = Info.num_planes;	      
  108.30 @@ -919,7 +919,7 @@
  108.31      	      ret[i].vert_y_period = Info.vert_y_period;
  108.32      	      ret[i].vert_u_period = Info.vert_u_period;
  108.33      	      ret[i].vert_v_period = Info.vert_v_period;
  108.34 -	      SDL_memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32);
  108.35 +	      memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32);
  108.36      	      ret[i].scanline_order = Info.scanline_order;
  108.37  	      (*num)++;
  108.38  	  }
   109.1 --- a/src/video/Xext/Xxf86dga/XF86DGA.c	Tue Feb 07 07:03:29 2006 +0000
   109.2 +++ b/src/video/Xext/Xxf86dga/XF86DGA.c	Tue Feb 07 09:29:18 2006 +0000
   109.3 @@ -407,12 +407,12 @@
   109.4      MapPtr *old;
   109.5  
   109.6      old = mapList;
   109.7 -    mapList = SDL_realloc(mapList, sizeof(MapPtr) * (numMaps + 1));
   109.8 +    mapList = realloc(mapList, sizeof(MapPtr) * (numMaps + 1));
   109.9      if (!mapList) {
  109.10  	mapList = old;
  109.11  	return NULL;
  109.12      }
  109.13 -    mapList[numMaps] = SDL_malloc(sizeof(MapRec));
  109.14 +    mapList[numMaps] = malloc(sizeof(MapRec));
  109.15      if (!mapList[numMaps])
  109.16  	return NULL;
  109.17      return mapList[numMaps++];
  109.18 @@ -424,12 +424,12 @@
  109.19      ScrPtr *old;
  109.20  
  109.21      old = scrList;
  109.22 -    scrList = SDL_realloc(scrList, sizeof(ScrPtr) * (numScrs + 1));
  109.23 +    scrList = realloc(scrList, sizeof(ScrPtr) * (numScrs + 1));
  109.24      if (!scrList) {
  109.25  	scrList = old;
  109.26  	return NULL;
  109.27      }
  109.28 -    scrList[numScrs] = SDL_malloc(sizeof(ScrRec));
  109.29 +    scrList[numScrs] = malloc(sizeof(ScrRec));
  109.30      if (!scrList[numScrs])
  109.31  	return NULL;
  109.32      return scrList[numScrs++];
   110.1 --- a/src/video/aalib/SDL_aavideo.c	Tue Feb 07 07:03:29 2006 +0000
   110.2 +++ b/src/video/aalib/SDL_aavideo.c	Tue Feb 07 09:29:18 2006 +0000
   110.3 @@ -23,14 +23,13 @@
   110.4  /* AAlib based SDL video driver implementation.
   110.5  */
   110.6  
   110.7 -#include <stdlib.h>
   110.8 -#include <stdio.h>
   110.9 -#include <string.h>
  110.10  #include <unistd.h>
  110.11  #include <sys/stat.h>
  110.12  
  110.13  
  110.14  #include "SDL.h"
  110.15 +#include "SDL_stdlib.h"
  110.16 +#include "SDL_string.h"
  110.17  #include "SDL_error.h"
  110.18  #include "SDL_video.h"
  110.19  #include "SDL_mouse.h"
   111.1 --- a/src/video/ataricommon/SDL_atarievents.c	Tue Feb 07 07:03:29 2006 +0000
   111.2 +++ b/src/video/ataricommon/SDL_atarievents.c	Tue Feb 07 09:29:18 2006 +0000
   111.3 @@ -28,12 +28,11 @@
   111.4   *	This routines choose what the final event manager will be
   111.5   */
   111.6  
   111.7 -#include <stdlib.h>
   111.8 -#include <string.h>
   111.9 -
  111.10  #include <mint/cookie.h>
  111.11  
  111.12  #include "SDL.h"
  111.13 +#include "SDL_stdlib.h"
  111.14 +#include "SDL_string.h"
  111.15  #include "SDL_sysevents.h"
  111.16  #include "SDL_events_c.h"
  111.17  
   112.1 --- a/src/video/ataricommon/SDL_atarigl.c	Tue Feb 07 07:03:29 2006 +0000
   112.2 +++ b/src/video/ataricommon/SDL_atarigl.c	Tue Feb 07 09:29:18 2006 +0000
   112.3 @@ -24,15 +24,14 @@
   112.4  
   112.5  /*--- Includes ---*/
   112.6  
   112.7 -#include <stdio.h>
   112.8 -#include <stdlib.h>
   112.9 -#include <string.h>
  112.10  #ifdef HAVE_OPENGL
  112.11  #include <GL/osmesa.h>
  112.12  #endif
  112.13  
  112.14  #include <mint/osbind.h>
  112.15  
  112.16 +#include "SDL_stdlib.h"
  112.17 +#include "SDL_string.h"
  112.18  #include "SDL_video.h"
  112.19  #include "SDL_error.h"
  112.20  #include "SDL_endian.h"
   113.1 --- a/src/video/ataricommon/SDL_xbiosevents.c	Tue Feb 07 07:03:29 2006 +0000
   113.2 +++ b/src/video/ataricommon/SDL_xbiosevents.c	Tue Feb 07 09:29:18 2006 +0000
   113.3 @@ -26,10 +26,6 @@
   113.4   *	Patrice Mandin
   113.5   */
   113.6  
   113.7 -#include <stdio.h>
   113.8 -#include <stdlib.h>
   113.9 -#include <string.h>
  113.10 -
  113.11  #include <mint/osbind.h>
  113.12  
  113.13  #include "SDL_events_c.h"
   114.1 --- a/src/video/bwindow/SDL_sysmouse.cc	Tue Feb 07 07:03:29 2006 +0000
   114.2 +++ b/src/video/bwindow/SDL_sysmouse.cc	Tue Feb 07 09:29:18 2006 +0000
   114.3 @@ -20,12 +20,11 @@
   114.4      slouken@libsdl.org
   114.5  */
   114.6  
   114.7 -#include <stdlib.h>
   114.8 -#include <string.h>
   114.9 -
  114.10  #include <AppKit.h>
  114.11  #include <GameKit.h>
  114.12  
  114.13 +#include "SDL_stdlib.h"
  114.14 +#include "SDL_string.h"
  114.15  #include "SDL_error.h"
  114.16  #include "SDL_BWin.h"
  114.17  
   115.1 --- a/src/video/bwindow/SDL_sysvideo.cc	Tue Feb 07 07:03:29 2006 +0000
   115.2 +++ b/src/video/bwindow/SDL_sysvideo.cc	Tue Feb 07 09:29:18 2006 +0000
   115.3 @@ -22,13 +22,11 @@
   115.4  
   115.5  /* BWindow based framebuffer implementation */
   115.6  
   115.7 -#include <stdlib.h>
   115.8 -#include <string.h>
   115.9 -
  115.10 -#include <stdio.h>
  115.11  #include <unistd.h>
  115.12  
  115.13  #include "SDL.h"
  115.14 +#include "SDL_stdlib.h"
  115.15 +#include "SDL_string.h"
  115.16  #include "SDL_BeApp.h"
  115.17  #include "SDL_BWin.h"
  115.18  #include "SDL_timer.h"
  115.19 @@ -291,7 +289,7 @@
  115.20  
  115.21  	/* Get the video modes we can switch to in fullscreen mode */
  115.22  	bscreen.GetModeList(&modes, &nmodes);
  115.23 -	qsort(modes, nmodes, sizeof *modes, CompareModes);
  115.24 +	SDL_qsort(modes, nmodes, sizeof *modes, CompareModes);
  115.25  	for ( i=0; i<nmodes; ++i ) {
  115.26  		bpp = ColorSpaceToBitsPerPixel(modes[i].space);
  115.27  		//if ( bpp != 0 ) { // There are bugs in changing colorspace
   116.1 --- a/src/video/bwindow/SDL_sysyuv.cc	Tue Feb 07 07:03:29 2006 +0000
   116.2 +++ b/src/video/bwindow/SDL_sysyuv.cc	Tue Feb 07 09:29:18 2006 +0000
   116.3 @@ -22,10 +22,7 @@
   116.4  
   116.5  /* This is the BeOS version of SDL YUV video overlays */
   116.6  
   116.7 -#include <stdlib.h>
   116.8 -#include <string.h>
   116.9 -#include <errno.h>
  116.10 -
  116.11 +#include "SDL_stdlib.h"
  116.12  #include "SDL_error.h"
  116.13  #include "SDL_video.h"
  116.14  #include "SDL_sysyuv.h"
  116.15 @@ -158,7 +155,7 @@
  116.16  	}
  116.17  
  116.18      /* Create the overlay structure */
  116.19 -    overlay = (SDL_Overlay*)calloc(1, sizeof(SDL_Overlay));
  116.20 +    overlay = (SDL_Overlay*)SDL_calloc(1, sizeof(SDL_Overlay));
  116.21  
  116.22      if (overlay == NULL)
  116.23      {
  116.24 @@ -176,7 +173,7 @@
  116.25      overlay->hwfuncs = &be_yuvfuncs;
  116.26  
  116.27      /* Create the pixel data and lookup tables */
  116.28 -    hwdata = (struct private_yuvhwdata*)calloc(1, sizeof(struct private_yuvhwdata));
  116.29 +    hwdata = (struct private_yuvhwdata*)SDL_calloc(1, sizeof(struct private_yuvhwdata));
  116.30  
  116.31      if (hwdata == NULL)
  116.32      {
  116.33 @@ -215,8 +212,8 @@
  116.34  	overlay->hwdata->bbitmap = bbitmap;
  116.35  	
  116.36  	overlay->planes = planes;
  116.37 -	overlay->pitches = (Uint16*)calloc(overlay->planes, sizeof(Uint16));
  116.38 -	overlay->pixels  = (Uint8**)calloc(overlay->planes, sizeof(Uint8*));
  116.39 +	overlay->pitches = (Uint16*)SDL_calloc(overlay->planes, sizeof(Uint16));
  116.40 +	overlay->pixels  = (Uint8**)SDL_calloc(overlay->planes, sizeof(Uint8*));
  116.41  	if (!overlay->pitches || !overlay->pixels)
  116.42  	{
  116.43          SDL_OutOfMemory();
   117.1 --- a/src/video/cybergfx/SDL_cgximage.c	Tue Feb 07 07:03:29 2006 +0000
   117.2 +++ b/src/video/cybergfx/SDL_cgximage.c	Tue Feb 07 09:29:18 2006 +0000
   117.3 @@ -20,8 +20,8 @@
   117.4      slouken@libsdl.org
   117.5  */
   117.6  
   117.7 -#include <stdlib.h>
   117.8 -
   117.9 +#include "SDL_stdlib.h"
  117.10 +#include "SDL_string.h"
  117.11  #include "SDL_error.h"
  117.12  #include "SDL_endian.h"
  117.13  #include "SDL_cgximage_c.h"
   118.1 --- a/src/video/cybergfx/SDL_cgxmodes.c	Tue Feb 07 07:03:29 2006 +0000
   118.2 +++ b/src/video/cybergfx/SDL_cgxmodes.c	Tue Feb 07 09:29:18 2006 +0000
   118.3 @@ -22,11 +22,6 @@
   118.4  
   118.5  /* Utilities for getting and setting the X display mode */
   118.6  
   118.7 -/*
   118.8 -#include <stdlib.h>
   118.9 -#include <string.h>
  118.10 -*/
  118.11 -
  118.12  #include "SDL_timer.h"
  118.13  #include "SDL_error.h"
  118.14  #include "SDL_events.h"
   119.1 --- a/src/video/cybergfx/SDL_cgxvideo.c	Tue Feb 07 07:03:29 2006 +0000
   119.2 +++ b/src/video/cybergfx/SDL_cgxvideo.c	Tue Feb 07 09:29:18 2006 +0000
   119.3 @@ -25,18 +25,6 @@
   119.4   * gabriele.greco@aruba.it
   119.5   */
   119.6  
   119.7 -/*
   119.8 -#include <stdlib.h>
   119.9 -#include <stdio.h>
  119.10 -#include <unistd.h>
  119.11 -#include <string.h>
  119.12 -#include <sys/ioctl.h>
  119.13 -#ifdef MTRR_SUPPORT
  119.14 -#include <asm/mtrr.h>
  119.15 -#include <sys/fcntl.h>
  119.16 -#endif
  119.17 -*/
  119.18 -
  119.19  #include "SDL.h"
  119.20  #include "SDL_error.h"
  119.21  #include "SDL_timer.h"
   120.1 --- a/src/video/cybergfx/SDL_cgxvideo.h	Tue Feb 07 07:03:29 2006 +0000
   120.2 +++ b/src/video/cybergfx/SDL_cgxvideo.h	Tue Feb 07 09:29:18 2006 +0000
   120.3 @@ -24,10 +24,6 @@
   120.4  #define _SDL_cgxvideo_h
   120.5  
   120.6  
   120.7 -#include <stdio.h>
   120.8 -#include <stdlib.h>
   120.9 -#include <string.h>
  120.10 -
  120.11  #include <exec/exec.h>
  120.12  #include <cybergraphx/cybergraphics.h>
  120.13  #include <graphics/scale.h>
  120.14 @@ -47,9 +43,11 @@
  120.15  #include <inline/console.h>
  120.16  #endif
  120.17  
  120.18 -#include "mydebug.h"
  120.19 +#include "SDL_stdlib.h"
  120.20 +#include "SDL_string.h"
  120.21  #include "SDL_mouse.h"
  120.22  #include "SDL_sysvideo.h"
  120.23 +#include "mydebug.h"
  120.24  
  120.25  #define USE_CGX_WRITELUTPIXEL
  120.26  
   121.1 --- a/src/video/cybergfx/SDL_cgxyuv.c	Tue Feb 07 07:03:29 2006 +0000
   121.2 +++ b/src/video/cybergfx/SDL_cgxyuv.c	Tue Feb 07 09:29:18 2006 +0000
   121.3 @@ -24,14 +24,14 @@
   121.4  
   121.5  #ifdef XFREE86_XV
   121.6  
   121.7 -#include <stdlib.h>
   121.8 -#include <string.h>
   121.9  #include <X11/Xlib.h>
  121.10  #include <sys/ipc.h>
  121.11  #include <sys/shm.h>
  121.12  #include <X11/extensions/XShm.h>
  121.13  #include <X11/extensions/Xvlib.h>
  121.14  
  121.15 +#include "SDL_stdlib.h"
  121.16 +#include "SDL_string.h"
  121.17  #include "SDL_error.h"
  121.18  #include "SDL_video.h"
  121.19  #include "SDL_x11yuv_c.h"
   122.1 --- a/src/video/dc/SDL_dcvideo.c	Tue Feb 07 07:03:29 2006 +0000
   122.2 +++ b/src/video/dc/SDL_dcvideo.c	Tue Feb 07 09:29:18 2006 +0000
   122.3 @@ -20,11 +20,9 @@
   122.4      slouken@libsdl.org
   122.5  */
   122.6  
   122.7 -#include <stdio.h>
   122.8 -#include <stdlib.h>
   122.9 -#include <string.h>
  122.10 -
  122.11  #include "SDL.h"
  122.12 +#include "SDL_stdlib.h"
  122.13 +#include "SDL_string.h"
  122.14  #include "SDL_error.h"
  122.15  #include "SDL_video.h"
  122.16  #include "SDL_mouse.h"
   123.1 --- a/src/video/dga/SDL_dgavideo.c	Tue Feb 07 07:03:29 2006 +0000
   123.2 +++ b/src/video/dga/SDL_dgavideo.c	Tue Feb 07 09:29:18 2006 +0000
   123.3 @@ -23,16 +23,14 @@
   123.4  /* DGA 2.0 based SDL video driver implementation.
   123.5  */
   123.6  
   123.7 -#include <stdlib.h>
   123.8 -#include <string.h>
   123.9 +#include <stdio.h>
  123.10 +
  123.11  #include <X11/Xlib.h>
  123.12  #include <Xext/extensions/xf86dga.h>
  123.13  
  123.14 -#ifdef HAVE_ALLOCA_H
  123.15 -#include <alloca.h>
  123.16 -#endif
  123.17 -
  123.18  #include "SDL.h"
  123.19 +#include "SDL_stdlib.h"
  123.20 +#include "SDL_string.h"
  123.21  #include "SDL_error.h"
  123.22  #include "SDL_video.h"
  123.23  #include "SDL_mouse.h"
  123.24 @@ -390,7 +388,7 @@
  123.25  
  123.26  	/* Query for the list of available video modes */
  123.27  	modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes);
  123.28 -	qsort(modes, num_modes, sizeof *modes, cmpmodes);
  123.29 +	SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
  123.30  	for ( i=0; i<num_modes; ++i ) {
  123.31  #ifdef DGA_DEBUG
  123.32  		PrintMode(&modes[i]);
  123.33 @@ -449,7 +447,7 @@
  123.34  
  123.35  	/* Search for a matching video mode */
  123.36  	modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes);
  123.37 -	qsort(modes, num_modes, sizeof *modes, cmpmodes);
  123.38 +	SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
  123.39  	for ( i=0; i<num_modes; ++i ) {
  123.40  		int depth;
  123.41  
  123.42 @@ -968,7 +966,7 @@
  123.43  	if ( ! DGA_colormap ) {
  123.44  		return(0);
  123.45  	}
  123.46 -	xcmap = (XColor *)alloca(ncolors*sizeof(*xcmap));
  123.47 +	xcmap = SDL_stack_alloc(XColor, ncolors);
  123.48  	for ( i=0; i<ncolors; ++i ) {
  123.49  		xcmap[i].pixel = firstcolor + i;
  123.50  		xcmap[i].red   = (colors[i].r<<8)|colors[i].r;
  123.51 @@ -980,6 +978,7 @@
  123.52  	pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
  123.53  	pXSync(DGA_Display, False);
  123.54  	UNLOCK_DISPLAY();
  123.55 +	SDL_stack_free(xcmap);
  123.56  
  123.57  	/* That was easy. :) */
  123.58  	return(1);
   124.1 --- a/src/video/directfb/SDL_DirectFB_events.c	Tue Feb 07 07:03:29 2006 +0000
   124.2 +++ b/src/video/directfb/SDL_DirectFB_events.c	Tue Feb 07 09:29:18 2006 +0000
   124.3 @@ -24,8 +24,6 @@
   124.4  
   124.5  #include <sys/types.h>
   124.6  #include <sys/time.h>
   124.7 -#include <stdlib.h>
   124.8 -#include <stdio.h>
   124.9  #include <unistd.h>
  124.10  #include <fcntl.h>
  124.11  #include <termios.h>
   125.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Tue Feb 07 07:03:29 2006 +0000
   125.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Tue Feb 07 09:29:18 2006 +0000
   125.3 @@ -27,9 +27,6 @@
   125.4  /* DirectFB video driver implementation.
   125.5  */
   125.6  
   125.7 -#include <stdlib.h>
   125.8 -#include <string.h>
   125.9 -#include <stdio.h>
  125.10  #include <fcntl.h>
  125.11  #include <unistd.h>
  125.12  #include <sys/mman.h>
  125.13 @@ -38,6 +35,8 @@
  125.14  #include <directfb_version.h>
  125.15  
  125.16  #include "SDL.h"
  125.17 +#include "SDL_stdlib.h"
  125.18 +#include "SDL_string.h"
  125.19  #include "SDL_error.h"
  125.20  #include "SDL_video.h"
  125.21  #include "SDL_mouse.h"
  125.22 @@ -110,7 +109,7 @@
  125.23    device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
  125.24    if (device)
  125.25      {
  125.26 -      memset (device, 0, (sizeof *device));
  125.27 +      SDL_memset (device, 0, (sizeof *device));
  125.28        device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden));
  125.29      }
  125.30    if (device == NULL  ||  device->hidden == NULL)
  125.31 @@ -122,7 +121,7 @@
  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 = DirectFB_VideoInit;
  125.40 @@ -195,7 +194,7 @@
  125.41  
  125.42    HIDDEN->nummodes++;
  125.43  
  125.44 -  enumrect = calloc(1, sizeof(struct DirectFBEnumRect));
  125.45 +  enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect));
  125.46    if (!enumrect)
  125.47      {
  125.48        SDL_OutOfMemory();
  125.49 @@ -294,14 +293,14 @@
  125.50    SDL_Palette *palette;
  125.51    SDL_Color   *colors;
  125.52  
  125.53 -  palette = calloc (1, sizeof(SDL_Palette));
  125.54 +  palette = SDL_calloc (1, sizeof(SDL_Palette));
  125.55    if (!palette)
  125.56      {
  125.57        SDL_OutOfMemory();
  125.58        return NULL;
  125.59      }
  125.60  
  125.61 -  colors = calloc (size, sizeof(SDL_Color));
  125.62 +  colors = SDL_calloc (size, sizeof(SDL_Color));
  125.63    if (!colors)
  125.64      {
  125.65        SDL_OutOfMemory();
  125.66 @@ -432,7 +431,7 @@
  125.67        goto error;
  125.68      }
  125.69  
  125.70 -  HIDDEN->modelist = calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
  125.71 +  HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
  125.72    if (!HIDDEN->modelist)
  125.73      {
  125.74        SDL_OutOfMemory();
  125.75 @@ -614,7 +613,7 @@
  125.76    else if (!current->hwdata)
  125.77      {
  125.78        /* Allocate the hardware acceleration data */
  125.79 -      current->hwdata = (struct private_hwdata *) calloc (1, sizeof(*current->hwdata));
  125.80 +      current->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*current->hwdata));
  125.81        if (!current->hwdata)
  125.82          {
  125.83            SDL_OutOfMemory();
  125.84 @@ -821,7 +820,7 @@
  125.85      return -1;
  125.86  
  125.87    /* Allocate the hardware acceleration data */
  125.88 -  surface->hwdata = (struct private_hwdata *) calloc (1, sizeof(*surface->hwdata));
  125.89 +  surface->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*surface->hwdata));
  125.90    if (surface->hwdata == NULL)
  125.91      {
  125.92        SDL_OutOfMemory();
   126.1 --- a/src/video/directfb/SDL_DirectFB_yuv.c	Tue Feb 07 07:03:29 2006 +0000
   126.2 +++ b/src/video/directfb/SDL_DirectFB_yuv.c	Tue Feb 07 09:29:18 2006 +0000
   126.3 @@ -22,9 +22,7 @@
   126.4  
   126.5  /* This is the DirectFB implementation of YUV video overlays */
   126.6  
   126.7 -#include <stdlib.h>
   126.8 -#include <string.h>
   126.9 -
  126.10 +#include "SDL_stdlib.h"
  126.11  #include "SDL_error.h"
  126.12  #include "SDL_video.h"
  126.13  #include "SDL_DirectFB_yuv.h"
  126.14 @@ -148,7 +146,7 @@
  126.15    struct private_yuvhwdata *hwdata;
  126.16  
  126.17    /* Create the overlay structure */
  126.18 -  overlay = calloc (1, sizeof(SDL_Overlay));
  126.19 +  overlay = SDL_calloc (1, sizeof(SDL_Overlay));
  126.20    if (!overlay)
  126.21      {
  126.22        SDL_OutOfMemory();
  126.23 @@ -164,7 +162,7 @@
  126.24    overlay->hwfuncs = &directfb_yuvfuncs;
  126.25  
  126.26    /* Create the pixel data and lookup tables */
  126.27 -  hwdata = calloc(1, sizeof(struct private_yuvhwdata));
  126.28 +  hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata));
  126.29    overlay->hwdata = hwdata;
  126.30    if (!hwdata)
  126.31      {
   127.1 --- a/src/video/dummy/SDL_nullvideo.c	Tue Feb 07 07:03:29 2006 +0000
   127.2 +++ b/src/video/dummy/SDL_nullvideo.c	Tue Feb 07 09:29:18 2006 +0000
   127.3 @@ -35,11 +35,9 @@
   127.4   *  SDL video driver.  Renamed to "DUMMY" by Sam Lantinga.
   127.5   */
   127.6  
   127.7 -#include <stdio.h>
   127.8 -#include <stdlib.h>
   127.9 -#include <string.h>
  127.10 -
  127.11  #include "SDL.h"
  127.12 +#include "SDL_stdlib.h"
  127.13 +#include "SDL_string.h"
  127.14  #include "SDL_error.h"
  127.15  #include "SDL_video.h"
  127.16  #include "SDL_mouse.h"
  127.17 @@ -145,7 +143,9 @@
  127.18  
  127.19  int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat)
  127.20  {
  127.21 +	/*
  127.22  	fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n");
  127.23 +	*/
  127.24  
  127.25  	/* Determine the screen depth (use default 8-bit depth) */
  127.26  	/* we change this during the SDL_SetVideoMode implementation... */
   128.1 --- a/src/video/epoc/SDL_epocvideo.cpp	Tue Feb 07 07:03:29 2006 +0000
   128.2 +++ b/src/video/epoc/SDL_epocvideo.cpp	Tue Feb 07 09:29:18 2006 +0000
   128.3 @@ -29,11 +29,9 @@
   128.4  
   128.5  
   128.6  
   128.7 -#include <stdlib.h>
   128.8 -#include <stdio.h>
   128.9 -#include <string.h>
  128.10 -
  128.11  extern "C" {
  128.12 +#include "SDL_stdlib.h"
  128.13 +#include "SDL_string.h"
  128.14  #include "SDL_error.h"
  128.15  #include "SDL_timer.h"
  128.16  #include "SDL_video.h"
   129.1 --- a/src/video/fbcon/SDL_fbelo.c	Tue Feb 07 07:03:29 2006 +0000
   129.2 +++ b/src/video/fbcon/SDL_fbelo.c	Tue Feb 07 09:29:18 2006 +0000
   129.3 @@ -20,12 +20,12 @@
   129.4      slouken@libsdl.org
   129.5  */
   129.6  
   129.7 -#include <stdlib.h>
   129.8  #include <unistd.h>
   129.9  #include <sys/time.h>
  129.10  #include <ctype.h>
  129.11 -#include <string.h>
  129.12  
  129.13 +#include "SDL_stdlib.h"
  129.14 +#include "SDL_string.h"
  129.15  #include "SDL_fbvideo.h"
  129.16  #include "SDL_fbelo.h"
  129.17  
   130.1 --- a/src/video/fbcon/SDL_fbevents.c	Tue Feb 07 07:03:29 2006 +0000
   130.2 +++ b/src/video/fbcon/SDL_fbevents.c	Tue Feb 07 09:29:18 2006 +0000
   130.3 @@ -22,14 +22,12 @@
   130.4  
   130.5  /* Handle the event stream, converting console events into SDL events */
   130.6  
   130.7 +#include <stdio.h>
   130.8  #include <sys/types.h>
   130.9  #include <sys/time.h>
  130.10  #include <sys/ioctl.h>
  130.11 -#include <stdlib.h>
  130.12 -#include <stdio.h>
  130.13  #include <unistd.h>
  130.14  #include <fcntl.h>
  130.15 -#include <string.h>
  130.16  #include <errno.h>
  130.17  #include <limits.h>
  130.18  
  130.19 @@ -42,6 +40,8 @@
  130.20  #include <linux/keyboard.h>
  130.21  
  130.22  #include "SDL.h"
  130.23 +#include "SDL_stdlib.h"
  130.24 +#include "SDL_string.h"
  130.25  #include "SDL_mutex.h"
  130.26  #include "SDL_sysevents.h"
  130.27  #include "SDL_sysvideo.h"
  130.28 @@ -260,7 +260,7 @@
  130.29  			for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) {
  130.30  				char vtpath[12];
  130.31  
  130.32 -				sprintf(vtpath, vcs[i], current_vt);
  130.33 +				SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], current_vt);
  130.34  				keyboard_fd = open(vtpath, O_RDWR, 0);
  130.35  #ifdef DEBUG_KEYBOARD
  130.36  				fprintf(stderr, "vtpath = %s, fd = %d\n",
  130.37 @@ -345,7 +345,7 @@
  130.38  			char path[PATH_MAX];
  130.39  			char name[PATH_MAX];
  130.40  
  130.41 -			sprintf(path, "/proc/%s/status", entry->d_name);
  130.42 +			SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", entry->d_name);
  130.43  			status=fopen(path, "r");
  130.44  			if ( status ) {
  130.45  				name[0] = '\0';
  130.46 @@ -379,7 +379,7 @@
  130.47  	proc = opendir("/proc");
  130.48  	if ( proc ) {
  130.49  		while ( (pid=find_pid(proc, "gpm")) > 0 ) {
  130.50 -			sprintf(path, "/proc/%d/cmdline", pid);
  130.51 +			SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid);
  130.52  			cmdline = open(path, O_RDONLY, 0);
  130.53  			if ( cmdline >= 0 ) {
  130.54  				len = read(cmdline, args, sizeof(args));
   131.1 --- a/src/video/fbcon/SDL_fbvideo.c	Tue Feb 07 07:03:29 2006 +0000
   131.2 +++ b/src/video/fbcon/SDL_fbvideo.c	Tue Feb 07 09:29:18 2006 +0000
   131.3 @@ -23,16 +23,17 @@
   131.4  /* Framebuffer console based SDL video driver implementation.
   131.5  */
   131.6  
   131.7 -#include <stdlib.h>
   131.8  #include <stdio.h>
   131.9 -#include <string.h>
  131.10  #include <fcntl.h>
  131.11  #include <unistd.h>
  131.12  #include <sys/ioctl.h>
  131.13  #include <sys/mman.h>
  131.14  #include <asm/page.h>		/* For definition of PAGE_SIZE */
  131.15 +#include <sys/io.h>		/* For ioperm() */
  131.16  
  131.17  #include "SDL.h"
  131.18 +#include "SDL_stdlib.h"
  131.19 +#include "SDL_string.h"
  131.20  #include "SDL_error.h"
  131.21  #include "SDL_video.h"
  131.22  #include "SDL_mouse.h"
  131.23 @@ -53,10 +54,12 @@
  131.24  #ifndef FB_AUX_VGA_PLANES_VGA4
  131.25  #define FB_AUX_VGA_PLANES_VGA4	0
  131.26  #endif
  131.27 +/*
  131.28  static inline void outb (unsigned char value, unsigned short port)
  131.29  {
  131.30    __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port));
  131.31  } 
  131.32 +*/
  131.33  #endif /* FB_TYPE_VGA_PLANES */
  131.34  
  131.35  /* A list of video resolutions that we query for (sorted largest to smallest) */
  131.36 @@ -438,7 +441,7 @@
  131.37  	int i;
  131.38  	for ( i=0; i<NUM_MODELISTS; ++i ) {
  131.39  		if ( SDL_nummodes[i] > 0 ) {
  131.40 -			qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes);
  131.41 +			SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes);
  131.42  		}
  131.43  	}
  131.44  }
   132.1 --- a/src/video/gapi/SDL_gapivideo.c	Tue Feb 07 07:03:29 2006 +0000
   132.2 +++ b/src/video/gapi/SDL_gapivideo.c	Tue Feb 07 09:29:18 2006 +0000
   132.3 @@ -32,11 +32,8 @@
   132.4  // TODO: windib on SH3 PPC2000 landscape test
   132.5  // TODO: optimize 8bpp landscape mode
   132.6  
   132.7 -#include <stdio.h>
   132.8 -#include <stdlib.h>
   132.9 -#include <string.h>
  132.10 -
  132.11  #include "SDL.h"
  132.12 +#include "SDL_stdlib.h"
  132.13  #include "SDL_error.h"
  132.14  #include "SDL_video.h"
  132.15  #include "SDL_mouse.h"
  132.16 @@ -479,7 +476,7 @@
  132.17  	/* Sort the mode lists */
  132.18  	for ( i=0; i<NUM_MODELISTS; ++i ) {
  132.19  		if ( gapi->SDL_nummodes[i] > 0 ) {
  132.20 -			qsort(gapi->SDL_modelist[i], gapi->SDL_nummodes[i], sizeof *gapi->SDL_modelist[i], cmpmodes);
  132.21 +			SDL_qsort(gapi->SDL_modelist[i], gapi->SDL_nummodes[i], sizeof *gapi->SDL_modelist[i], cmpmodes);
  132.22  		}
  132.23  	}
  132.24  
   133.1 --- a/src/video/gem/SDL_gemmouse.c	Tue Feb 07 07:03:29 2006 +0000
   133.2 +++ b/src/video/gem/SDL_gemmouse.c	Tue Feb 07 09:29:18 2006 +0000
   133.3 @@ -26,10 +26,9 @@
   133.4   *	Patrice Mandin
   133.5   */
   133.6  
   133.7 -#include <stdlib.h>
   133.8 -
   133.9  #include <gem.h>
  133.10  
  133.11 +#include "SDL_stdlib.h"
  133.12  #include "SDL_error.h"
  133.13  #include "SDL_mouse.h"
  133.14  #include "SDL_events_c.h"
   134.1 --- a/src/video/gem/SDL_gemvideo.c	Tue Feb 07 07:03:29 2006 +0000
   134.2 +++ b/src/video/gem/SDL_gemvideo.c	Tue Feb 07 09:29:18 2006 +0000
   134.3 @@ -28,10 +28,6 @@
   134.4  	Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
   134.5  */
   134.6  
   134.7 -#include <stdio.h>
   134.8 -#include <stdlib.h>
   134.9 -#include <string.h>
  134.10 -
  134.11  /* Mint includes */
  134.12  #include <gem.h>
  134.13  #include <gemx.h>
  134.14 @@ -39,6 +35,8 @@
  134.15  #include <mint/cookie.h>
  134.16  
  134.17  #include "SDL.h"
  134.18 +#include "SDL_stdlib.h"
  134.19 +#include "SDL_string.h"
  134.20  #include "SDL_error.h"
  134.21  #include "SDL_video.h"
  134.22  #include "SDL_mouse.h"
   135.1 --- a/src/video/ggi/SDL_ggievents.c	Tue Feb 07 07:03:29 2006 +0000
   135.2 +++ b/src/video/ggi/SDL_ggievents.c	Tue Feb 07 09:29:18 2006 +0000
   135.3 @@ -24,8 +24,6 @@
   135.4  
   135.5  #include <sys/types.h>
   135.6  #include <sys/time.h>
   135.7 -#include <stdlib.h>
   135.8 -#include <stdio.h>
   135.9  #include <unistd.h>
  135.10  #include <fcntl.h>
  135.11  #include <termios.h>
   136.1 --- a/src/video/ggi/SDL_ggivideo.c	Tue Feb 07 07:03:29 2006 +0000
   136.2 +++ b/src/video/ggi/SDL_ggivideo.c	Tue Feb 07 09:29:18 2006 +0000
   136.3 @@ -23,8 +23,6 @@
   136.4  /* GGI-based SDL video driver implementation.
   136.5  */
   136.6  
   136.7 -#include <stdlib.h>
   136.8 -#include <stdio.h>
   136.9  #include <fcntl.h>
  136.10  #include <unistd.h>
  136.11  #include <sys/mman.h>
  136.12 @@ -33,6 +31,8 @@
  136.13  #include <ggi/gii.h>
  136.14  
  136.15  #include "SDL.h"
  136.16 +#include "SDL_stdlib.h"
  136.17 +#include "SDL_string.h"
  136.18  #include "SDL_error.h"
  136.19  #include "SDL_video.h"
  136.20  #include "SDL_mouse.h"
   137.1 --- a/src/video/ipod/SDL_ipodvideo.c	Tue Feb 07 07:03:29 2006 +0000
   137.2 +++ b/src/video/ipod/SDL_ipodvideo.c	Tue Feb 07 09:29:18 2006 +0000
   137.3 @@ -1,8 +1,6 @@
   137.4  #include <sys/types.h>
   137.5  #include <sys/ioctl.h>
   137.6  
   137.7 -#include <stdlib.h>
   137.8 -#include <stdio.h>
   137.9  #include <unistd.h>
  137.10  #include <fcntl.h>
  137.11  #include <string.h>
  137.12 @@ -15,6 +13,8 @@
  137.13  #include <linux/fb.h>
  137.14  
  137.15  #include "SDL.h"
  137.16 +#include "SDL_stdlib.h"
  137.17 +#include "SDL_string.h"
  137.18  #include "SDL_error.h"
  137.19  #include "SDL_video.h"
  137.20  #include "SDL_mouse.h"
  137.21 @@ -93,15 +93,15 @@
  137.22  {
  137.23      SDL_VideoDevice *this;
  137.24      
  137.25 -    this = (SDL_VideoDevice *)malloc (sizeof(SDL_VideoDevice));
  137.26 +    this = (SDL_VideoDevice *)SDL_malloc (sizeof(SDL_VideoDevice));
  137.27      if (this) {
  137.28  	memset (this, 0, sizeof *this);
  137.29 -	this->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof(struct SDL_PrivateVideoData));
  137.30 +	this->hidden = (struct SDL_PrivateVideoData *) SDL_malloc (sizeof(struct SDL_PrivateVideoData));
  137.31      }
  137.32      if (!this || !this->hidden) {
  137.33  	SDL_OutOfMemory();
  137.34  	if (this)
  137.35 -	    free (this);
  137.36 +	    SDL_free (this);
  137.37  	return 0;
  137.38      }
  137.39      memset (this->hidden, 0, sizeof(struct SDL_PrivateVideoData));
  137.40 @@ -178,7 +178,7 @@
  137.41  	    for ( i=0; vcs[i] && (kbfd < 0); ++i ) {
  137.42  		char vtpath[12];
  137.43  		
  137.44 -		sprintf(vtpath, vcs[i], curvt);
  137.45 +		SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], curvt);
  137.46  		kbfd = open(vtpath, O_RDWR);
  137.47  	    }
  137.48  	}
  137.49 @@ -320,8 +320,8 @@
  137.50  	Rmask = Gmask = Bmask = 0;
  137.51      }
  137.52  
  137.53 -    if (this->hidden->buffer) free (this->hidden->buffer);
  137.54 -    this->hidden->buffer = malloc (width * height * (bpp / 8));
  137.55 +    if (this->hidden->buffer) SDL_free (this->hidden->buffer);
  137.56 +    this->hidden->buffer = SDL_malloc (width * height * (bpp / 8));
  137.57      if (!this->hidden->buffer) {
  137.58  	SDL_SetError ("Couldn't allocate buffer for requested mode");
  137.59  	return 0;
  137.60 @@ -331,7 +331,7 @@
  137.61  
  137.62      if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) {
  137.63  	SDL_SetError ("Couldn't allocate new pixel format");
  137.64 -	free (this->hidden->buffer);
  137.65 +	SDL_free (this->hidden->buffer);
  137.66  	this->hidden->buffer = 0;
  137.67  	return 0;
  137.68      }
   138.1 --- a/src/video/maccommon/SDL_macmouse.c	Tue Feb 07 07:03:29 2006 +0000
   138.2 +++ b/src/video/maccommon/SDL_macmouse.c	Tue Feb 07 09:29:18 2006 +0000
   138.3 @@ -20,8 +20,6 @@
   138.4      slouken@libsdl.org
   138.5  */
   138.6  
   138.7 -#include <stdlib.h>
   138.8 -#include <stdio.h>
   138.9  #if defined(__APPLE__) && defined(__MACH__)
  138.10  #include <Carbon/Carbon.h>
  138.11  #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
  138.12 @@ -35,6 +33,8 @@
  138.13  #include <CursorDevices.h>
  138.14  #endif
  138.15  
  138.16 +#include "SDL_stdlib.h"
  138.17 +#include "SDL_string.h"
  138.18  #include "SDL_error.h"
  138.19  #include "SDL_mouse.h"
  138.20  #include "SDL_macmouse_c.h"
   139.1 --- a/src/video/maccommon/SDL_macwm.c	Tue Feb 07 07:03:29 2006 +0000
   139.2 +++ b/src/video/maccommon/SDL_macwm.c	Tue Feb 07 09:29:18 2006 +0000
   139.3 @@ -20,9 +20,6 @@
   139.4      slouken@libsdl.org
   139.5  */
   139.6  
   139.7 -#include <stdlib.h>
   139.8 -#include <string.h>
   139.9 -
  139.10  #if defined(__APPLE__) && defined(__MACH__)
  139.11  #include <Carbon/Carbon.h>
  139.12  #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
  139.13 @@ -32,6 +29,7 @@
  139.14  #include <Strings.h>
  139.15  #endif
  139.16  
  139.17 +#include "SDL_string.h"
  139.18  #include "SDL_macwm_c.h"
  139.19  
  139.20  void Mac_SetCaption(_THIS, const char *title, const char *icon)
   140.1 --- a/src/video/macdsp/SDL_dspvideo.c	Tue Feb 07 07:03:29 2006 +0000
   140.2 +++ b/src/video/macdsp/SDL_dspvideo.c	Tue Feb 07 09:29:18 2006 +0000
   140.3 @@ -122,9 +122,6 @@
   140.4  #define DSP_NO_SYNC_OPENGL
   140.5  
   140.6  
   140.7 -#include <stdio.h>
   140.8 -#include <stdlib.h>
   140.9 -
  140.10  #if defined(__APPLE__) && defined(__MACH__)
  140.11  #include <Carbon/Carbon.h>
  140.12  #include <DrawSprocket/DrawSprocket.h>
  140.13 @@ -140,6 +137,8 @@
  140.14  #include <DrawSprocket.h>
  140.15  #endif
  140.16  
  140.17 +#include "SDL_stdlib.h"
  140.18 +#include "SDL_string.h"
  140.19  #include "SDL_video.h"
  140.20  #include "SDL_blit.h"
  140.21  #include "SDL_error.h"
  140.22 @@ -265,7 +264,7 @@
  140.23  		if ( device ) {
  140.24  			
  140.25  			if (device->hidden)
  140.26 -		        free (device->hidden);			
  140.27 +				SDL_free(device->hidden);			
  140.28  			
  140.29  			SDL_free(device);
  140.30  		}
  140.31 @@ -390,14 +389,14 @@
  140.32  done:
  140.33  	i++;          /* i was not incremented before kicking out of the loop */
  140.34  	
  140.35 -	mode_list = (SDL_Rect**) malloc (sizeof (SDL_Rect*) * (i+1));
  140.36 +	mode_list = (SDL_Rect**) SDL_malloc (sizeof (SDL_Rect*) * (i+1));
  140.37  	if (mode_list) {
  140.38  	
  140.39  	   /* -dw- new stuff: build in reverse order so largest sizes list first */
  140.40  		for (j = i-1; j >= 0; j--) {
  140.41 -			mode_list [j] = (SDL_Rect*) malloc (sizeof (SDL_Rect));	
  140.42 +			mode_list [j] = (SDL_Rect*) SDL_malloc (sizeof (SDL_Rect));	
  140.43  			if (mode_list [j])
  140.44 -				memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect));
  140.45 +				SDL_memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect));
  140.46  			else {
  140.47  				SDL_OutOfMemory ();
  140.48  				return NULL;
  140.49 @@ -475,7 +474,7 @@
  140.50  	  return 0;
  140.51  	}
  140.52  		
  140.53 -	memset (&attrib, 0, sizeof (DSpContextAttributes));
  140.54 +	SDL_memset (&attrib, 0, sizeof (DSpContextAttributes));
  140.55  
  140.56  	/* These attributes are hopefully supported on all devices...*/
  140.57  	attrib.displayWidth         = 640;
  140.58 @@ -657,7 +656,7 @@
  140.59  		fmt = "Hardware surface could not be allocated in %s - unknown error";
  140.60  		break;
  140.61  	}
  140.62 -	sprintf(message, fmt, mem);
  140.63 +	SDL_snprintf(message, SDL_arraysize(message), fmt, mem);
  140.64  	SDL_SetError(message);
  140.65  }
  140.66  #endif // TARGET_API_MAC_OSX
  140.67 @@ -735,7 +734,7 @@
  140.68  		   DisposeGWorld (dsp_back_buffer);
  140.69  		
  140.70  		if (current->hwdata)
  140.71 -		   free (current->hwdata);
  140.72 +		   SDL_free(current->hwdata);
  140.73  		   
  140.74  		DSpContext_SetState (dsp_context, kDSpContextState_Inactive );
  140.75  		DSpContext_Release  (dsp_context);
  140.76 @@ -788,7 +787,7 @@
  140.77  		page_count = 1;
  140.78  	}
  140.79  
  140.80 -	memset (&attrib, 0, sizeof (DSpContextAttributes));
  140.81 +	SDL_memset (&attrib, 0, sizeof (DSpContextAttributes));
  140.82  	attrib.displayWidth         = width;
  140.83  	attrib.displayHeight        = height;
  140.84  	attrib.displayBestDepth     = bpp;
  140.85 @@ -867,7 +866,7 @@
  140.86  		/* single-buffer context */
  140.87  		DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer);
  140.88  			
  140.89 -		current->hwdata   = (private_hwdata*) malloc (sizeof (private_hwdata));
  140.90 +		current->hwdata   = (private_hwdata*) SDL_malloc (sizeof (private_hwdata));
  140.91  		if (current ->hwdata == NULL) {
  140.92  			SDL_OutOfMemory ();
  140.93  	  		return NULL;		  
  140.94 @@ -885,13 +884,13 @@
  140.95  	} 
  140.96  	else if ( DSp_NewHWSurface(this, &dsp_back_buffer, bpp, width-1, height-1) == 0 ) {
  140.97        
  140.98 -      current->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata));
  140.99 +      current->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata));
 140.100        if (current ->hwdata == NULL) {
 140.101        	SDL_OutOfMemory ();
 140.102        	return NULL;		  
 140.103        }
 140.104        
 140.105 -      memset (current->hwdata, 0, sizeof (private_hwdata));
 140.106 +      SDL_memset (current->hwdata, 0, sizeof (private_hwdata));
 140.107        current->hwdata->offscreen = dsp_back_buffer;
 140.108        current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; 
 140.109        this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */	   
 140.110 @@ -1084,13 +1083,13 @@
 140.111  	if ( DSp_NewHWSurface (this, &temp, surface->format->BitsPerPixel, surface->w, surface->h) < 0 )
 140.112  	   return (-1);
 140.113  			
 140.114 -	surface->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata));
 140.115 +	surface->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata));
 140.116  	if (surface->hwdata == NULL) {
 140.117  		SDL_OutOfMemory ();
 140.118  		return -1;
 140.119  	}
 140.120  	
 140.121 -	memset (surface->hwdata, 0, sizeof(private_hwdata));
 140.122 +	SDL_memset (surface->hwdata, 0, sizeof(private_hwdata));
 140.123  	surface->hwdata->offscreen = temp;
 140.124  	surface->pitch	 = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF;
 140.125  	surface->pixels  = GetPixBaseAddr (GetPortPixMap (temp));
 140.126 @@ -1105,7 +1104,7 @@
 140.127  {	
 140.128  	if (surface->hwdata->offscreen != NULL)
 140.129  		DisposeGWorld (surface->hwdata->offscreen);
 140.130 -	free (surface->hwdata);
 140.131 +	SDL_free(surface->hwdata);
 140.132  
 140.133      surface->pixels = NULL;
 140.134  }
   141.1 --- a/src/video/macrom/SDL_romvideo.c	Tue Feb 07 07:03:29 2006 +0000
   141.2 +++ b/src/video/macrom/SDL_romvideo.c	Tue Feb 07 09:29:18 2006 +0000
   141.3 @@ -20,9 +20,6 @@
   141.4      slouken@libsdl.org
   141.5  */
   141.6  
   141.7 -#include <stdio.h>
   141.8 -#include <stdlib.h>
   141.9 -
  141.10  #if defined(__APPLE__) && defined(__MACH__)
  141.11  #include <Carbon/Carbon.h>
  141.12  #if USE_QUICKTIME
  141.13 @@ -44,6 +41,8 @@
  141.14  #include <QDOffscreen.h>
  141.15  #endif
  141.16  
  141.17 +#include "SDL_stdlib.h"
  141.18 +#include "SDL_string.h"
  141.19  #include "SDL_video.h"
  141.20  #include "SDL_error.h"
  141.21  #include "SDL_syswm.h"
   142.1 --- a/src/video/nanox/SDL_nximage.c	Tue Feb 07 07:03:29 2006 +0000
   142.2 +++ b/src/video/nanox/SDL_nximage.c	Tue Feb 07 09:29:18 2006 +0000
   142.3 @@ -25,9 +25,8 @@
   142.4      clare@setabox.com
   142.5  */
   142.6  
   142.7 -#include <stdlib.h>
   142.8 -#include <string.h>
   142.9 -
  142.10 +#include "SDL_stdlib.h"
  142.11 +#include "SDL_string.h"
  142.12  #include "SDL_error.h"
  142.13  
  142.14  #include "SDL_nximage_c.h"
  142.15 @@ -106,7 +105,7 @@
  142.16          else
  142.17          {
  142.18              for (j = h; j > 0; -- j, src += yinc, dest += destinc)
  142.19 -                memcpy (dest, src, rowinc) ;
  142.20 +                SDL_memcpy (dest, src, rowinc) ;
  142.21          }
  142.22          if (!Clientfb) {
  142.23              if (currently_fullscreen) {
  142.24 @@ -128,13 +127,13 @@
  142.25      
  142.26      Dprintf ("enter NX_SetupImage\n") ;
  142.27  
  142.28 -    screen -> pixels = (void *) malloc (size) ;
  142.29 +    screen -> pixels = (void *) SDL_malloc (size) ;
  142.30  
  142.31      if (!Clientfb) {
  142.32 -        Image_buff = (unsigned char *) malloc (size) ;
  142.33 +        Image_buff = (unsigned char *) SDL_malloc (size) ;
  142.34          if (screen -> pixels == NULL || Image_buff == NULL) {
  142.35 -            free (screen -> pixels) ;
  142.36 -            free (Image_buff) ;
  142.37 +            SDL_free (screen -> pixels) ;
  142.38 +            SDL_free (Image_buff) ;
  142.39              SDL_OutOfMemory () ;
  142.40              return -1 ;
  142.41          }
  142.42 @@ -152,8 +151,8 @@
  142.43  {
  142.44      Dprintf ("enter NX_DestroyImage\n") ;
  142.45      
  142.46 -    if (SDL_Image) free (SDL_Image) ;
  142.47 -    if (Image_buff) free (Image_buff) ;
  142.48 +    if (SDL_Image) SDL_free (SDL_Image) ;
  142.49 +    if (Image_buff) SDL_free (Image_buff) ;
  142.50      if (screen) screen -> pixels = NULL ;
  142.51      
  142.52      Dprintf ("leave NX_DestroyImage\n") ;
  142.53 @@ -215,7 +214,7 @@
  142.54          rowinc = xinc * this -> screen -> w;
  142.55  
  142.56          for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
  142.57 -            memcpy (dest, src, rowinc) ;
  142.58 +            SDL_memcpy (dest, src, rowinc) ;
  142.59      }
  142.60      else
  142.61  #endif
   143.1 --- a/src/video/nanox/SDL_nxmodes.c	Tue Feb 07 07:03:29 2006 +0000
   143.2 +++ b/src/video/nanox/SDL_nxmodes.c	Tue Feb 07 09:29:18 2006 +0000
   143.3 @@ -24,8 +24,8 @@
   143.4      clare@setabox.com
   143.5  */
   143.6  
   143.7 -#include <stdlib.h>
   143.8 -
   143.9 +#include "SDL_stdlib.h"
  143.10 +#include "SDL_string.h"
  143.11  #include "SDL_nxmodes_c.h"
  143.12  
  143.13  SDL_Rect ** NX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
  143.14 @@ -46,9 +46,9 @@
  143.15  
  143.16      if (SDL_modelist) {
  143.17          for (i = 0; SDL_modelist [i]; ++ i) {
  143.18 -            free (SDL_modelist [i]) ;
  143.19 +            SDL_free (SDL_modelist [i]) ;
  143.20          }
  143.21 -        free (SDL_modelist) ;
  143.22 +        SDL_free (SDL_modelist) ;
  143.23          SDL_modelist = NULL;
  143.24      }
  143.25  }
   144.1 --- a/src/video/nanox/SDL_nxmouse.c	Tue Feb 07 07:03:29 2006 +0000
   144.2 +++ b/src/video/nanox/SDL_nxmouse.c	Tue Feb 07 09:29:18 2006 +0000
   144.3 @@ -24,8 +24,7 @@
   144.4      clare@setabox.com
   144.5  */
   144.6  
   144.7 -#include <stdlib.h>
   144.8 -
   144.9 +#include "SDL_stdlib.h"
  144.10  #include "SDL_error.h"
  144.11  #include "SDL_events_c.h"
  144.12  
  144.13 @@ -43,7 +42,7 @@
  144.14  
  144.15      Dprintf ("enter NX_CreateWMCursor\n") ;
  144.16  
  144.17 -    cursor = (WMcursor *) malloc (sizeof (WMcursor)) ;
  144.18 +    cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)) ;
  144.19      if (cursor == NULL) {
  144.20          SDL_OutOfMemory () ;
  144.21          return NULL ;
  144.22 @@ -56,7 +55,7 @@
  144.23  void NX_FreeWMCursor (_THIS, WMcursor * cursor)
  144.24  {
  144.25      Dprintf ("NX_FreeWMCursor\n") ;
  144.26 -    free (cursor) ;
  144.27 +    SDL_free (cursor) ;
  144.28      return ;
  144.29  }
  144.30  
   145.1 --- a/src/video/nanox/SDL_nxvideo.c	Tue Feb 07 07:03:29 2006 +0000
   145.2 +++ b/src/video/nanox/SDL_nxvideo.c	Tue Feb 07 09:29:18 2006 +0000
   145.3 @@ -25,9 +25,8 @@
   145.4      clare@setabox.com
   145.5  */
   145.6  
   145.7 -#include <stdlib.h>
   145.8 -#include <string.h>
   145.9 -
  145.10 +#include "SDL_stdlib.h"
  145.11 +#include "SDL_string.h"
  145.12  #include "SDL_video.h"
  145.13  #include "SDL_pixels_c.h"
  145.14  #include "SDL_events_c.h"
  145.15 @@ -84,11 +83,11 @@
  145.16      Dprintf ("enter NX_CreateDevice\n") ;
  145.17  
  145.18      // Initialize all variables that we clean on shutdown
  145.19 -    device = (SDL_VideoDevice *) malloc (sizeof (SDL_VideoDevice)) ;
  145.20 +    device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)) ;
  145.21      if (device) {
  145.22 -        memset (device, 0, (sizeof * device)) ;
  145.23 +        SDL_memset (device, 0, (sizeof * device)) ;
  145.24          device -> hidden = (struct SDL_PrivateVideoData *)
  145.25 -                malloc ((sizeof * device -> hidden)) ;
  145.26 +                SDL_malloc ((sizeof * device -> hidden)) ;
  145.27          device -> gl_data = NULL ;
  145.28      }
  145.29      if ((device == NULL) || (device -> hidden == NULL)) {
  145.30 @@ -96,7 +95,7 @@
  145.31          NX_DeleteDevice (device) ;
  145.32          return 0 ;
  145.33      }
  145.34 -    memset (device -> hidden, 0, (sizeof * device -> hidden)) ;
  145.35 +    SDL_memset (device -> hidden, 0, (sizeof * device -> hidden)) ;
  145.36  
  145.37      // Set the function pointers
  145.38      device -> VideoInit = NX_VideoInit ;
  145.39 @@ -212,9 +211,9 @@
  145.40      SDL_Visual.bpp = si.bpp ;
  145.41  
  145.42      // GetVideoMode
  145.43 -    SDL_modelist = (SDL_Rect **) malloc (sizeof (SDL_Rect *) * 2) ;
  145.44 +    SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2) ;
  145.45      if (SDL_modelist) {
  145.46 -        SDL_modelist [0] = (SDL_Rect *) malloc (sizeof(SDL_Rect)) ;
  145.47 +        SDL_modelist [0] = (SDL_Rect *) SDL_malloc (sizeof(SDL_Rect)) ;
  145.48          if (SDL_modelist [0]) {
  145.49              SDL_modelist [0] -> x = 0 ;
  145.50              SDL_modelist [0] -> y = 0 ;
  145.51 @@ -486,9 +485,9 @@
  145.52      
  145.53      if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1 ;
  145.54  
  145.55 -    if (! GammaRamp_R) GammaRamp_R = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ;
  145.56 -    if (! GammaRamp_G) GammaRamp_G = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ;
  145.57 -    if (! GammaRamp_B) GammaRamp_B = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ;
  145.58 +    if (! GammaRamp_R) GammaRamp_R = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ;
  145.59 +    if (! GammaRamp_G) GammaRamp_G = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ;
  145.60 +    if (! GammaRamp_B) GammaRamp_B = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ;
  145.61      if ((! GammaRamp_R) || (! GammaRamp_G) || (! GammaRamp_B)) {
  145.62          SDL_OutOfMemory () ;
  145.63          return -1 ;
   146.1 --- a/src/video/nanox/SDL_nxwm.c	Tue Feb 07 07:03:29 2006 +0000
   146.2 +++ b/src/video/nanox/SDL_nxwm.c	Tue Feb 07 09:29:18 2006 +0000
   146.3 @@ -24,8 +24,6 @@
   146.4      clare@setabox.com
   146.5  */
   146.6  
   146.7 -#include <stdlib.h>
   146.8 -
   146.9  #include "SDL_syswm.h"
  146.10  #include "SDL_error.h"
  146.11  #include "SDL_events_c.h"
   147.1 --- a/src/video/os2fslib/SDL_os2fslib.c	Tue Feb 07 07:03:29 2006 +0000
   147.2 +++ b/src/video/os2fslib/SDL_os2fslib.c	Tue Feb 07 09:29:18 2006 +0000
   147.3 @@ -20,13 +20,12 @@
   147.4      slouken@libsdl.org
   147.5  */
   147.6  
   147.7 -#include <stdio.h>
   147.8 -#include <stdlib.h>
   147.9 -#include <string.h>
  147.10  #include <process.h>
  147.11  #include <time.h>
  147.12  
  147.13  #include "SDL.h"
  147.14 +#include "SDL_stdlib.h"
  147.15 +#include "SDL_string.h"
  147.16  #include "SDL_error.h"
  147.17  #include "SDL_video.h"
  147.18  #include "SDL_mouse.h"
   148.1 --- a/src/video/photon/SDL_ph_image.c	Tue Feb 07 07:03:29 2006 +0000
   148.2 +++ b/src/video/photon/SDL_ph_image.c	Tue Feb 07 09:29:18 2006 +0000
   148.3 @@ -20,12 +20,12 @@
   148.4      slouken@libsdl.org
   148.5  */
   148.6  
   148.7 -#include <stdlib.h>
   148.8 -
   148.9  #include <Ph.h>
  148.10  #include <photon/Pg.h>
  148.11  
  148.12  #include "SDL.h"
  148.13 +#include "SDL_stdlib.h"
  148.14 +#include "SDL_string.h"
  148.15  #include "SDL_error.h"
  148.16  #include "SDL_endian.h"
  148.17  #include "SDL_video.h"
   149.1 --- a/src/video/photon/SDL_ph_modes.c	Tue Feb 07 07:03:29 2006 +0000
   149.2 +++ b/src/video/photon/SDL_ph_modes.c	Tue Feb 07 09:29:18 2006 +0000
   149.3 @@ -173,7 +173,7 @@
   149.4          return -1;
   149.5      }
   149.6  
   149.7 -    qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
   149.8 +    SDL_qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
   149.9  
  149.10      for(i=0;i<mode_list.num_modes;i++)
  149.11      {
   150.1 --- a/src/video/photon/SDL_ph_mouse.c	Tue Feb 07 07:03:29 2006 +0000
   150.2 +++ b/src/video/photon/SDL_ph_mouse.c	Tue Feb 07 09:29:18 2006 +0000
   150.3 @@ -20,10 +20,8 @@
   150.4      slouken@libsdl.org
   150.5  */
   150.6  
   150.7 -#include <stdlib.h>
   150.8 -#include <stdio.h>
   150.9 -#include <string.h>
  150.10 -
  150.11 +#include "SDL_stdlib.h"
  150.12 +#include "SDL_string.h"
  150.13  #include "SDL_error.h"
  150.14  #include "SDL_mouse.h"
  150.15  #include "SDL_events_c.h"
   151.1 --- a/src/video/photon/SDL_ph_video.c	Tue Feb 07 07:03:29 2006 +0000
   151.2 +++ b/src/video/photon/SDL_ph_video.c	Tue Feb 07 09:29:18 2006 +0000
   151.3 @@ -20,13 +20,12 @@
   151.4      slouken@libsdl.org
   151.5  */
   151.6  
   151.7 -#include <stdlib.h>
   151.8 -#include <stdio.h>
   151.9  #include <unistd.h>
  151.10 -#include <string.h>
  151.11  #include <sys/ioctl.h>
  151.12  
  151.13  #include "SDL.h"
  151.14 +#include "SDL_stdlib.h"
  151.15 +#include "SDL_string.h"
  151.16  #include "SDL_error.h"
  151.17  #include "SDL_timer.h"
  151.18  #include "SDL_thread.h"
   152.1 --- a/src/video/photon/SDL_ph_wm.c	Tue Feb 07 07:03:29 2006 +0000
   152.2 +++ b/src/video/photon/SDL_ph_wm.c	Tue Feb 07 09:29:18 2006 +0000
   152.3 @@ -22,13 +22,13 @@
   152.4  
   152.5  #define DISABLE_X11
   152.6  
   152.7 -#include <stdlib.h>
   152.8 -#include <string.h>
   152.9  #include <Ph.h>
  152.10  #include <photon/PpProto.h>
  152.11  #include <photon/PhWm.h>
  152.12  #include <photon/wmapi.h>
  152.13 +
  152.14  #include "SDL_version.h"
  152.15 +#include "SDL_string.h"
  152.16  #include "SDL_error.h"
  152.17  #include "SDL_timer.h"
  152.18  #include "SDL_video.h"
   153.1 --- a/src/video/photon/SDL_phyuv.c	Tue Feb 07 07:03:29 2006 +0000
   153.2 +++ b/src/video/photon/SDL_phyuv.c	Tue Feb 07 09:29:18 2006 +0000
   153.3 @@ -22,13 +22,13 @@
   153.4  
   153.5  /* This is the QNX Realtime Platform version of SDL YUV video overlays */
   153.6  
   153.7 -#include <stdlib.h>
   153.8 -#include <string.h>
   153.9  #include <errno.h>
  153.10  
  153.11  #include <Ph.h>
  153.12  #include <Pt.h>
  153.13  
  153.14 +#include "SDL_stdlib.h"
  153.15 +#include "SDL_string.h"
  153.16  #include "SDL_error.h"
  153.17  #include "SDL_video.h"
  153.18  #include "SDL_phyuv_c.h"
  153.19 @@ -81,7 +81,7 @@
  153.20      PhPoint_t pos;
  153.21  
  153.22      /* Create the overlay structure */
  153.23 -    overlay = calloc(1, sizeof(SDL_Overlay));
  153.24 +    overlay = SDL_calloc(1, sizeof(SDL_Overlay));
  153.25  
  153.26      if (overlay == NULL)
  153.27      {
  153.28 @@ -99,7 +99,7 @@
  153.29      overlay->hwfuncs = &ph_yuvfuncs;
  153.30  
  153.31      /* Create the pixel data and lookup tables */
  153.32 -    hwdata = calloc(1, sizeof(struct private_yuvhwdata));
  153.33 +    hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata));
  153.34  
  153.35      if (hwdata == NULL)
  153.36      {
  153.37 @@ -132,8 +132,8 @@
  153.38      overlay->hwdata->CurrentViewPort.size.w = width;
  153.39      overlay->hwdata->CurrentViewPort.size.h = height;
  153.40      overlay->hwdata->State = OVERLAY_STATE_UNINIT;
  153.41 -    overlay->hwdata->FrameData0 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA));
  153.42 -    overlay->hwdata->FrameData1 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA));
  153.43 +    overlay->hwdata->FrameData0 = (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA));
  153.44 +    overlay->hwdata->FrameData1 = (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA));
  153.45  
  153.46      vidport = -1;
  153.47      i=0;
  153.48 @@ -246,8 +246,8 @@
  153.49  
  153.50      /* Find the pitch and offset values for the overlay */
  153.51      overlay->planes = planes;
  153.52 -    overlay->pitches = calloc(overlay->planes, sizeof(Uint16));
  153.53 -    overlay->pixels  = calloc(overlay->planes, sizeof(Uint8*));
  153.54 +    overlay->pitches = SDL_calloc(overlay->planes, sizeof(Uint16));
  153.55 +    overlay->pixels  = SDL_calloc(overlay->planes, sizeof(Uint8*));
  153.56      if (!overlay->pitches || !overlay->pixels)
  153.57      {
  153.58          SDL_OutOfMemory();
   154.1 --- a/src/video/picogui/SDL_pgvideo.c	Tue Feb 07 07:03:29 2006 +0000
   154.2 +++ b/src/video/picogui/SDL_pgvideo.c	Tue Feb 07 09:29:18 2006 +0000
   154.3 @@ -23,11 +23,9 @@
   154.4      micahjd@users.sourceforge.net
   154.5  */
   154.6  
   154.7 -#include <stdio.h>
   154.8 -#include <stdlib.h>
   154.9 -#include <string.h>
  154.10 -
  154.11  #include "SDL.h"
  154.12 +#include "SDL_stdlib.h"
  154.13 +#include "SDL_string.h"
  154.14  #include "SDL_error.h"
  154.15  #include "SDL_video.h"
  154.16  #include "SDL_mouse.h"
   155.1 --- a/src/video/ps2gs/SDL_gsevents.c	Tue Feb 07 07:03:29 2006 +0000
   155.2 +++ b/src/video/ps2gs/SDL_gsevents.c	Tue Feb 07 09:29:18 2006 +0000
   155.3 @@ -25,11 +25,8 @@
   155.4  #include <sys/types.h>
   155.5  #include <sys/time.h>
   155.6  #include <sys/ioctl.h>
   155.7 -#include <stdlib.h>
   155.8 -#include <stdio.h>
   155.9  #include <unistd.h>
  155.10  #include <fcntl.h>
  155.11 -#include <string.h>
  155.12  #include <errno.h>
  155.13  #include <limits.h>
  155.14  
  155.15 @@ -42,6 +39,7 @@
  155.16  #include <linux/keyboard.h>
  155.17  
  155.18  #include "SDL.h"
  155.19 +#include "SDL_string.h"
  155.20  #include "SDL_mutex.h"
  155.21  #include "SDL_sysevents.h"
  155.22  #include "SDL_sysvideo.h"
  155.23 @@ -257,7 +255,7 @@
  155.24  			for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) {
  155.25  				char vtpath[12];
  155.26  
  155.27 -				sprintf(vtpath, vcs[i], current_vt);
  155.28 +				SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], current_vt);
  155.29  				keyboard_fd = open(vtpath, O_RDWR, 0);
  155.30  #ifdef DEBUG_KEYBOARD
  155.31  				fprintf(stderr, "vtpath = %s, fd = %d\n",
  155.32 @@ -333,7 +331,7 @@
  155.33  			char path[PATH_MAX];
  155.34  			char name[PATH_MAX];
  155.35  
  155.36 -			sprintf(path, "/proc/%s/status", entry->d_name);
  155.37 +			SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", entry->d_name);
  155.38  			status=fopen(path, "r");
  155.39  			if ( status ) {
  155.40  				name[0] = '\0';
  155.41 @@ -367,7 +365,7 @@
  155.42  	proc = opendir("/proc");
  155.43  	if ( proc ) {
  155.44  		while ( (pid=find_pid(proc, "gpm")) > 0 ) {
  155.45 -			sprintf(path, "/proc/%d/cmdline", pid);
  155.46 +			SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid);
  155.47  			cmdline = open(path, O_RDONLY, 0);
  155.48  			if ( cmdline >= 0 ) {
  155.49  				len = read(cmdline, args, sizeof(args));
   156.1 --- a/src/video/ps2gs/SDL_gsmouse.c	Tue Feb 07 07:03:29 2006 +0000
   156.2 +++ b/src/video/ps2gs/SDL_gsmouse.c	Tue Feb 07 09:29:18 2006 +0000
   156.3 @@ -20,8 +20,6 @@
   156.4      slouken@libsdl.org
   156.5  */
   156.6  
   156.7 -#include <stdlib.h>
   156.8 -#include <stdio.h>
   156.9  #include <sys/ioctl.h>
  156.10  
  156.11  #include "SDL_error.h"
   157.1 --- a/src/video/ps2gs/SDL_gsvideo.c	Tue Feb 07 07:03:29 2006 +0000
   157.2 +++ b/src/video/ps2gs/SDL_gsvideo.c	Tue Feb 07 09:29:18 2006 +0000
   157.3 @@ -23,14 +23,14 @@
   157.4  /* Framebuffer console based SDL video driver implementation.
   157.5  */
   157.6  
   157.7 -#include <stdlib.h>
   157.8 -#include <stdio.h>
   157.9  #include <fcntl.h>
  157.10  #include <unistd.h>
  157.11  #include <sys/ioctl.h>
  157.12  #include <sys/mman.h>
  157.13  
  157.14  #include "SDL.h"
  157.15 +#include "SDL_stdlib.h"
  157.16 +#include "SDL_string.h"
  157.17  #include "SDL_error.h"
  157.18  #include "SDL_video.h"
  157.19  #include "SDL_mouse.h"
   158.1 --- a/src/video/ps2gs/SDL_gsyuv.c	Tue Feb 07 07:03:29 2006 +0000
   158.2 +++ b/src/video/ps2gs/SDL_gsyuv.c	Tue Feb 07 09:29:18 2006 +0000
   158.3 @@ -22,14 +22,14 @@
   158.4  
   158.5  /* This is the Playstation 2 implementation of YUV video overlays */
   158.6  
   158.7 -#include <stdlib.h>
   158.8 -#include <string.h>
   158.9  #include <fcntl.h>
  158.10  #include <unistd.h>
  158.11  #include <sys/ioctl.h>
  158.12  #include <sys/mman.h>
  158.13  #include <asm/page.h>		/* For definition of PAGE_SIZE */
  158.14  
  158.15 +#include "SDL_stdlib.h"
  158.16 +#include "SDL_string.h"
  158.17  #include "SDL_error.h"
  158.18  #include "SDL_video.h"
  158.19  #include "SDL_gsyuv_c.h"
   159.1 --- a/src/video/qtopia/SDL_sysmouse.cc	Tue Feb 07 07:03:29 2006 +0000
   159.2 +++ b/src/video/qtopia/SDL_sysmouse.cc	Tue Feb 07 09:29:18 2006 +0000
   159.3 @@ -20,11 +20,6 @@
   159.4      slouken@libsdl.org
   159.5  */
   159.6  
   159.7 -#include <stdlib.h>
   159.8 -#include <string.h>
   159.9 -
  159.10 -
  159.11 -#include "SDL_error.h"
  159.12  #include "SDL_QWin.h"
  159.13  
  159.14  extern "C" {
   160.1 --- a/src/video/qtopia/SDL_sysvideo.cc	Tue Feb 07 07:03:29 2006 +0000
   160.2 +++ b/src/video/qtopia/SDL_sysvideo.cc	Tue Feb 07 09:29:18 2006 +0000
   160.3 @@ -22,16 +22,14 @@
   160.4  
   160.5  /* Qtopia based framebuffer implementation */
   160.6  
   160.7 -#include <stdlib.h>
   160.8 -#include <string.h>
   160.9 -
  160.10 -#include <stdio.h>
  160.11  #include <unistd.h>
  160.12  
  160.13  #include <qapplication.h>
  160.14  #include <qpe/qpeapplication.h>
  160.15  
  160.16  #include "SDL.h"
  160.17 +#include "SDL_stdlib.h"
  160.18 +#include "SDL_string.h"
  160.19  #include "SDL_timer.h"
  160.20  
  160.21  #include "SDL_QWin.h"
   161.1 --- a/src/video/quartz/SDL_QuartzEvents.m	Tue Feb 07 07:03:29 2006 +0000
   161.2 +++ b/src/video/quartz/SDL_QuartzEvents.m	Tue Feb 07 09:29:18 2006 +0000
   161.3 @@ -20,9 +20,9 @@
   161.4      slouken@libsdl.org
   161.5  */
   161.6  
   161.7 +#include "SDL_stdlib.h"
   161.8  #include "SDL_QuartzVideo.h"
   161.9  
  161.10 -#include <stdlib.h> // For getenv()
  161.11  #include <IOKit/IOMessage.h> // For wake from sleep detection
  161.12  #include <IOKit/pwr_mgt/IOPMLib.h> // For wake from sleep detection
  161.13  #include "SDL_QuartzKeys.h"
  161.14 @@ -295,7 +295,7 @@
  161.15          }
  161.16      }
  161.17      
  161.18 -    if (getenv ("SDL_ENABLEAPPEVENTS"))
  161.19 +    if (SDL_getenv ("SDL_ENABLEAPPEVENTS"))
  161.20          [ NSApp sendEvent:event ];
  161.21  }
  161.22  
  161.23 @@ -773,7 +773,7 @@
  161.24  
  161.25              switch (type) {
  161.26                  case NSLeftMouseDown:
  161.27 -                    if ( getenv("SDL_HAS3BUTTONMOUSE") ) {
  161.28 +                    if ( SDL_getenv("SDL_HAS3BUTTONMOUSE") ) {
  161.29                          DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
  161.30                      } else {
  161.31                          if ( NSCommandKeyMask & current_mods ) {
   162.1 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c	Tue Feb 07 07:03:29 2006 +0000
   162.2 +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c	Tue Feb 07 09:29:18 2006 +0000
   162.3 @@ -27,11 +27,9 @@
   162.4       Implements RISC OS full screen display.
   162.5  */
   162.6  
   162.7 -#include <stdio.h>
   162.8 -#include <stdlib.h>
   162.9 -#include <string.h>
  162.10 -
  162.11  #include "SDL.h"
  162.12 +#include "SDL_stdlib.h"
  162.13 +#include "SDL_string.h"
  162.14  #include "SDL_error.h"
  162.15  #include "SDL_video.h"
  162.16  #include "SDL_mouse.h"
  162.17 @@ -357,7 +355,7 @@
  162.18  	/* Sort the mode lists */
  162.19  	for ( j=0; j<NUM_MODELISTS; ++j ) {
  162.20  		if ( SDL_nummodes[j] > 0 ) {
  162.21 -			qsort(SDL_modelist[j], SDL_nummodes[j], sizeof *SDL_modelist[j], cmpmodes);
  162.22 +			SDL_qsort(SDL_modelist[j], SDL_nummodes[j], sizeof *SDL_modelist[j], cmpmodes);
  162.23  		}
  162.24  	}
  162.25  }
   163.1 --- a/src/video/riscos/SDL_riscosmouse.c	Tue Feb 07 07:03:29 2006 +0000
   163.2 +++ b/src/video/riscos/SDL_riscosmouse.c	Tue Feb 07 09:29:18 2006 +0000
   163.3 @@ -27,9 +27,7 @@
   163.4       Implements mouse cursor shape definitions and positioning
   163.5  */
   163.6  
   163.7 -#include <stdio.h>
   163.8 -#include <stdlib.h>
   163.9 -
  163.10 +#include "SDL_stdlib.h"
  163.11  #include "SDL_error.h"
  163.12  #include "SDL_mouse.h"
  163.13  #include "SDL_events_c.h"
   164.1 --- a/src/video/riscos/SDL_riscossprite.c	Tue Feb 07 07:03:29 2006 +0000
   164.2 +++ b/src/video/riscos/SDL_riscossprite.c	Tue Feb 07 09:29:18 2006 +0000
   164.3 @@ -27,9 +27,10 @@
   164.4       Implements Sprite plotting code for wimp display.window
   164.5  */
   164.6  
   164.7 -#include <stdlib.h>
   164.8  #include "kernel.h"
   164.9  #include "swis.h"
  164.10 +
  164.11 +#include "SDL_stdlib.h"
  164.12  #include "SDL_riscosvideo.h"
  164.13  
  164.14  extern void WIMP_ReadModeInfo(_THIS);
   165.1 --- a/src/video/riscos/SDL_riscostask.c	Tue Feb 07 07:03:29 2006 +0000
   165.2 +++ b/src/video/riscos/SDL_riscostask.c	Tue Feb 07 09:29:18 2006 +0000
   165.3 @@ -31,12 +31,11 @@
   165.4  	  Restoring desktop after switching to full screen
   165.5  */
   165.6  
   165.7 -#include <stdlib.h>
   165.8 -#include <string.h>
   165.9 -
  165.10  #include "kernel.h"
  165.11  #include "swis.h"
  165.12  
  165.13 +#include "SDL_stdlib.h"
  165.14 +#include "SDL_string.h"
  165.15  #include "SDL_riscostask.h"
  165.16  
  165.17  #ifndef DISABLE_THREADS
   166.1 --- a/src/video/riscos/SDL_riscosvideo.c	Tue Feb 07 07:03:29 2006 +0000
   166.2 +++ b/src/video/riscos/SDL_riscosvideo.c	Tue Feb 07 09:29:18 2006 +0000
   166.3 @@ -29,11 +29,9 @@
   166.4  	 into other source files.
   166.5  */
   166.6  
   166.7 -#include <stdio.h>
   166.8 -#include <stdlib.h>
   166.9 -#include <string.h>
  166.10 -
  166.11  #include "SDL.h"
  166.12 +#include "SDL_stdlib.h"
  166.13 +#include "SDL_string.h"
  166.14  #include "SDL_syswm.h"
  166.15  #include "SDL_error.h"
  166.16  #include "SDL_video.h"
   167.1 --- a/src/video/riscos/SDL_wimpvideo.c	Tue Feb 07 07:03:29 2006 +0000
   167.2 +++ b/src/video/riscos/SDL_wimpvideo.c	Tue Feb 07 09:29:18 2006 +0000
   167.3 @@ -27,11 +27,9 @@
   167.4       Implements RISC OS Wimp display.
   167.5  */
   167.6  
   167.7 -#include <stdio.h>
   167.8 -#include <stdlib.h>
   167.9 -#include <string.h>
  167.10 -
  167.11  #include "SDL.h"
  167.12 +#include "SDL_stdlib.h"
  167.13 +#include "SDL_string.h"
  167.14  #include "SDL_error.h"
  167.15  #include "SDL_video.h"
  167.16  #include "SDL_mouse.h"
   168.1 --- a/src/video/svga/SDL_svgaevents.c	Tue Feb 07 07:03:29 2006 +0000
   168.2 +++ b/src/video/svga/SDL_svgaevents.c	Tue Feb 07 09:29:18 2006 +0000
   168.3 @@ -22,9 +22,6 @@
   168.4  
   168.5  /* Handle the event stream, converting X11 events into SDL events */
   168.6  
   168.7 -#include <stdio.h>
   168.8 -#include <stdlib.h>
   168.9 -
  168.10  #include <vga.h>
  168.11  #include <vgamouse.h>
  168.12  #include <vgakeyboard.h>
  168.13 @@ -38,6 +35,8 @@
  168.14  #endif
  168.15  
  168.16  #include "SDL.h"
  168.17 +#include "SDL_stdlib.h"
  168.18 +#include "SDL_string.h"
  168.19  #include "SDL_sysevents.h"
  168.20  #include "SDL_events_c.h"
  168.21  #include "SDL_svgavideo.h"
   169.1 --- a/src/video/svga/SDL_svgavideo.c	Tue Feb 07 07:03:29 2006 +0000
   169.2 +++ b/src/video/svga/SDL_svgavideo.c	Tue Feb 07 09:29:18 2006 +0000
   169.3 @@ -23,8 +23,6 @@
   169.4  /* SVGAlib based SDL video driver implementation.
   169.5  */
   169.6  
   169.7 -#include <stdlib.h>
   169.8 -#include <stdio.h>
   169.9  #include <unistd.h>
  169.10  #include <sys/stat.h>
  169.11  #include <sys/types.h>
  169.12 @@ -43,6 +41,8 @@
  169.13  #include <vgakeyboard.h>
  169.14  
  169.15  #include "SDL.h"
  169.16 +#include "SDL_stdlib.h"
  169.17 +#include "SDL_string.h"
  169.18  #include "SDL_error.h"
  169.19  #include "SDL_video.h"
  169.20  #include "SDL_mouse.h"
   170.1 --- a/src/video/vgl/SDL_vglvideo.c	Tue Feb 07 07:03:29 2006 +0000
   170.2 +++ b/src/video/vgl/SDL_vglvideo.c	Tue Feb 07 09:29:18 2006 +0000
   170.3 @@ -25,8 +25,6 @@
   170.4  
   170.5  #include <err.h>
   170.6  #include <osreldate.h>
   170.7 -#include <stdlib.h>
   170.8 -#include <stdio.h>
   170.9  #include <unistd.h>
  170.10  #include <sys/stat.h>
  170.11  
  170.12 @@ -36,6 +34,8 @@
  170.13  #include <vgl.h>
  170.14  
  170.15  #include "SDL.h"
  170.16 +#include "SDL_stdlib.h"
  170.17 +#include "SDL_string.h"
  170.18  #include "SDL_error.h"
  170.19  #include "SDL_video.h"
  170.20  #include "SDL_mouse.h"
   171.1 --- a/src/video/wincommon/SDL_sysevents.c	Tue Feb 07 07:03:29 2006 +0000
   171.2 +++ b/src/video/wincommon/SDL_sysevents.c	Tue Feb 07 09:29:18 2006 +0000
   171.3 @@ -22,12 +22,12 @@
   171.4  
   171.5  #include "SDL_windows.h"
   171.6  
   171.7 +#include "SDL_stdlib.h"
   171.8 +#include "SDL_string.h"
   171.9  #include "SDL_events.h"
  171.10  #include "SDL_video.h"
  171.11  #include "SDL_error.h"
  171.12  #include "SDL_syswm.h"
  171.13 -#include "SDL_stdlib.h"
  171.14 -#include "SDL_string.h"
  171.15  #include "SDL_getenv.h"
  171.16  #include "SDL_sysevents.h"
  171.17  #include "SDL_events_c.h"
   172.1 --- a/src/video/wincommon/SDL_sysmouse.c	Tue Feb 07 07:03:29 2006 +0000
   172.2 +++ b/src/video/wincommon/SDL_sysmouse.c	Tue Feb 07 09:29:18 2006 +0000
   172.3 @@ -22,10 +22,10 @@
   172.4  
   172.5  #include "SDL_windows.h"
   172.6  
   172.7 +#include "SDL_stdlib.h"
   172.8 +#include "SDL_string.h"
   172.9  #include "SDL_error.h"
  172.10  #include "SDL_mouse.h"
  172.11 -#include "SDL_stdlib.h"
  172.12 -#include "SDL_string.h"
  172.13  #include "SDL_sysmouse_c.h"
  172.14  #include "SDL_events_c.h"
  172.15  #include "SDL_cursor_c.h"
   173.1 --- a/src/video/wincommon/SDL_syswm.c	Tue Feb 07 07:03:29 2006 +0000
   173.2 +++ b/src/video/wincommon/SDL_syswm.c	Tue Feb 07 09:29:18 2006 +0000
   173.3 @@ -23,11 +23,11 @@
   173.4  #include "SDL_windows.h"
   173.5  
   173.6  #include "SDL_version.h"
   173.7 +#include "SDL_stdlib.h"
   173.8 +#include "SDL_string.h"
   173.9  #include "SDL_error.h"
  173.10  #include "SDL_video.h"
  173.11  #include "SDL_syswm.h"
  173.12 -#include "SDL_stdlib.h"
  173.13 -#include "SDL_string.h"
  173.14  #include "SDL_syswm_c.h"
  173.15  #include "SDL_wingl_c.h"
  173.16  #include "SDL_pixels_c.h"
   174.1 --- a/src/video/wincommon/SDL_wingl.c	Tue Feb 07 07:03:29 2006 +0000
   174.2 +++ b/src/video/wincommon/SDL_wingl.c	Tue Feb 07 09:29:18 2006 +0000
   174.3 @@ -22,12 +22,12 @@
   174.4  
   174.5  /* WGL implementation of SDL OpenGL support */
   174.6  
   174.7 +#include "SDL_stdlib.h"
   174.8 +#include "SDL_string.h"
   174.9  #ifdef HAVE_OPENGL
  174.10  #include "SDL_opengl.h"
  174.11  #endif
  174.12  #include "SDL_error.h"
  174.13 -#include "SDL_stdlib.h"
  174.14 -#include "SDL_string.h"
  174.15  #include "SDL_lowvideo.h"
  174.16  #include "SDL_wingl_c.h"
  174.17  
   175.1 --- a/src/video/windib/SDL_dibevents.c	Tue Feb 07 07:03:29 2006 +0000
   175.2 +++ b/src/video/windib/SDL_dibevents.c	Tue Feb 07 09:29:18 2006 +0000
   175.3 @@ -22,11 +22,11 @@
   175.4  
   175.5  #include "SDL_windows.h"
   175.6  
   175.7 +#include "SDL_stdlib.h"
   175.8 +#include "SDL_string.h"
   175.9  #include "SDL_events.h"
  175.10  #include "SDL_error.h"
  175.11  #include "SDL_syswm.h"
  175.12 -#include "SDL_stdlib.h"
  175.13 -#include "SDL_string.h"
  175.14  #include "SDL_sysevents.h"
  175.15  #include "SDL_events_c.h"
  175.16  #include "SDL_lowvideo.h"
   176.1 --- a/src/video/windib/SDL_dibvideo.c	Tue Feb 07 07:03:29 2006 +0000
   176.2 +++ b/src/video/windib/SDL_dibvideo.c	Tue Feb 07 09:29:18 2006 +0000
   176.3 @@ -35,10 +35,10 @@
   176.4  #endif
   176.5  
   176.6  #include "SDL.h"
   176.7 +#include "SDL_stdlib.h"
   176.8 +#include "SDL_string.h"
   176.9  #include "SDL_mutex.h"
  176.10  #include "SDL_syswm.h"
  176.11 -#include "SDL_stdlib.h"
  176.12 -#include "SDL_string.h"
  176.13  #include "SDL_sysvideo.h"
  176.14  #include "SDL_sysevents.h"
  176.15  #include "SDL_events_c.h"
   177.1 --- a/src/video/windx5/SDL_dx5events.c	Tue Feb 07 07:03:29 2006 +0000
   177.2 +++ b/src/video/windx5/SDL_dx5events.c	Tue Feb 07 09:29:18 2006 +0000
   177.3 @@ -24,12 +24,12 @@
   177.4  
   177.5  #include "directx.h"
   177.6  
   177.7 +#include "SDL_stdlib.h"
   177.8 +#include "SDL_string.h"
   177.9  #include "SDL_events.h"
  177.10  #include "SDL_video.h"
  177.11  #include "SDL_error.h"
  177.12  #include "SDL_syswm.h"
  177.13 -#include "SDL_stdlib.h"
  177.14 -#include "SDL_string.h"
  177.15  #include "SDL_sysevents.h"
  177.16  #include "SDL_events_c.h"
  177.17  #include "SDL_lowvideo.h"
   178.1 --- a/src/video/windx5/SDL_dx5video.c	Tue Feb 07 07:03:29 2006 +0000
   178.2 +++ b/src/video/windx5/SDL_dx5video.c	Tue Feb 07 09:29:18 2006 +0000
   178.3 @@ -28,12 +28,12 @@
   178.4  #define CDS_FULLSCREEN	4
   178.5  #endif
   178.6  
   178.7 +#include "SDL_stdlib.h"
   178.8 +#include "SDL_string.h"
   178.9  #include "SDL_error.h"
  178.10  #include "SDL_timer.h"
  178.11  #include "SDL_events.h"
  178.12  #include "SDL_syswm.h"
  178.13 -#include "SDL_stdlib.h"
  178.14 -#include "SDL_string.h"
  178.15  #include "SDL_sysvideo.h"
  178.16  #include "SDL_blit.h"
  178.17  #include "SDL_pixels_c.h"
   179.1 --- a/src/video/windx5/SDL_dx5yuv.c	Tue Feb 07 07:03:29 2006 +0000
   179.2 +++ b/src/video/windx5/SDL_dx5yuv.c	Tue Feb 07 09:29:18 2006 +0000
   179.3 @@ -22,10 +22,10 @@
   179.4  
   179.5  /* This is the DirectDraw implementation of YUV video overlays */
   179.6  
   179.7 +#include "SDL_stdlib.h"
   179.8 +#include "SDL_string.h"
   179.9  #include "SDL_error.h"
  179.10  #include "SDL_video.h"
  179.11 -#include "SDL_stdlib.h"
  179.12 -#include "SDL_string.h"
  179.13  #include "SDL_dx5yuv_c.h"
  179.14  #include "SDL_yuvfuncs.h"
  179.15  
   180.1 --- a/src/video/wscons/SDL_wsconsvideo.c	Tue Feb 07 07:03:29 2006 +0000
   180.2 +++ b/src/video/wscons/SDL_wsconsvideo.c	Tue Feb 07 09:29:18 2006 +0000
   180.3 @@ -26,13 +26,11 @@
   180.4  #include <dev/wscons/wsdisplay_usl_io.h>
   180.5  #include <fcntl.h>
   180.6  #include <unistd.h>
   180.7 -#include <stdio.h>
   180.8 -#include <stdlib.h>
   180.9 -#include <string.h>
  180.10 -#include <stdarg.h>
  180.11  #include <errno.h>
  180.12  
  180.13  #include "SDL.h"
  180.14 +#include "SDL_stdlib.h"
  180.15 +#include "SDL_string.h"
  180.16  #include "SDL_error.h"
  180.17  #include "SDL_video.h"
  180.18  #include "SDL_mouse.h"
   181.1 --- a/src/video/x11/SDL_x11dga.c	Tue Feb 07 07:03:29 2006 +0000
   181.2 +++ b/src/video/x11/SDL_x11dga.c	Tue Feb 07 09:29:18 2006 +0000
   181.3 @@ -25,7 +25,8 @@
   181.4     There will be a completely separate DGA driver that is fullscreen-only.
   181.5  */
   181.6  
   181.7 -#include <stdlib.h>		/* For SDL_getenv() */
   181.8 +#include "SDL_stdlib.h"
   181.9 +#include "SDL_string.h"
  181.10  #include "SDL_video.h"
  181.11  #include "SDL_cursor_c.h"
  181.12  #include "SDL_x11dga_c.h"
   182.1 --- a/src/video/x11/SDL_x11events.c	Tue Feb 07 07:03:29 2006 +0000
   182.2 +++ b/src/video/x11/SDL_x11events.c	Tue Feb 07 09:29:18 2006 +0000
   182.3 @@ -22,9 +22,6 @@
   182.4  
   182.5  /* Handle the event stream, converting X11 events into SDL events */
   182.6  
   182.7 -#include <stdio.h>
   182.8 -#include <stdlib.h>
   182.9 -#include <string.h>
  182.10  #include <setjmp.h>
  182.11  #include <X11/Xlib.h>
  182.12  #include <X11/Xutil.h>
  182.13 @@ -37,6 +34,7 @@
  182.14  #include <unistd.h>
  182.15  
  182.16  #include "SDL.h"
  182.17 +#include "SDL_string.h"
  182.18  #include "SDL_syswm.h"
  182.19  #include "SDL_sysevents.h"
  182.20  #include "SDL_sysvideo.h"
   183.1 --- a/src/video/x11/SDL_x11gl.c	Tue Feb 07 07:03:29 2006 +0000
   183.2 +++ b/src/video/x11/SDL_x11gl.c	Tue Feb 07 09:29:18 2006 +0000
   183.3 @@ -20,12 +20,11 @@
   183.4      slouken@libsdl.org
   183.5  */
   183.6  
   183.7 -#include <stdlib.h>	/* For SDL_getenv() prototype */
   183.8 -#include <string.h>
   183.9 -
  183.10 -#include "SDL_events_c.h"
  183.11 +#include "SDL_stdlib.h"
  183.12 +#include "SDL_string.h"
  183.13  #include "SDL_error.h"
  183.14  #include "SDL_x11video.h"
  183.15 +#include "SDL_events_c.h"
  183.16  #include "SDL_x11dga_c.h"
  183.17  #include "SDL_x11gl_c.h"
  183.18  
   184.1 --- a/src/video/x11/SDL_x11image.c	Tue Feb 07 07:03:29 2006 +0000
   184.2 +++ b/src/video/x11/SDL_x11image.c	Tue Feb 07 09:29:18 2006 +0000
   184.3 @@ -20,9 +20,11 @@
   184.4      slouken@libsdl.org
   184.5  */
   184.6  
   184.7 -#include <stdlib.h>
   184.8 +#include <stdio.h>
   184.9  #include <unistd.h>
  184.10  
  184.11 +#include "SDL_stdlib.h"
  184.12 +#include "SDL_string.h"
  184.13  #include "SDL_error.h"
  184.14  #include "SDL_endian.h"
  184.15  #include "SDL_events_c.h"
   185.1 --- a/src/video/x11/SDL_x11modes.c	Tue Feb 07 07:03:29 2006 +0000
   185.2 +++ b/src/video/x11/SDL_x11modes.c	Tue Feb 07 09:29:18 2006 +0000
   185.3 @@ -22,9 +22,10 @@
   185.4  
   185.5  /* Utilities for getting and setting the X display mode */
   185.6  
   185.7 -#include <stdlib.h>
   185.8 -#include <string.h>
   185.9 +#include <stdio.h>
  185.10  
  185.11 +#include "SDL_stdlib.h"
  185.12 +#include "SDL_string.h"
  185.13  #include "SDL_timer.h"
  185.14  #include "SDL_error.h"
  185.15  #include "SDL_events.h"
  185.16 @@ -359,7 +360,7 @@
  185.17          }
  185.18  #endif
  185.19  
  185.20 -        qsort(modes, nmodes, sizeof *modes, cmpmodes);
  185.21 +        SDL_qsort(modes, nmodes, sizeof *modes, cmpmodes);
  185.22          SDL_modelist = (SDL_Rect **)SDL_malloc((nmodes+2)*sizeof(SDL_Rect *));
  185.23          if ( SDL_modelist ) {
  185.24              n = 0;
   186.1 --- a/src/video/x11/SDL_x11mouse.c	Tue Feb 07 07:03:29 2006 +0000
   186.2 +++ b/src/video/x11/SDL_x11mouse.c	Tue Feb 07 09:29:18 2006 +0000
   186.3 @@ -20,13 +20,11 @@
   186.4      slouken@libsdl.org
   186.5  */
   186.6  
   186.7 -#include <stdlib.h>
   186.8 -#include <stdio.h>
   186.9 -#include <string.h>
  186.10 -
  186.11  #include <X11/Xlib.h>
  186.12  #include <X11/Xutil.h>
  186.13  
  186.14 +#include "SDL_stdlib.h"
  186.15 +#include "SDL_string.h"
  186.16  #include "SDL_error.h"
  186.17  #include "SDL_mouse.h"
  186.18  #include "SDL_events_c.h"
   187.1 --- a/src/video/x11/SDL_x11video.c	Tue Feb 07 07:03:29 2006 +0000
   187.2 +++ b/src/video/x11/SDL_x11video.c	Tue Feb 07 09:29:18 2006 +0000
   187.3 @@ -27,29 +27,16 @@
   187.4            if full locking is neccessary, take a look at XInitThreads().
   187.5  */
   187.6  
   187.7 -#include <stdlib.h>
   187.8 -#include <stdio.h>
   187.9  #include <unistd.h>
  187.10 -#include <string.h>
  187.11  #include <sys/ioctl.h>
  187.12  #ifdef MTRR_SUPPORT
  187.13  #include <asm/mtrr.h>
  187.14  #include <sys/fcntl.h>
  187.15  #endif
  187.16  
  187.17 -#ifdef HAVE_ALLOCA_H
  187.18 -#include <alloca.h>
  187.19 -#endif
  187.20 -
  187.21 -#ifdef HAVE_ALLOCA
  187.22 -#define ALLOCA(n) ((void*)alloca(n))
  187.23 -#define FREEA(p)
  187.24 -#else
  187.25 -#define ALLOCA(n) SDL_malloc(n)
  187.26 -#define FREEA(p) SDL_free(p)
  187.27 -#endif
  187.28 -
  187.29  #include "SDL.h"
  187.30 +#include "SDL_stdlib.h"
  187.31 +#include "SDL_string.h"
  187.32  #include "SDL_error.h"
  187.33  #include "SDL_timer.h"
  187.34  #include "SDL_thread.h"
  187.35 @@ -299,9 +286,9 @@
  187.36  	/* Next look at the application's executable name */
  187.37  #if defined(linux) || defined(__FreeBSD__)
  187.38  #if defined(linux)
  187.39 -	sprintf(procfile, "/proc/%d/exe", getpid());
  187.40 +	SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid());
  187.41  #elif defined(__FreeBSD__)
  187.42 -	sprintf(procfile, "/proc/%d/file", getpid());
  187.43 +	SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file", getpid());
  187.44  #else
  187.45  #error Where can we find the executable name?
  187.46  #endif
  187.47 @@ -1215,7 +1202,7 @@
  187.48  	        /* private writable colormap: just set the colours we need */
  187.49  	        XColor  *xcmap;
  187.50  		int i;
  187.51 -	        xcmap = ALLOCA(ncolors*sizeof(*xcmap));
  187.52 +	        xcmap = SDL_stack_alloc(XColor, ncolors);
  187.53  		if(xcmap == NULL)
  187.54  		        return 0;
  187.55  		for ( i=0; i<ncolors; ++i ) {
  187.56 @@ -1227,7 +1214,7 @@
  187.57  		}
  187.58  		pXStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
  187.59  		pXSync(GFX_Display, False);
  187.60 -		FREEA(xcmap);
  187.61 +		SDL_stack_free(xcmap);
  187.62  	} else {
  187.63  	        /*
  187.64  		 * Shared colormap: We only allocate read-only cells, which
  187.65 @@ -1245,7 +1232,7 @@
  187.66  		int nfree = 0;
  187.67  		int nc = this->screen->format->palette->ncolors;
  187.68  	        colors = this->screen->format->palette->colors;
  187.69 -		freelist = ALLOCA(nc * sizeof(*freelist));
  187.70 +		freelist = SDL_stack_alloc(unsigned long, nc);
  187.71  		/* make sure multiple allocations of the same cell are freed */
  187.72  	        for(i = 0; i < ncolors; i++) {
  187.73  		        int pixel = firstcolor + i;
  187.74 @@ -1255,10 +1242,10 @@
  187.75  			}
  187.76  		}
  187.77  		pXFreeColors(GFX_Display, SDL_XColorMap, freelist, nfree, 0);
  187.78 -		FREEA(freelist);
  187.79 +		SDL_stack_free(freelist);
  187.80  
  187.81 -		want = ALLOCA(ncolors * sizeof(SDL_Color));
  187.82 -		reject = ALLOCA(ncolors * sizeof(SDL_Color));
  187.83 +		want = SDL_stack_alloc(SDL_Color, ncolors);
  187.84 +		reject = SDL_stack_alloc(SDL_Color, ncolors);
  187.85  		SDL_memcpy(want, colors + firstcolor, ncolors * sizeof(SDL_Color));
  187.86  		/* make sure the user isn't fooled by her own wishes
  187.87  		   (black is safe, always available in the default colormap) */
  187.88 @@ -1288,8 +1275,8 @@
  187.89  		}
  187.90  		if(nrej)
  187.91  			allocate_nearest(this, colors, reject, nrej);
  187.92 -		FREEA(reject);
  187.93 -		FREEA(want);
  187.94 +		SDL_stack_free(reject);
  187.95 +		SDL_stack_free(want);
  187.96  	}
  187.97  	return nrej == 0;
  187.98  }
   188.1 --- a/src/video/x11/SDL_x11wm.c	Tue Feb 07 07:03:29 2006 +0000
   188.2 +++ b/src/video/x11/SDL_x11wm.c	Tue Feb 07 09:29:18 2006 +0000
   188.3 @@ -20,12 +20,12 @@
   188.4      slouken@libsdl.org
   188.5  */
   188.6  
   188.7 -#include <stdlib.h>
   188.8 -#include <string.h>
   188.9  #include <X11/Xlib.h>
  188.10  #include <X11/Xutil.h>
  188.11  
  188.12  #include "SDL_version.h"
  188.13 +#include "SDL_stdlib.h"
  188.14 +#include "SDL_string.h"
  188.15  #include "SDL_error.h"
  188.16  #include "SDL_timer.h"
  188.17  #include "SDL_video.h"
   189.1 --- a/src/video/x11/SDL_x11yuv.c	Tue Feb 07 07:03:29 2006 +0000
   189.2 +++ b/src/video/x11/SDL_x11yuv.c	Tue Feb 07 09:29:18 2006 +0000
   189.3 @@ -24,8 +24,6 @@
   189.4  
   189.5  #ifdef XFREE86_XV
   189.6  
   189.7 -#include <stdlib.h>
   189.8 -#include <string.h>
   189.9  #include <X11/Xlib.h>
  189.10  #ifndef NO_SHARED_MEMORY
  189.11  #include <sys/ipc.h>
  189.12 @@ -34,6 +32,8 @@
  189.13  #endif
  189.14  #include <Xext/extensions/Xvlib.h>
  189.15  
  189.16 +#include "SDL_stdlib.h"
  189.17 +#include "SDL_string.h"
  189.18  #include "SDL_error.h"
  189.19  #include "SDL_video.h"
  189.20  #include "SDL_x11yuv_c.h"
   190.1 --- a/src/video/xbios/SDL_xbios.c	Tue Feb 07 07:03:29 2006 +0000
   190.2 +++ b/src/video/xbios/SDL_xbios.c	Tue Feb 07 09:29:18 2006 +0000
   190.3 @@ -26,9 +26,6 @@
   190.4   * Patrice Mandin
   190.5   */
   190.6  
   190.7 -#include <stdio.h>
   190.8 -#include <stdlib.h>
   190.9 -#include <string.h>
  190.10  #include <sys/stat.h>
  190.11  #include <unistd.h>
  190.12  
  190.13 @@ -38,6 +35,8 @@
  190.14  #include <mint/falcon.h>
  190.15  
  190.16  #include "SDL.h"
  190.17 +#include "SDL_stdlib.h"
  190.18 +#include "SDL_string.h"
  190.19  #include "SDL_error.h"
  190.20  #include "SDL_video.h"
  190.21  #include "SDL_mouse.h"
   191.1 --- a/src/video/xbios/SDL_xbios_centscreen.c	Tue Feb 07 07:03:29 2006 +0000
   191.2 +++ b/src/video/xbios/SDL_xbios_centscreen.c	Tue Feb 07 09:29:18 2006 +0000
   191.3 @@ -26,11 +26,10 @@
   191.4  	Patrice Mandin
   191.5  */
   191.6  
   191.7 -#include <stdlib.h>
   191.8 -#include <string.h>
   191.9 -
  191.10  #include <mint/falcon.h>
  191.11  
  191.12 +#include "SDL_stdlib.h"
  191.13 +#include "SDL_string.h"
  191.14  #include "SDL_xbios.h"
  191.15  #include "SDL_xbios_centscreen.h"
  191.16  
   192.1 --- a/src/video/xbios/SDL_xbios_sb3.c	Tue Feb 07 07:03:29 2006 +0000
   192.2 +++ b/src/video/xbios/SDL_xbios_sb3.c	Tue Feb 07 09:29:18 2006 +0000
   192.3 @@ -28,8 +28,7 @@
   192.4  
   192.5  /*--- Includes ---*/
   192.6  
   192.7 -#include <stdlib.h>
   192.8 -
   192.9 +#include "SDL_stdlib.h"
  192.10  #include "SDL_xbios.h"
  192.11  #include "SDL_xbios_sb3.h"
  192.12