From 07c43c5fd054f69198ca6af049e358d0e01e0f6e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 7 Feb 2006 09:29:18 +0000 Subject: [PATCH] Removed uses of stdlib.h and string.h --- src/SDL.c | 2 +- src/SDL_error.c | 2 +- src/audio/SDL_audiodev.c | 14 ++++---- src/audio/SDL_audiomem.c | 2 +- src/audio/SDL_wave.c | 4 +-- src/audio/alsa/SDL_alsa_audio.c | 11 ++---- src/audio/amigaos/SDL_ahiaudio.h | 2 -- src/audio/arts/SDL_artsaudio.c | 10 ++---- src/audio/baudio/SDL_beaudio.cc | 5 ++- src/audio/dart/SDL_dart.c | 6 ++-- src/audio/dc/SDL_dcaudio.c | 6 ++-- src/audio/disk/SDL_diskaudio.c | 4 +-- src/audio/dma/SDL_dmaaudio.c | 4 +-- src/audio/dmedia/SDL_irixaudio.c | 4 +-- src/audio/dsp/SDL_dspaudio.c | 7 ++-- src/audio/esd/SDL_esdaudio.c | 9 ++--- src/audio/macosx/SDL_coreaudio.c | 12 +++---- src/audio/macrom/SDL_romaudio.c | 7 ++-- src/audio/mint/SDL_mintaudio_dma8.c | 6 ++-- src/audio/mint/SDL_mintaudio_gsxb.c | 6 ++-- src/audio/mint/SDL_mintaudio_mcsn.c | 5 ++- src/audio/mint/SDL_mintaudio_stfa.c | 6 ++-- src/audio/mint/SDL_mintaudio_xbios.c | 5 ++- src/audio/mme/SDL_mmeaudio.c | 2 +- src/audio/mme/SDL_mmeaudio.h | 3 -- src/audio/nas/SDL_nasaudio.c | 6 ++-- src/audio/nto/SDL_nto_audio.c | 5 ++- src/audio/openbsd/SDL_openbsdaudio.c | 6 ++-- src/audio/paudio/SDL_paudio.c | 5 ++- src/audio/sun/SDL_sunaudio.c | 5 ++- src/audio/ums/SDL_umsaudio.c | 5 ++- src/audio/windib/SDL_dibaudio.c | 4 +-- src/audio/windx5/SDL_dx5audio.c | 4 +-- src/cdrom/SDL_cdrom.c | 4 +-- src/cdrom/aix/SDL_syscdrom.c | 5 ++- src/cdrom/beos/SDL_syscdrom.cc | 5 ++- src/cdrom/bsdi/SDL_syscdrom.c | 10 +++--- src/cdrom/dc/SDL_syscdrom.c | 2 -- src/cdrom/freebsd/SDL_syscdrom.c | 9 +++-- src/cdrom/linux/SDL_syscdrom.c | 9 +++-- src/cdrom/macosx/AudioFileReaderThread.c | 4 +-- src/cdrom/macosx/SDLOSXCAGuard.c | 7 ++++ src/cdrom/macosx/SDL_syscdrom.c | 6 ++-- src/cdrom/mint/SDL_syscdrom.c | 3 -- src/cdrom/openbsd/SDL_syscdrom.c | 9 +++-- src/cdrom/os2/SDL_syscdrom.c | 5 ++- src/cdrom/osf/SDL_syscdrom.c | 9 ++--- src/cdrom/qnx/SDL_syscdrom.c | 9 +++-- src/cdrom/win32/SDL_syscdrom.c | 4 +-- src/file/SDL_rwops.c | 4 +-- src/joystick/SDL_joystick.c | 4 +-- src/joystick/amigaos/SDL_sysjoystick.c | 4 +-- src/joystick/beos/SDL_bejoystick.cc | 6 ++-- src/joystick/bsd/SDL_sysjoystick.c | 11 +++--- src/joystick/darwin/SDL_sysjoystick.c | 3 -- src/joystick/dc/SDL_sysjoystick.c | 5 ++- src/joystick/linux/SDL_sysjoystick.c | 7 ++-- src/joystick/mint/SDL_sysjoystick.c | 6 ++-- src/joystick/os2/SDL_sysjoystick.c | 9 ++--- src/joystick/riscos/SDL_sysjoystick.c | 5 ++- src/joystick/win32/SDL_mmjoystick.c | 4 +-- src/loadso/macosx/SDL_loadso.c | 18 +++++----- src/main/beos/SDL_BeApp.cc | 2 -- src/main/macos/SDL_main.c | 2 +- src/stdlib/SDL_malloc.c | 7 +--- src/stdlib/SDL_string.c | 9 +++-- src/thread/SDL_thread.c | 4 +-- src/thread/amigaos/SDL_systhread.c | 2 +- src/thread/amigaos/SDL_systhread_c.h | 3 -- src/thread/amigaos/SDL_thread.c | 6 ++-- src/thread/bsdi/SDL_syssem.c | 4 +-- src/thread/dc/SDL_syscond.c | 4 +-- src/thread/dc/SDL_sysmutex.c | 4 +-- src/thread/dc/SDL_syssem.c | 2 -- src/thread/epoc/SDL_sysmutex.cpp | 3 -- src/thread/epoc/SDL_syssem.cpp | 2 -- src/thread/epoc/SDL_systhread.cpp | 4 --- src/thread/generic/SDL_syscond.c | 2 +- src/thread/generic/SDL_sysmutex.c | 2 +- src/thread/generic/SDL_syssem.c | 2 +- src/thread/irix/SDL_systhread.c | 1 - src/thread/linux/SDL_syscond.c | 2 +- src/thread/linux/SDL_sysmutex.c | 5 ++- src/thread/linux/SDL_syssem.c | 7 ++-- src/thread/linux/SDL_systhread.c | 4 +-- src/thread/os2/SDL_syscond.c | 4 +-- src/thread/os2/SDL_sysmutex.c | 3 +- src/thread/os2/SDL_syssem.c | 3 +- src/thread/os2/SDL_systhread.c | 3 +- src/thread/pth/SDL_syscond.c | 3 +- src/thread/pth/SDL_sysmutex.c | 3 +- src/thread/riscos/SDL_syscond.c | 3 +- src/thread/riscos/SDL_sysmutex.c | 5 ++- src/thread/riscos/SDL_syssem.c | 6 +--- src/thread/win32/SDL_sysmutex.c | 2 +- src/thread/win32/SDL_syssem.c | 2 +- src/thread/win32/SDL_systhread.c | 2 +- src/timer/SDL_timer.c | 2 +- src/video/SDL_RLEaccel.c | 4 +-- src/video/SDL_blit_N.c | 4 +-- src/video/SDL_cursor.c | 4 +-- src/video/SDL_gamma.c | 2 +- src/video/SDL_pixels.c | 4 +-- src/video/SDL_surface.c | 4 +-- src/video/SDL_video.c | 4 +-- src/video/SDL_yuv.c | 2 +- src/video/SDL_yuv_sw.c | 4 +-- src/video/Xext/Xv/Xv.c | 8 ++--- src/video/Xext/Xxf86dga/XF86DGA.c | 8 ++--- src/video/aalib/SDL_aavideo.c | 5 ++- src/video/ataricommon/SDL_atarievents.c | 5 ++- src/video/ataricommon/SDL_atarigl.c | 5 ++- src/video/ataricommon/SDL_xbiosevents.c | 4 --- src/video/bwindow/SDL_sysmouse.cc | 5 ++- src/video/bwindow/SDL_sysvideo.cc | 8 ++--- src/video/bwindow/SDL_sysyuv.cc | 13 +++---- src/video/cybergfx/SDL_cgximage.c | 4 +-- src/video/cybergfx/SDL_cgxmodes.c | 5 --- src/video/cybergfx/SDL_cgxvideo.c | 12 ------- src/video/cybergfx/SDL_cgxvideo.h | 8 ++--- src/video/cybergfx/SDL_cgxyuv.c | 4 +-- src/video/dc/SDL_dcvideo.c | 6 ++-- src/video/dga/SDL_dgavideo.c | 17 +++++---- src/video/directfb/SDL_DirectFB_events.c | 2 -- src/video/directfb/SDL_DirectFB_video.c | 21 ++++++----- src/video/directfb/SDL_DirectFB_yuv.c | 8 ++--- src/video/dummy/SDL_nullvideo.c | 8 ++--- src/video/epoc/SDL_epocvideo.cpp | 6 ++-- src/video/fbcon/SDL_fbelo.c | 4 +-- src/video/fbcon/SDL_fbevents.c | 12 +++---- src/video/fbcon/SDL_fbvideo.c | 9 +++-- src/video/gapi/SDL_gapivideo.c | 7 ++-- src/video/gem/SDL_gemmouse.c | 3 +- src/video/gem/SDL_gemvideo.c | 6 ++-- src/video/ggi/SDL_ggievents.c | 2 -- src/video/ggi/SDL_ggivideo.c | 4 +-- src/video/ipod/SDL_ipodvideo.c | 18 +++++----- src/video/maccommon/SDL_macmouse.c | 4 +-- src/video/maccommon/SDL_macwm.c | 4 +-- src/video/macdsp/SDL_dspvideo.c | 33 +++++++++-------- src/video/macrom/SDL_romvideo.c | 5 ++- src/video/nanox/SDL_nximage.c | 21 ++++++----- src/video/nanox/SDL_nxmodes.c | 8 ++--- src/video/nanox/SDL_nxmouse.c | 7 ++-- src/video/nanox/SDL_nxvideo.c | 23 ++++++------ src/video/nanox/SDL_nxwm.c | 2 -- src/video/os2fslib/SDL_os2fslib.c | 5 ++- src/video/photon/SDL_ph_image.c | 4 +-- src/video/photon/SDL_ph_modes.c | 2 +- src/video/photon/SDL_ph_mouse.c | 6 ++-- src/video/photon/SDL_ph_video.c | 5 ++- src/video/photon/SDL_ph_wm.c | 4 +-- src/video/photon/SDL_phyuv.c | 16 ++++----- src/video/picogui/SDL_pgvideo.c | 6 ++-- src/video/ps2gs/SDL_gsevents.c | 10 +++--- src/video/ps2gs/SDL_gsmouse.c | 2 -- src/video/ps2gs/SDL_gsvideo.c | 4 +-- src/video/ps2gs/SDL_gsyuv.c | 4 +-- src/video/qtopia/SDL_sysmouse.cc | 5 --- src/video/qtopia/SDL_sysvideo.cc | 6 ++-- src/video/quartz/SDL_QuartzEvents.m | 6 ++-- src/video/riscos/SDL_riscosFullScreenVideo.c | 8 ++--- src/video/riscos/SDL_riscosmouse.c | 4 +-- src/video/riscos/SDL_riscossprite.c | 3 +- src/video/riscos/SDL_riscostask.c | 5 ++- src/video/riscos/SDL_riscosvideo.c | 6 ++-- src/video/riscos/SDL_wimpvideo.c | 6 ++-- src/video/svga/SDL_svgaevents.c | 5 ++- src/video/svga/SDL_svgavideo.c | 4 +-- src/video/vgl/SDL_vglvideo.c | 4 +-- src/video/wincommon/SDL_sysevents.c | 4 +-- src/video/wincommon/SDL_sysmouse.c | 4 +-- src/video/wincommon/SDL_syswm.c | 4 +-- src/video/wincommon/SDL_wingl.c | 4 +-- src/video/windib/SDL_dibevents.c | 4 +-- src/video/windib/SDL_dibvideo.c | 4 +-- src/video/windx5/SDL_dx5events.c | 4 +-- src/video/windx5/SDL_dx5video.c | 4 +-- src/video/windx5/SDL_dx5yuv.c | 4 +-- src/video/wscons/SDL_wsconsvideo.c | 6 ++-- src/video/x11/SDL_x11dga.c | 3 +- src/video/x11/SDL_x11events.c | 4 +-- src/video/x11/SDL_x11gl.c | 7 ++-- src/video/x11/SDL_x11image.c | 4 ++- src/video/x11/SDL_x11modes.c | 7 ++-- src/video/x11/SDL_x11mouse.c | 6 ++-- src/video/x11/SDL_x11video.c | 37 +++++++------------- src/video/x11/SDL_x11wm.c | 4 +-- src/video/x11/SDL_x11yuv.c | 4 +-- src/video/xbios/SDL_xbios.c | 5 ++- src/video/xbios/SDL_xbios_centscreen.c | 5 ++- src/video/xbios/SDL_xbios_sb3.c | 3 +- 192 files changed, 455 insertions(+), 666 deletions(-) diff --git a/src/SDL.c b/src/SDL.c index 9d18916b2..120ea54a8 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -27,9 +27,9 @@ #endif #include "SDL.h" +#include "SDL_stdlib.h" #include "SDL_endian.h" #include "SDL_fatal.h" -#include "SDL_stdlib.h" #ifndef DISABLE_VIDEO #include "SDL_leaks.h" #endif diff --git a/src/SDL_error.c b/src/SDL_error.c index bdf58feec..f0b59ec4b 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -22,9 +22,9 @@ /* Simple error handling in SDL */ -#include "SDL_types.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_types.h" #include "SDL_error.h" #include "SDL_error_c.h" #ifndef DISABLE_THREADS diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index e2d0542d7..41e5c7d1e 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -24,13 +24,12 @@ #if defined(unix) || defined(__unix__) || defined(__riscos__) -#include -#include #include #include #include -#include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audiodev_c.h" #ifndef _PATH_DEV_DSP @@ -80,7 +79,8 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) instance = 1; do { /* Don't use errno ENOENT - it may not be thread-safe */ - sprintf(audiopath, "%s%d", audiodev, instance++); + SDL_snprintf(audiopath, SDL_arraysize(audiopath), + "%s%d", audiodev, instance++); exists = 0; if ( stat(audiopath, &sb) == 0 ) { exists = 1; @@ -100,11 +100,11 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) /* Get the name of the audio device we use for output */ -#include #include #include -#include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audiodev_c.h" #ifndef _PATH_DEV_DSP @@ -158,7 +158,7 @@ int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) cycle = 0; while( devsettings[cycle][0] != '\0' ) { - sprintf( audiopath, + SDL_snprintf( audiopath, SDL_arraysize(audiopath), _PATH_DEV_DSP, devsettings[cycle][0], devsettings[cycle][1], diff --git a/src/audio/SDL_audiomem.c b/src/audio/SDL_audiomem.c index 6333ffbc6..3e93aa1aa 100644 --- a/src/audio/SDL_audiomem.c +++ b/src/audio/SDL_audiomem.c @@ -31,8 +31,8 @@ #include #endif -#include "SDL_audiomem.h" #include "SDL_stdlib.h" +#include "SDL_audiomem.h" /* Allocate memory that will be shared between threads (freed on exit) */ void *SDL_AllocAudioMem(int size) diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 9a2af7ede..e2ecf14d6 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -24,10 +24,10 @@ /* Microsoft WAVE file loading routines */ -#include "SDL_error.h" -#include "SDL_audio.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_audio.h" #include "SDL_wave.h" #include "SDL_endian.h" diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 4f40fff70..b36aa5f58 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -24,16 +24,11 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include -#include -#include -#include -#include #include -#include +#include /* For kill() */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/amigaos/SDL_ahiaudio.h b/src/audio/amigaos/SDL_ahiaudio.h index 433a76509..fd5c9bd9a 100644 --- a/src/audio/amigaos/SDL_ahiaudio.h +++ b/src/audio/amigaos/SDL_ahiaudio.h @@ -30,8 +30,6 @@ #else #include #endif -#include -#include #include #include "mydebug.h" diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index 366421d26..e7342385b 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -22,14 +22,8 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include -#include -#include -#include -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/baudio/SDL_beaudio.cc b/src/audio/baudio/SDL_beaudio.cc index 3a2727c6e..c53483c18 100644 --- a/src/audio/baudio/SDL_beaudio.cc +++ b/src/audio/baudio/SDL_beaudio.cc @@ -22,15 +22,14 @@ /* Allow access to the audio stream on BeOS */ -#include -#include -#include #include #include "SDL_BeApp.h" extern "C" { +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_audio_c.h" #include "SDL_sysaudio.h" diff --git a/src/audio/dart/SDL_dart.c b/src/audio/dart/SDL_dart.c index cf6e5f689..7d1c1f3cd 100644 --- a/src/audio/dart/SDL_dart.c +++ b/src/audio/dart/SDL_dart.c @@ -22,10 +22,8 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_types.h" #include "SDL_error.h" #include "SDL_timer.h" diff --git a/src/audio/dc/SDL_dcaudio.c b/src/audio/dc/SDL_dcaudio.c index 869d92676..4550df10a 100644 --- a/src/audio/dc/SDL_dcaudio.c +++ b/src/audio/dc/SDL_dcaudio.c @@ -23,10 +23,6 @@ /* Output dreamcast aica */ -#include -#include -#include -#include #include #include #include @@ -34,6 +30,8 @@ #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index c834f5d78..878271ae1 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -25,9 +25,7 @@ /* Output raw audio data to a file. */ -#include #include -#include #include #include #include @@ -36,6 +34,8 @@ #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/dma/SDL_dmaaudio.c b/src/audio/dma/SDL_dmaaudio.c index e04cd4745..3bf9f179f 100644 --- a/src/audio/dma/SDL_dmaaudio.c +++ b/src/audio/dma/SDL_dmaaudio.c @@ -22,9 +22,7 @@ /* Allow access to a raw mixing buffer */ -#include #include -#include #include #include #include @@ -46,6 +44,8 @@ #define MAP_FAILED ((Uint8 *)-1) #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/dmedia/SDL_irixaudio.c b/src/audio/dmedia/SDL_irixaudio.c index a6efe9666..47574f0cd 100644 --- a/src/audio/dmedia/SDL_irixaudio.c +++ b/src/audio/dmedia/SDL_irixaudio.c @@ -23,8 +23,8 @@ /* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */ /* patch for IRIX 5 by Georg Schwarz 18/07/2004 */ -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_timer.h" #include "SDL_audio.h" diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index 714436a31..d1ff4cb5b 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -25,9 +25,7 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include +#include /* For perror() ... should we really do this? */ #include #include #include @@ -43,6 +41,8 @@ #include #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" @@ -303,7 +303,6 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) #endif if ( ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0 ) { perror("SNDCTL_DSP_SETFRAGMENT"); - fprintf(stderr, "Warning: Couldn't set audio fragment size\n"); } #ifdef DEBUG_AUDIO { audio_buf_info info; diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index f1a03ac5e..cb3cdac24 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -24,15 +24,12 @@ #ifdef ESD_SUPPORT -#include -#include -#include #include -#include -#include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" @@ -257,7 +254,7 @@ static char *get_progname(void) FILE *fp; static char temp[BUFSIZ]; - sprintf(temp, "/proc/%d/cmdline", getpid()); + SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid()); fp = fopen(temp, "r"); if ( fp != NULL ) { if ( fgets(temp, sizeof(temp)-1, fp) ) { diff --git a/src/audio/macosx/SDL_coreaudio.c b/src/audio/macosx/SDL_coreaudio.c index 85bd9c6f3..af7fe0823 100644 --- a/src/audio/macosx/SDL_coreaudio.c +++ b/src/audio/macosx/SDL_coreaudio.c @@ -22,11 +22,8 @@ #include -#include -#include -#include -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" @@ -113,8 +110,10 @@ static OSStatus audioCallback (void *inRefCon, /* No SDL conversion should be needed here, ever, since we accept any input format in OpenAudio, and leave the conversion to CoreAudio. */ + /* assert(!this->convert.needed); assert(this->spec.channels == ioData->mNumberChannels); + */ remaining = ioData->mDataByteSize; ptr = ioData->mData; @@ -270,8 +269,7 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec) /* Allocate a sample buffer */ bufferOffset = bufferSize = this->spec.size; buffer = SDL_malloc(bufferSize); - assert(buffer); - + /* Finally, start processing of the audio unit */ result = AudioOutputUnitStart (outputAudioUnit); CHECK_RESULT("AudioOutputUnitStart") diff --git a/src/audio/macrom/SDL_romaudio.c b/src/audio/macrom/SDL_romaudio.c index cf4912bec..4b97b4bc7 100644 --- a/src/audio/macrom/SDL_romaudio.c +++ b/src/audio/macrom/SDL_romaudio.c @@ -30,9 +30,6 @@ # include #endif -#include -#include - #if !defined(NewSndCallBackUPP) && (UNIVERSAL_INTERFACES_VERSION < 0x0335) #if !defined(NewSndCallBackProc) /* avoid circular redefinition... */ #define NewSndCallBackUPP NewSndCallBackProc @@ -42,6 +39,8 @@ #endif #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" @@ -455,7 +454,7 @@ static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) /* allocate the 2 double-back buffers */ for ( i=0; i<2; ++i ) { - audio_buf[i] = calloc(1, sizeof(SndDoubleBuffer)+spec->size); + audio_buf[i] = SDL_calloc(1, sizeof(SndDoubleBuffer)+spec->size); if ( audio_buf[i] == NULL ) { SDL_OutOfMemory(); return(-1); diff --git a/src/audio/mint/SDL_mintaudio_dma8.c b/src/audio/mint/SDL_mintaudio_dma8.c index b7036d6a9..21a1fda78 100644 --- a/src/audio/mint/SDL_mintaudio_dma8.c +++ b/src/audio/mint/SDL_mintaudio_dma8.c @@ -27,15 +27,13 @@ Patrice Mandin */ -#include -#include -#include - /* Mint includes */ #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" diff --git a/src/audio/mint/SDL_mintaudio_gsxb.c b/src/audio/mint/SDL_mintaudio_gsxb.c index 8fbfcb70a..91f4d4178 100644 --- a/src/audio/mint/SDL_mintaudio_gsxb.c +++ b/src/audio/mint/SDL_mintaudio_gsxb.c @@ -27,15 +27,13 @@ Patrice Mandin */ -#include -#include -#include - /* Mint includes */ #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" diff --git a/src/audio/mint/SDL_mintaudio_mcsn.c b/src/audio/mint/SDL_mintaudio_mcsn.c index f8e790c09..e1baa79ce 100644 --- a/src/audio/mint/SDL_mintaudio_mcsn.c +++ b/src/audio/mint/SDL_mintaudio_mcsn.c @@ -27,9 +27,6 @@ Patrice Mandin */ -#include -#include -#include #include /* Mint includes */ @@ -37,6 +34,8 @@ #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" diff --git a/src/audio/mint/SDL_mintaudio_stfa.c b/src/audio/mint/SDL_mintaudio_stfa.c index fcb6e94c8..63dc32562 100644 --- a/src/audio/mint/SDL_mintaudio_stfa.c +++ b/src/audio/mint/SDL_mintaudio_stfa.c @@ -27,15 +27,13 @@ Patrice Mandin */ -#include -#include -#include - /* Mint includes */ #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" diff --git a/src/audio/mint/SDL_mintaudio_xbios.c b/src/audio/mint/SDL_mintaudio_xbios.c index bbd8565e1..191b62b90 100644 --- a/src/audio/mint/SDL_mintaudio_xbios.c +++ b/src/audio/mint/SDL_mintaudio_xbios.c @@ -27,9 +27,6 @@ Patrice Mandin, Didier Méquignon */ -#include -#include -#include #include #include @@ -38,6 +35,8 @@ #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audio_c.h" diff --git a/src/audio/mme/SDL_mmeaudio.c b/src/audio/mme/SDL_mmeaudio.c index 0c60d2155..e6fad1db0 100644 --- a/src/audio/mme/SDL_mmeaudio.c +++ b/src/audio/mme/SDL_mmeaudio.c @@ -91,7 +91,7 @@ static void SetMMerror(char *function, MMRESULT code) int len; char errbuf[MAXERRORLENGTH]; - sprintf(errbuf, "%s: ", function); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); len = SDL_strlen(errbuf); waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len); SDL_SetError("%s",errbuf); diff --git a/src/audio/mme/SDL_mmeaudio.h b/src/audio/mme/SDL_mmeaudio.h index f569528f1..404c21903 100644 --- a/src/audio/mme/SDL_mmeaudio.h +++ b/src/audio/mme/SDL_mmeaudio.h @@ -22,9 +22,6 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include #include #include "SDL_audio.h" diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index 8a1545f4e..b227f2978 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -26,13 +26,11 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include -#include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/nto/SDL_nto_audio.c b/src/audio/nto/SDL_nto_audio.c index 2e9380560..69585a665 100644 --- a/src/audio/nto/SDL_nto_audio.c +++ b/src/audio/nto/SDL_nto_audio.c @@ -20,9 +20,6 @@ slouken@libsdl.org */ -#include -#include -#include #include #include #include @@ -34,6 +31,8 @@ #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/openbsd/SDL_openbsdaudio.c b/src/audio/openbsd/SDL_openbsdaudio.c index a3441a01c..5e61f9af1 100644 --- a/src/audio/openbsd/SDL_openbsdaudio.c +++ b/src/audio/openbsd/SDL_openbsdaudio.c @@ -25,19 +25,17 @@ * vedge@vedge.com.ar. */ -#include -#include -#include #include #include #include -#include #include #include #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index d3c572a33..b175f5610 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -24,9 +24,6 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include #include #include #include @@ -34,6 +31,8 @@ #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audiomem.h" diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 46540312c..1c48edd59 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -22,11 +22,8 @@ /* Allow access to a raw mixing buffer */ -#include -#include #include #include -#include #ifdef __NetBSD__ #include #include @@ -39,6 +36,8 @@ #endif #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_endian.h" #include "SDL_audio.h" #include "SDL_audiomem.h" diff --git a/src/audio/ums/SDL_umsaudio.c b/src/audio/ums/SDL_umsaudio.c index 60cd8bebc..639dc2fa2 100644 --- a/src/audio/ums/SDL_umsaudio.c +++ b/src/audio/ums/SDL_umsaudio.c @@ -24,9 +24,6 @@ /* Allow access to a raw mixing buffer */ -#include -#include -#include #include #include #include @@ -36,6 +33,8 @@ #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_error.h" #include "SDL_audio_c.h" diff --git a/src/audio/windib/SDL_dibaudio.c b/src/audio/windib/SDL_dibaudio.c index eb63feff1..2e0afaedd 100644 --- a/src/audio/windib/SDL_dibaudio.c +++ b/src/audio/windib/SDL_dibaudio.c @@ -25,11 +25,11 @@ #include "SDL_windows.h" #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_audio.h" #include "SDL_mutex.h" #include "SDL_timer.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_audio_c.h" #include "SDL_dibaudio.h" #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) diff --git a/src/audio/windx5/SDL_dx5audio.c b/src/audio/windx5/SDL_dx5audio.c index bc9f555fd..a75cb64a9 100644 --- a/src/audio/windx5/SDL_dx5audio.c +++ b/src/audio/windx5/SDL_dx5audio.c @@ -22,12 +22,12 @@ /* Allow access to a raw mixing buffer */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_types.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_audio.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_audio_c.h" #include "SDL_dx5audio.h" diff --git a/src/cdrom/SDL_cdrom.c b/src/cdrom/SDL_cdrom.c index 8411251bf..b9c8625d3 100644 --- a/src/cdrom/SDL_cdrom.c +++ b/src/cdrom/SDL_cdrom.c @@ -22,10 +22,10 @@ /* This is the CD-audio control API for Simple DirectMedia Layer */ -#include "SDL_error.h" -#include "SDL_cdrom.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_cdrom.h" #include "SDL_syscdrom.h" #if !defined(macintosh) diff --git a/src/cdrom/aix/SDL_syscdrom.c b/src/cdrom/aix/SDL_syscdrom.c index b072d2fd4..00c0013c0 100644 --- a/src/cdrom/aix/SDL_syscdrom.c +++ b/src/cdrom/aix/SDL_syscdrom.c @@ -27,11 +27,8 @@ #define DEBUG_CDROM 1 #include -#include #include #include -#include -#include #include #include @@ -43,6 +40,8 @@ #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" diff --git a/src/cdrom/beos/SDL_syscdrom.cc b/src/cdrom/beos/SDL_syscdrom.cc index ce3da7526..5f9c3ebee 100644 --- a/src/cdrom/beos/SDL_syscdrom.cc +++ b/src/cdrom/beos/SDL_syscdrom.cc @@ -25,10 +25,7 @@ */ #include -#include #include -#include -#include #include #include @@ -36,6 +33,8 @@ #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" extern "C" { diff --git a/src/cdrom/bsdi/SDL_syscdrom.c b/src/cdrom/bsdi/SDL_syscdrom.c index c621d9519..602ad7c65 100644 --- a/src/cdrom/bsdi/SDL_syscdrom.c +++ b/src/cdrom/bsdi/SDL_syscdrom.c @@ -29,18 +29,16 @@ */ #include -#include #include #include -#include -#include -#include #include #include #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" @@ -303,7 +301,7 @@ int SDL_SYS_CDInit(void) char *insert; exists = 1; for ( j=checklist[i][1]; exists; ++j ) { - sprintf(drive, "/dev/%sc", &checklist[i][3]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc", &checklist[i][3]); insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; @@ -323,7 +321,7 @@ int SDL_SYS_CDInit(void) } } } else { - sprintf(drive, "/dev/%s", checklist[i]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]); if ( CheckDrive(drive, &stbuf) > 0 ) { AddDrive(drive, &stbuf); } diff --git a/src/cdrom/dc/SDL_syscdrom.c b/src/cdrom/dc/SDL_syscdrom.c index 0184c3dcd..64bee2016 100644 --- a/src/cdrom/dc/SDL_syscdrom.c +++ b/src/cdrom/dc/SDL_syscdrom.c @@ -22,8 +22,6 @@ /* Functions for system-level CD-ROM audio control */ -#include -#include #include #include diff --git a/src/cdrom/freebsd/SDL_syscdrom.c b/src/cdrom/freebsd/SDL_syscdrom.c index 7f17cd829..5154d25d1 100644 --- a/src/cdrom/freebsd/SDL_syscdrom.c +++ b/src/cdrom/freebsd/SDL_syscdrom.c @@ -23,15 +23,14 @@ /* Functions for system-level CD-ROM audio control */ #include -#include #include #include -#include -#include #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" @@ -189,7 +188,7 @@ int SDL_SYS_CDInit(void) char *insert; exists = 1; for ( j=checklist[i][1]; exists; ++j ) { - sprintf(drive, "/dev/%sc", &checklist[i][3]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc", &checklist[i][3]); insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; @@ -209,7 +208,7 @@ int SDL_SYS_CDInit(void) } } } else { - sprintf(drive, "/dev/%s", checklist[i]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]); if ( CheckDrive(drive, &stbuf) > 0 ) { AddDrive(drive, &stbuf); } diff --git a/src/cdrom/linux/SDL_syscdrom.c b/src/cdrom/linux/SDL_syscdrom.c index 558ab4795..325368105 100644 --- a/src/cdrom/linux/SDL_syscdrom.c +++ b/src/cdrom/linux/SDL_syscdrom.c @@ -23,12 +23,9 @@ /* Functions for system-level CD-ROM audio control */ #include -#include #include #include #include -#include -#include #include #include #ifdef __linux__ @@ -83,6 +80,8 @@ #endif #endif /* USE_MNTENT */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" @@ -336,7 +335,7 @@ int SDL_SYS_CDInit(void) char *insert; exists = 1; for ( j=checklist[i][1]; exists; ++j ) { - sprintf(drive, "/dev/%s", &checklist[i][3]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", &checklist[i][3]); insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; @@ -359,7 +358,7 @@ int SDL_SYS_CDInit(void) } } } else { - sprintf(drive, "/dev/%s", checklist[i]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]); #ifdef DEBUG_CDROM fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive); #endif diff --git a/src/cdrom/macosx/AudioFileReaderThread.c b/src/cdrom/macosx/AudioFileReaderThread.c index ef56b5ed0..cfd6ff017 100644 --- a/src/cdrom/macosx/AudioFileReaderThread.c +++ b/src/cdrom/macosx/AudioFileReaderThread.c @@ -546,7 +546,7 @@ void delete_AudioFileManager (AudioFileManager *afm) { if (afm != NULL) { if (afm->mFileBuffer) { - free (afm->mFileBuffer); + free(afm->mFileBuffer); } SDL_free(afm); @@ -594,7 +594,7 @@ AudioFileManager *new_AudioFileManager(AudioFilePlayer *inParent, afm->mBufferOffset = inChunkSize; afm->mChunkSize = inChunkSize; afm->mFileLength = inFileLength; - afm->mFileBuffer = (char*) malloc (afm->mChunkSize * 2); + afm->mFileBuffer = (char*) SDL_malloc(afm->mChunkSize * 2); FSGetForkPosition(afm->mForkRefNum, &afm->mAudioDataOffset); assert (afm->mFileBuffer != NULL); return afm; diff --git a/src/cdrom/macosx/SDLOSXCAGuard.c b/src/cdrom/macosx/SDLOSXCAGuard.c index 7a8105c9a..163a1ef4d 100644 --- a/src/cdrom/macosx/SDLOSXCAGuard.c +++ b/src/cdrom/macosx/SDLOSXCAGuard.c @@ -68,12 +68,19 @@ // Includes //============================================================================= +/* #include #include #include +*/ +#include "SDL_stdlib.h" +#include "SDL_string.h" //#define NDEBUG 1 +/* #include +*/ +#define assert(X) #include "SDLOSXCAGuard.h" diff --git a/src/cdrom/macosx/SDL_syscdrom.c b/src/cdrom/macosx/SDL_syscdrom.c index 2dc5a2bcc..098bba527 100644 --- a/src/cdrom/macosx/SDL_syscdrom.c +++ b/src/cdrom/macosx/SDL_syscdrom.c @@ -58,7 +58,7 @@ static int LoadTracks (SDL_CD *cdrom) return 0; /* Allocate memory for tracks */ - tracks[cdrom->id] = (FSRef*) calloc (1, sizeof(**tracks) * cdrom->numtracks); + tracks[cdrom->id] = (FSRef*) SDL_calloc (1, sizeof(**tracks) * cdrom->numtracks); if (tracks[cdrom->id] == NULL) { SDL_OutOfMemory (); return -1; @@ -203,14 +203,14 @@ int SDL_SYS_CDInit (void) } /* Allocate space for volumes */ - volumes = (FSVolumeRefNum*) calloc (1, sizeof(*volumes) * SDL_numcds); + volumes = (FSVolumeRefNum*) SDL_calloc (1, sizeof(*volumes) * SDL_numcds); if (volumes == NULL) { SDL_OutOfMemory (); return -1; } /* Allocate space for tracks */ - tracks = (FSRef**) calloc (1, sizeof(*tracks) * (SDL_numcds + 1)); + tracks = (FSRef**) SDL_calloc (1, sizeof(*tracks) * (SDL_numcds + 1)); if (tracks == NULL) { SDL_OutOfMemory (); return -1; diff --git a/src/cdrom/mint/SDL_syscdrom.c b/src/cdrom/mint/SDL_syscdrom.c index 578f2cf1e..78138eaa1 100644 --- a/src/cdrom/mint/SDL_syscdrom.c +++ b/src/cdrom/mint/SDL_syscdrom.c @@ -27,9 +27,6 @@ */ #include -#include -#include -#include #include #include diff --git a/src/cdrom/openbsd/SDL_syscdrom.c b/src/cdrom/openbsd/SDL_syscdrom.c index 76c50c84f..5c57fadc4 100644 --- a/src/cdrom/openbsd/SDL_syscdrom.c +++ b/src/cdrom/openbsd/SDL_syscdrom.c @@ -24,16 +24,15 @@ #include #include -#include #include #include -#include -#include #include #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" @@ -198,7 +197,7 @@ int SDL_SYS_CDInit(void) char *insert; exists = 1; for ( j=checklist[i][1]; exists; ++j ) { - sprintf(drive, "/dev/%s", &checklist[i][3]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", &checklist[i][3]); insert = SDL_strchr(drive, '?'); if ( insert != NULL ) { *insert = j; @@ -218,7 +217,7 @@ int SDL_SYS_CDInit(void) } } } else { - sprintf(drive, "/dev/%s", checklist[i]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]); if ( CheckDrive(drive, &stbuf) > 0 ) { AddDrive(drive, &stbuf); } diff --git a/src/cdrom/os2/SDL_syscdrom.c b/src/cdrom/os2/SDL_syscdrom.c index c525ed3cd..c1922a004 100644 --- a/src/cdrom/os2/SDL_syscdrom.c +++ b/src/cdrom/os2/SDL_syscdrom.c @@ -25,10 +25,9 @@ #define INCL_MCIOS2 #include #include -#include -#include -#include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" diff --git a/src/cdrom/osf/SDL_syscdrom.c b/src/cdrom/osf/SDL_syscdrom.c index 250b9568a..930de4e04 100644 --- a/src/cdrom/osf/SDL_syscdrom.c +++ b/src/cdrom/osf/SDL_syscdrom.c @@ -31,12 +31,9 @@ #include #include #include -#include -#include -#include -#include -#include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" @@ -218,7 +215,7 @@ int SDL_SYS_CDInit(void) while (devent = readdir(devdir)) if (SDL_memcmp(checklist[i].name, devent->d_name, name_len) == 0) if (devent->d_name[devent->d_namlen-1] == 'c') { - sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name); + SDL_snprintf(drive, SDL_arraysize(drive), "%s/%s", checklist[i].dir, devent->d_name); #ifdef DEBUG_CDROM fprintf(stderr, "Try to add drive: %s\n", drive); #endif diff --git a/src/cdrom/qnx/SDL_syscdrom.c b/src/cdrom/qnx/SDL_syscdrom.c index e6a288d73..8dc5bd520 100644 --- a/src/cdrom/qnx/SDL_syscdrom.c +++ b/src/cdrom/qnx/SDL_syscdrom.c @@ -23,17 +23,16 @@ /* Functions for system-level CD-ROM audio control */ #include -#include #include #include #include -#include #include -#include #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_timer.h" @@ -218,7 +217,7 @@ int SDL_SYS_CDInit(void) for ( j=checklist[i][1]; exists; ++j ) { - sprintf(drive, "/dev/%s", &checklist[i][3]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", &checklist[i][3]); insert = SDL_strchr(drive, '?'); if (insert != NULL) { @@ -242,7 +241,7 @@ int SDL_SYS_CDInit(void) } else { - sprintf(drive, "/dev/%s", checklist[i]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", checklist[i]); if (CheckDrive(drive, &stbuf) > 0) { AddDrive(drive, &stbuf); diff --git a/src/cdrom/win32/SDL_syscdrom.c b/src/cdrom/win32/SDL_syscdrom.c index 30d92f597..4f70a72ce 100644 --- a/src/cdrom/win32/SDL_syscdrom.c +++ b/src/cdrom/win32/SDL_syscdrom.c @@ -25,10 +25,10 @@ #include "SDL_windows.h" #include -#include "SDL_error.h" -#include "SDL_cdrom.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_cdrom.h" #include "SDL_syscdrom.h" /* This really broken?? */ diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 9f9f73a4e..f591eae6b 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -24,10 +24,10 @@ data sources. It can easily be extended to files, memory, etc. */ -#include "SDL_error.h" -#include "SDL_rwops.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_rwops.h" #ifdef HAVE_STDIO_H diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 952c5ddcc..0d590255e 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -22,10 +22,10 @@ /* This is the joystick API for Simple DirectMedia Layer */ -#include "SDL_error.h" -#include "SDL_events.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_events.h" #ifndef DISABLE_EVENTS #include "SDL_events_c.h" #endif diff --git a/src/joystick/amigaos/SDL_sysjoystick.c b/src/joystick/amigaos/SDL_sysjoystick.c index ad59d7857..650d71b9d 100644 --- a/src/joystick/amigaos/SDL_sysjoystick.c +++ b/src/joystick/amigaos/SDL_sysjoystick.c @@ -23,8 +23,6 @@ /* This is the system specific header for the SDL joystick API */ -#include /* For the definition of NULL */ - #include #if defined(__SASC) || defined(STORMC4_WOS) #include @@ -39,8 +37,8 @@ extern struct ExecBase *SysBase; extern struct GfxBase *GfxBase; -#include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_joystick.h" #include "SDL_sysjoystick.h" diff --git a/src/joystick/beos/SDL_bejoystick.cc b/src/joystick/beos/SDL_bejoystick.cc index 13a6fe7e5..d958e06d2 100644 --- a/src/joystick/beos/SDL_bejoystick.cc +++ b/src/joystick/beos/SDL_bejoystick.cc @@ -22,15 +22,13 @@ /* This is the system specific header for the SDL joystick API */ -#include -#include -#include - #include #include extern "C" { +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_joystick.h" #include "SDL_sysjoystick.h" diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index d224a21fa..92dcc35fd 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -29,11 +29,8 @@ #include -#include -#include #include #include -#include #include #if defined(HAVE_USB_H) @@ -59,6 +56,8 @@ #include #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_joystick.h" #include "SDL_sysjoystick.h" @@ -145,7 +144,7 @@ SDL_SYS_JoystickInit(void) for (i = 0; i < MAX_UHID_JOYS; i++) { SDL_Joystick nj; - sprintf(s, "/dev/uhid%d", i); + SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i); nj.index = SDL_numjoysticks; joynames[nj.index] = strdup(s); @@ -159,7 +158,7 @@ SDL_SYS_JoystickInit(void) } } for (i = 0; i < MAX_JOY_JOYS; i++) { - sprintf(s, "/dev/joy%d", i); + SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i); fd = open(s, O_RDONLY); if (fd != -1) { joynames[SDL_numjoysticks++] = strdup(s); @@ -312,7 +311,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy) case HUG_GAME_PAD: s = hid_usage_in_page(hitem.usage); sp = SDL_malloc(SDL_strlen(s) + 5); - sprintf(sp, "%s (%d)", s, + SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)", s, joy->index); joydevnames[joy->index] = sp; } diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index 67c317a7b..0aa470155 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -23,11 +23,8 @@ /* SDL joystick driver for Darwin / MacOS X, based on the IOKit HID API */ /* Written 2001 by Max Horn */ -#include -#include #include #include -#include #include #include #include diff --git a/src/joystick/dc/SDL_sysjoystick.c b/src/joystick/dc/SDL_sysjoystick.c index 3b3f70eff..001da769c 100644 --- a/src/joystick/dc/SDL_sysjoystick.c +++ b/src/joystick/dc/SDL_sysjoystick.c @@ -22,9 +22,8 @@ /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */ -#include -#include /* For the definition of NULL */ - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_joystick.h" #include "SDL_sysjoystick.h" diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index fcb9a0b47..770c57e75 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -22,9 +22,6 @@ /* This is the system specific header for the SDL joystick API */ -#include /* For the definition of NULL */ -#include /* For SDL_getenv() prototype */ -#include #include #include #include @@ -38,6 +35,8 @@ #include #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_joystick.h" #include "SDL_sysjoystick.h" @@ -325,7 +324,7 @@ int SDL_SYS_JoystickInit(void) for ( i=0; i -#include -#include - #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_types.h" #include "SDL_error.h" #include "SDL_joystick.h" diff --git a/src/joystick/os2/SDL_sysjoystick.c b/src/joystick/os2/SDL_sysjoystick.c index 11181fd2f..57da3b29f 100644 --- a/src/joystick/os2/SDL_sysjoystick.c +++ b/src/joystick/os2/SDL_sysjoystick.c @@ -22,8 +22,6 @@ /* OS/2 Joystick driver, contributed by Daniel Caetano */ -#include -#include #include #define INCL_DOSDEVICES @@ -32,6 +30,8 @@ #include #include "joyos2.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_joystick.h" #include "SDL_sysjoystick.h" @@ -217,7 +217,7 @@ if (numdevs > 0) if (joycfg.buttons>=7) SYS_JoyData[0].buttoncalc[2]=((axis[2]->upper+axis[3]->centre)>>1); if (joycfg.buttons>=8) SYS_JoyData[0].buttoncalc[3]=((axis[3]->upper+axis[3]->centre)>>1); /* Intialize Joystick Name */ - strcpy (SYS_JoyData[0].szDeviceName,joycfg.name); + SDL_strcpy (SYS_JoyData[0].szDeviceName,joycfg.name); } /* Default Init ... autoconfig */ else @@ -294,7 +294,8 @@ if (numdevs > 0) } /* Hack to define Joystick Port Names */ if ( numdevs > maxdevs ) numdevs = maxdevs; - for (i=0; i /* For the definition of NULL */ -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_joystick.h" #include "SDL_sysjoystick.h" diff --git a/src/joystick/win32/SDL_mmjoystick.c b/src/joystick/win32/SDL_mmjoystick.c index e4b5b4af3..532b571c0 100644 --- a/src/joystick/win32/SDL_mmjoystick.c +++ b/src/joystick/win32/SDL_mmjoystick.c @@ -22,11 +22,11 @@ /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_events.h" #include "SDL_joystick.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_sysjoystick.h" #include "SDL_joystick_c.h" diff --git a/src/loadso/macosx/SDL_loadso.c b/src/loadso/macosx/SDL_loadso.c index 776c7f233..2d1fac22a 100644 --- a/src/loadso/macosx/SDL_loadso.c +++ b/src/loadso/macosx/SDL_loadso.c @@ -62,9 +62,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include -#include -#include -#include #include #include #include @@ -73,6 +70,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" + /* Just playing to see if it would compile with the freebsd headers, it does, * but because of the different values for RTLD_LOCAL etc, it would break binary * compat... oh well @@ -390,14 +390,14 @@ static const char *getSearchPath(int i) } if (!path) { - path = (char **)calloc(MAX_SEARCH_PATHS, sizeof(char **)); + path = (char **)SDL_calloc(MAX_SEARCH_PATHS, sizeof(char **)); } if (!list && !end) list = searchList(); if (i >= (numsize)) { debug("Increasing size for long PATH"); - tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **)); + tmp = (char **)SDL_calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **)); if (tmp) { SDL_memcpy(tmp, path, sizeof(char **) * numsize); @@ -515,7 +515,7 @@ static struct dlstatus *allocStatus() dls = dls->next; if (!dls) #endif - dls = calloc(sizeof(*dls),1); + dls = SDL_calloc(sizeof(*dls),1); return dls; } @@ -1017,7 +1017,7 @@ static void *SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict s malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { - sprintf(malloc_sym, "_%s", symbol); + SDL_sprintf(malloc_sym, sym_len+2, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); SDL_free(malloc_sym); } @@ -1062,7 +1062,7 @@ static void *dlsym_prepend_underscore_intern(void *handle, const char *symbol) malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { - sprintf(malloc_sym, "_%s", symbol); + SDL_snprintf(malloc_sym, sym_len+2, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); SDL_free(malloc_sym); } @@ -1347,7 +1347,7 @@ static dlfunc_t SDL_OSX_dlfunc(void * dl_restrict handle, const char * dl_restri malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { - sprintf(malloc_sym, "_%s", symbol); + SDL_snprintf(malloc_sym, sym_len+2, "_%s", symbol); rv.d = dlsymIntern(handle, malloc_sym, 1); SDL_free(malloc_sym); } diff --git a/src/main/beos/SDL_BeApp.cc b/src/main/beos/SDL_BeApp.cc index 77c4d2b60..7f3b9a5c2 100644 --- a/src/main/beos/SDL_BeApp.cc +++ b/src/main/beos/SDL_BeApp.cc @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include #include "SDL_BeApp.h" diff --git a/src/main/macos/SDL_main.c b/src/main/macos/SDL_main.c index a2ce3b4fc..2e745a6a4 100644 --- a/src/main/macos/SDL_main.c +++ b/src/main/macos/SDL_main.c @@ -589,7 +589,7 @@ int main(int argc, char *argv[]) /* Parse C-string into argv and argc */ nargs = ParseCommandLine (commandLine, NULL); - args = (char **)SDL_malloc((nargs+1)*(sizeof *args)); + args = (char **)malloc((nargs+1)*(sizeof *args)); if ( args == NULL ) { exit(-1); } diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index d33807f3c..3aec83c61 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -29,19 +29,14 @@ #ifndef HAVE_MALLOC #define LACKS_STDIO_H -#define LACKS_UNISTD_H -#define LACKS_FCNTL_H -#define LACKS_SYS_PARAM_H -#define LACKS_SYS_MMAN_H #define LACKS_STRINGS_H #define LACKS_STRING_H -#define LACKS_SYS_TYPES_H -#define LACKS_ERRNO_H #define LACKS_STDLIB_H #define ABORT #define memset SDL_memset #define memcpy SDL_memcpy #define malloc SDL_malloc +#define calloc SDL_calloc #define realloc SDL_realloc #define free SDL_free diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index e15718e97..7f2b29c69 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -343,7 +343,8 @@ char *SDL_strupr(char *string) { char *bufp = string; while ( *bufp ) { - *bufp++ = toupper(*bufp); + *bufp = toupper(*bufp); + ++bufp; } return string; } @@ -354,7 +355,8 @@ char *SDL_strlwr(char *string) { char *bufp = string; while ( *bufp ) { - *bufp++ = tolower(*bufp); + *bufp = tolower(*bufp); + ++bufp; } return string; } @@ -367,6 +369,7 @@ char *SDL_strchr(const char *string, int c) if ( *string == c ) { return (char *)string; } + ++string; } return NULL; } @@ -380,6 +383,7 @@ char *SDL_strrchr(const char *string, int c) if ( *bufp == c ) { return (char *)bufp; } + --bufp; } return NULL; } @@ -393,6 +397,7 @@ char *SDL_strstr(const char *haystack, const char *needle) if ( SDL_strncmp(haystack, needle, length) == 0 ) { return (char *)haystack; } + ++haystack; } return NULL; } diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index a8982b4ca..b763466f0 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -22,11 +22,11 @@ /* System independent thread management routines for SDL */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_mutex.h" #include "SDL_thread.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_thread_c.h" #include "SDL_systhread.h" diff --git a/src/thread/amigaos/SDL_systhread.c b/src/thread/amigaos/SDL_systhread.c index e7c4af59a..722588f7a 100644 --- a/src/thread/amigaos/SDL_systhread.c +++ b/src/thread/amigaos/SDL_systhread.c @@ -102,7 +102,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) D(bug("Sending %lx to the new thread...\n",args)); if(args) - sprintf(buffer,"%ld",args); + SDL_snprintf(buffer, SDL_arraysize(buffer),"%ld",args); #ifdef STORMC4_WOS thread->handle=CreateTaskPPCTags(TASKATTR_CODE, RunThread, diff --git a/src/thread/amigaos/SDL_systhread_c.h b/src/thread/amigaos/SDL_systhread_c.h index 1f1f18dc9..0603a5b48 100644 --- a/src/thread/amigaos/SDL_systhread_c.h +++ b/src/thread/amigaos/SDL_systhread_c.h @@ -31,9 +31,6 @@ #include #endif -#include -#include -#include #include "mydebug.h" extern struct ExecBase *SysBase; diff --git a/src/thread/amigaos/SDL_thread.c b/src/thread/amigaos/SDL_thread.c index ba8a4c0bd..2f7332f3b 100644 --- a/src/thread/amigaos/SDL_thread.c +++ b/src/thread/amigaos/SDL_thread.c @@ -22,10 +22,8 @@ /* System independent thread management routines for SDL */ -#include -#include -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_mutex.h" #include "SDL_thread.h" diff --git a/src/thread/bsdi/SDL_syssem.c b/src/thread/bsdi/SDL_syssem.c index 02a18e363..8b663cdd5 100644 --- a/src/thread/bsdi/SDL_syssem.c +++ b/src/thread/bsdi/SDL_syssem.c @@ -20,15 +20,13 @@ slouken@libsdl.org */ -#include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_timer.h" #ifdef SDL_USE_PTHREADS -#include -#include #include /* For getpid() */ #include diff --git a/src/thread/dc/SDL_syscond.c b/src/thread/dc/SDL_syscond.c index c188acfc1..062d7e3dd 100644 --- a/src/thread/dc/SDL_syscond.c +++ b/src/thread/dc/SDL_syscond.c @@ -26,9 +26,7 @@ implementation, written by Christopher Tate and Owen Smith. Thanks! */ -#include -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" diff --git a/src/thread/dc/SDL_sysmutex.c b/src/thread/dc/SDL_sysmutex.c index 2b7af1c5a..165b63fd3 100644 --- a/src/thread/dc/SDL_sysmutex.c +++ b/src/thread/dc/SDL_sysmutex.c @@ -22,9 +22,7 @@ /* An implementation of mutexes using semaphores */ -#include -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_systhread_c.h" diff --git a/src/thread/dc/SDL_syssem.c b/src/thread/dc/SDL_syssem.c index c8171ead1..a56efbc7b 100644 --- a/src/thread/dc/SDL_syssem.c +++ b/src/thread/dc/SDL_syssem.c @@ -22,8 +22,6 @@ /* An implementation of semaphores using mutexes and condition variables */ -#include - #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_thread.h" diff --git a/src/thread/epoc/SDL_sysmutex.cpp b/src/thread/epoc/SDL_sysmutex.cpp index c63cc96d1..fdbb8451b 100644 --- a/src/thread/epoc/SDL_sysmutex.cpp +++ b/src/thread/epoc/SDL_sysmutex.cpp @@ -29,9 +29,6 @@ /* Mutex functions using the Win32 API */ -//#include -//#include - #include #include "SDL_error.h" diff --git a/src/thread/epoc/SDL_syssem.cpp b/src/thread/epoc/SDL_syssem.cpp index cd7d53955..65b82a13c 100644 --- a/src/thread/epoc/SDL_syssem.cpp +++ b/src/thread/epoc/SDL_syssem.cpp @@ -28,8 +28,6 @@ /* Semaphore functions using the Win32 API */ -//#include -//#include #include #include "SDL_error.h" diff --git a/src/thread/epoc/SDL_systhread.cpp b/src/thread/epoc/SDL_systhread.cpp index 950d0d040..dad59955c 100644 --- a/src/thread/epoc/SDL_systhread.cpp +++ b/src/thread/epoc/SDL_systhread.cpp @@ -28,10 +28,6 @@ */ -//#include -//#include - - extern "C" { #undef NULL #include "SDL_error.h" diff --git a/src/thread/generic/SDL_syscond.c b/src/thread/generic/SDL_syscond.c index ffd5c5650..062d7e3dd 100644 --- a/src/thread/generic/SDL_syscond.c +++ b/src/thread/generic/SDL_syscond.c @@ -26,9 +26,9 @@ implementation, written by Christopher Tate and Owen Smith. Thanks! */ +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" -#include "SDL_stdlib.h" struct SDL_cond { diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index b46c5a2c5..8d1ee1ba7 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -22,9 +22,9 @@ /* An implementation of mutexes using semaphores */ +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" -#include "SDL_stdlib.h" #include "SDL_systhread_c.h" diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index 6312d034d..f6a8bb575 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -22,10 +22,10 @@ /* An implementation of semaphores using mutexes and condition variables */ +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_thread.h" -#include "SDL_stdlib.h" #include "SDL_systhread_c.h" diff --git a/src/thread/irix/SDL_systhread.c b/src/thread/irix/SDL_systhread.c index 240d51638..5f450e9cf 100644 --- a/src/thread/irix/SDL_systhread.c +++ b/src/thread/irix/SDL_systhread.c @@ -22,7 +22,6 @@ /* IRIX thread management routines for SDL */ -#include #include #include #include diff --git a/src/thread/linux/SDL_syscond.c b/src/thread/linux/SDL_syscond.c index 9aaa21ce8..5417d1d80 100644 --- a/src/thread/linux/SDL_syscond.c +++ b/src/thread/linux/SDL_syscond.c @@ -40,9 +40,9 @@ #include #include #include -#include #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_sysmutex_c.h" diff --git a/src/thread/linux/SDL_sysmutex.c b/src/thread/linux/SDL_sysmutex.c index d41f20639..fe9aba507 100644 --- a/src/thread/linux/SDL_sysmutex.c +++ b/src/thread/linux/SDL_sysmutex.c @@ -37,10 +37,9 @@ #ifdef SDL_USE_PTHREADS -#include -#include #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" @@ -59,7 +58,7 @@ SDL_mutex *SDL_CreateMutex (void) pthread_mutexattr_t attr; /* Allocate the structure */ - mutex = (SDL_mutex *)calloc(1, sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex)); if ( mutex ) { pthread_mutexattr_init(&attr); #if defined(PTHREAD_RECURSIVE_MUTEX) diff --git a/src/thread/linux/SDL_syssem.c b/src/thread/linux/SDL_syssem.c index 0e4896bfa..86c583ba8 100644 --- a/src/thread/linux/SDL_syssem.c +++ b/src/thread/linux/SDL_syssem.c @@ -20,7 +20,7 @@ slouken@libsdl.org */ -#include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_timer.h" @@ -46,9 +46,6 @@ #include "generic/SDL_syssem.c" #else -#include -#include -#include /* For getpid() */ #include #include @@ -74,7 +71,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) static int semnum = 0; char name[32]; - sprintf(name, "/SDL_sem-%d-%4.4d", getpid(), semnum++); + SDL_snprintf(name, SDL_arraysize(name), "/SDL_sem-%d-%4.4d", getpid(), semnum++); sem->sem = sem_open(name, O_CREAT, 0600, initial_value); if ( sem->sem == (sem_t *)SEM_FAILED ) { SDL_SetError("sem_open(%s) failed", name); diff --git a/src/thread/linux/SDL_systhread.c b/src/thread/linux/SDL_systhread.c index 7ed5833fe..7dc354e66 100644 --- a/src/thread/linux/SDL_systhread.c +++ b/src/thread/linux/SDL_systhread.c @@ -22,6 +22,7 @@ /* Linux thread management routines for SDL */ +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_systhread.h" @@ -138,7 +139,6 @@ void SDL_SYS_KillThread(SDL_Thread *thread) #else /* Linux-specific clone() based implementation */ -#include #include #include #include @@ -227,7 +227,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread) */ char command[1024]; - sprintf(command, + SDL_snprintf(command, SDL_arraysize(command), "ps ax|fgrep -v fgrep|fgrep -v ''|fgrep %d >/dev/null", thread->handle); while ( system(command) == 0 ) diff --git a/src/thread/os2/SDL_syscond.c b/src/thread/os2/SDL_syscond.c index e4d5b697b..da833d5eb 100644 --- a/src/thread/os2/SDL_syscond.c +++ b/src/thread/os2/SDL_syscond.c @@ -26,9 +26,7 @@ implementation, written by Christopher Tate and Owen Smith. Thanks! */ -#include -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" diff --git a/src/thread/os2/SDL_sysmutex.c b/src/thread/os2/SDL_sysmutex.c index aa53461ae..2c9003b4e 100644 --- a/src/thread/os2/SDL_sysmutex.c +++ b/src/thread/os2/SDL_sysmutex.c @@ -22,12 +22,11 @@ /* Mutex functions using the OS/2 API */ -#include -#include #define INCL_DOSERRORS #define INCL_DOSSEMAPHORES #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_mutex.h" diff --git a/src/thread/os2/SDL_syssem.c b/src/thread/os2/SDL_syssem.c index 8122dd7b3..565c966f1 100644 --- a/src/thread/os2/SDL_syssem.c +++ b/src/thread/os2/SDL_syssem.c @@ -22,13 +22,12 @@ /* Semaphore functions using the OS/2 API */ -#include -#include #define INCL_DOS #define INCL_DOSERRORS #define INCL_DOSSEMAPHORES #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_timer.h" diff --git a/src/thread/os2/SDL_systhread.c b/src/thread/os2/SDL_systhread.c index 4da82f1b5..78a3925f8 100644 --- a/src/thread/os2/SDL_systhread.c +++ b/src/thread/os2/SDL_systhread.c @@ -22,13 +22,12 @@ /* OS/2 thread management routines for SDL */ -#include -#include #include #define INCL_DOSERRORS #define INCL_DOSPROCESS #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_systhread.h" diff --git a/src/thread/pth/SDL_syscond.c b/src/thread/pth/SDL_syscond.c index bb1d62b95..f0480b710 100644 --- a/src/thread/pth/SDL_syscond.c +++ b/src/thread/pth/SDL_syscond.c @@ -4,10 +4,9 @@ * Patrice Mandin */ -#include -#include #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_syscond_c.h" diff --git a/src/thread/pth/SDL_sysmutex.c b/src/thread/pth/SDL_sysmutex.c index d21e0926a..a3ab3ea38 100644 --- a/src/thread/pth/SDL_sysmutex.c +++ b/src/thread/pth/SDL_sysmutex.c @@ -4,10 +4,9 @@ * Patrice Mandin */ -#include -#include #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_mutex.h" #include "SDL_sysmutex_c.h" diff --git a/src/thread/riscos/SDL_syscond.c b/src/thread/riscos/SDL_syscond.c index bc39dd18d..462f3536a 100644 --- a/src/thread/riscos/SDL_syscond.c +++ b/src/thread/riscos/SDL_syscond.c @@ -27,10 +27,9 @@ #else #include #include -#include -#include #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" #include "SDL_sysmutex_c.h" diff --git a/src/thread/riscos/SDL_sysmutex.c b/src/thread/riscos/SDL_sysmutex.c index 00589efe2..c5e023ece 100644 --- a/src/thread/riscos/SDL_sysmutex.c +++ b/src/thread/riscos/SDL_sysmutex.c @@ -26,10 +26,9 @@ #include "../generic/SDL_sysmutex.c" #else -#include -#include #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" @@ -47,7 +46,7 @@ SDL_mutex *SDL_CreateMutex (void) pthread_mutexattr_t attr; /* Allocate the structure */ - mutex = (SDL_mutex *)calloc(1, sizeof(*mutex)); + mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex)); if ( mutex ) { pthread_mutexattr_init(&attr); #ifdef PTHREAD_NO_RECURSIVE_MUTEX diff --git a/src/thread/riscos/SDL_syssem.c b/src/thread/riscos/SDL_syssem.c index 7c8bd01d0..d7a5dad6f 100644 --- a/src/thread/riscos/SDL_syssem.c +++ b/src/thread/riscos/SDL_syssem.c @@ -23,12 +23,10 @@ /* RISC OS semiphores based on linux code */ -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_thread.h" - #include "SDL_systhread_c.h" #ifdef DISABLE_THREADS @@ -76,8 +74,6 @@ int SDL_SemPost(SDL_sem *sem) #else -#include -#include #include /* For getpid() */ #include #include diff --git a/src/thread/win32/SDL_sysmutex.c b/src/thread/win32/SDL_sysmutex.c index 13c357e23..b7bf77513 100644 --- a/src/thread/win32/SDL_sysmutex.c +++ b/src/thread/win32/SDL_sysmutex.c @@ -24,9 +24,9 @@ #include "SDL_windows.h" +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_mutex.h" -#include "SDL_stdlib.h" struct SDL_mutex { diff --git a/src/thread/win32/SDL_syssem.c b/src/thread/win32/SDL_syssem.c index ef42fae45..ef3e4aaac 100644 --- a/src/thread/win32/SDL_syssem.c +++ b/src/thread/win32/SDL_syssem.c @@ -24,9 +24,9 @@ #include "SDL_windows.h" +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" -#include "SDL_stdlib.h" #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) #include "win_ce_semaphore.h" #endif diff --git a/src/thread/win32/SDL_systhread.c b/src/thread/win32/SDL_systhread.c index cb9bb478a..74239a7d3 100644 --- a/src/thread/win32/SDL_systhread.c +++ b/src/thread/win32/SDL_systhread.c @@ -24,9 +24,9 @@ #include "SDL_windows.h" +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_thread.h" -#include "SDL_stdlib.h" #include "SDL_systhread.h" typedef struct ThreadStartParms diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index debb028ef..3e876882c 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -20,9 +20,9 @@ slouken@libsdl.org */ +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_timer.h" -#include "SDL_stdlib.h" #include "SDL_timer_c.h" #include "SDL_mutex.h" #include "SDL_systimer.h" diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 91f70674e..896208d42 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -86,10 +86,10 @@ */ #include "SDL_types.h" -#include "SDL_video.h" -#include "SDL_error.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_video.h" +#include "SDL_error.h" #include "SDL_sysvideo.h" #include "SDL_blit.h" #include "SDL_RLEaccel_c.h" diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index 9903a7d58..fc163ef8a 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -32,8 +32,7 @@ #ifdef HAVE_ALTIVEC_H #include #endif -#include -#include +#define assert(X) #ifdef MACOSX #include static size_t GetL3CacheSize( void ) @@ -235,7 +234,6 @@ static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) { assert(width == 0); - /* do scalar until we can align... */ ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND diff --git a/src/video/SDL_cursor.c b/src/video/SDL_cursor.c index 906e9a90d..0f9f3f339 100644 --- a/src/video/SDL_cursor.c +++ b/src/video/SDL_cursor.c @@ -22,12 +22,12 @@ /* General cursor handling code for SDL */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_mutex.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_blit.h" #include "SDL_events_c.h" #include "SDL_sysvideo.h" diff --git a/src/video/SDL_gamma.c b/src/video/SDL_gamma.c index 6e794b105..5ac70d66d 100644 --- a/src/video/SDL_gamma.c +++ b/src/video/SDL_gamma.c @@ -36,9 +36,9 @@ #define log(x) __ieee754_log(x) #endif -#include "SDL_error.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" #include "SDL_sysvideo.h" diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 81256dcbd..4ebae04fe 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -22,11 +22,11 @@ /* General (mostly internal) pixel/color manipulation routines for SDL */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_endian.h" #include "SDL_video.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_sysvideo.h" #include "SDL_blit.h" #include "SDL_pixels_c.h" diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index bf900ca30..e5e5d30e6 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -20,10 +20,10 @@ slouken@libsdl.org */ -#include "SDL_error.h" -#include "SDL_video.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_video.h" #include "SDL_sysvideo.h" #include "SDL_cursor_c.h" #include "SDL_blit.h" diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8aaf8fbd8..9a46e7ba0 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -23,12 +23,12 @@ /* The high-level video driver subsystem */ #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_events.h" #include "SDL_mutex.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_sysvideo.h" #include "SDL_sysevents.h" #include "SDL_blit.h" diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index 804f155c3..777e7ec67 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -22,9 +22,9 @@ /* This is the implementation of the YUV video surface support */ +#include "SDL_stdlib.h" #include "SDL_video.h" #include "SDL_error.h" -#include "SDL_stdlib.h" #include "SDL_sysvideo.h" #include "SDL_yuvfuncs.h" #include "SDL_yuv_sw_c.h" diff --git a/src/video/SDL_yuv_sw.c b/src/video/SDL_yuv_sw.c index a61c98cd0..79c95e13d 100644 --- a/src/video/SDL_yuv_sw.c +++ b/src/video/SDL_yuv_sw.c @@ -82,11 +82,11 @@ * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_cpuinfo.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_stretch_c.h" #include "SDL_yuvfuncs.h" #include "SDL_yuv_sw_c.h" diff --git a/src/video/Xext/Xv/Xv.c b/src/video/Xext/Xv/Xv.c index 8dfb612a8..7fc6c0138 100644 --- a/src/video/Xext/Xv/Xv.c +++ b/src/video/Xext/Xv/Xv.c @@ -234,7 +234,7 @@ SDL_NAME(XvQueryAdaptors)( SyncHandle(); return(XvBadAlloc); } - (void)SDL_strncpy(name, u.string, size); + (void)strncpy(name, u.string, size); name[size] = '\0'; pa->name = name; @@ -386,7 +386,7 @@ SDL_NAME(XvQueryEncodings)( SyncHandle(); return(XvBadAlloc); } - SDL_strncpy(name, u.string, size); + strncpy(name, u.string, size); name[size] = '\0'; pe->name = name; pe++; @@ -902,7 +902,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( ret[i].id = Info.id; ret[i].type = Info.type; ret[i].byte_order = Info.byte_order; - SDL_memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); + memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); ret[i].bits_per_pixel = Info.bpp; ret[i].format = Info.format; ret[i].num_planes = Info.num_planes; @@ -919,7 +919,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( ret[i].vert_y_period = Info.vert_y_period; ret[i].vert_u_period = Info.vert_u_period; ret[i].vert_v_period = Info.vert_v_period; - SDL_memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32); + memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32); ret[i].scanline_order = Info.scanline_order; (*num)++; } diff --git a/src/video/Xext/Xxf86dga/XF86DGA.c b/src/video/Xext/Xxf86dga/XF86DGA.c index 33d746814..926ddf6b9 100644 --- a/src/video/Xext/Xxf86dga/XF86DGA.c +++ b/src/video/Xext/Xxf86dga/XF86DGA.c @@ -407,12 +407,12 @@ AddMap(void) MapPtr *old; old = mapList; - mapList = SDL_realloc(mapList, sizeof(MapPtr) * (numMaps + 1)); + mapList = realloc(mapList, sizeof(MapPtr) * (numMaps + 1)); if (!mapList) { mapList = old; return NULL; } - mapList[numMaps] = SDL_malloc(sizeof(MapRec)); + mapList[numMaps] = malloc(sizeof(MapRec)); if (!mapList[numMaps]) return NULL; return mapList[numMaps++]; @@ -424,12 +424,12 @@ AddScr(void) ScrPtr *old; old = scrList; - scrList = SDL_realloc(scrList, sizeof(ScrPtr) * (numScrs + 1)); + scrList = realloc(scrList, sizeof(ScrPtr) * (numScrs + 1)); if (!scrList) { scrList = old; return NULL; } - scrList[numScrs] = SDL_malloc(sizeof(ScrRec)); + scrList[numScrs] = malloc(sizeof(ScrRec)); if (!scrList[numScrs]) return NULL; return scrList[numScrs++]; diff --git a/src/video/aalib/SDL_aavideo.c b/src/video/aalib/SDL_aavideo.c index 98c760ea0..b5f406ce3 100644 --- a/src/video/aalib/SDL_aavideo.c +++ b/src/video/aalib/SDL_aavideo.c @@ -23,14 +23,13 @@ /* AAlib based SDL video driver implementation. */ -#include -#include -#include #include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/ataricommon/SDL_atarievents.c b/src/video/ataricommon/SDL_atarievents.c index d839060a9..137959cc2 100644 --- a/src/video/ataricommon/SDL_atarievents.c +++ b/src/video/ataricommon/SDL_atarievents.c @@ -28,12 +28,11 @@ * This routines choose what the final event manager will be */ -#include -#include - #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_sysevents.h" #include "SDL_events_c.h" diff --git a/src/video/ataricommon/SDL_atarigl.c b/src/video/ataricommon/SDL_atarigl.c index 7025960a7..cf1ffcd95 100644 --- a/src/video/ataricommon/SDL_atarigl.c +++ b/src/video/ataricommon/SDL_atarigl.c @@ -24,15 +24,14 @@ /*--- Includes ---*/ -#include -#include -#include #ifdef HAVE_OPENGL #include #endif #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_video.h" #include "SDL_error.h" #include "SDL_endian.h" diff --git a/src/video/ataricommon/SDL_xbiosevents.c b/src/video/ataricommon/SDL_xbiosevents.c index b119a0bf0..1ab684cc3 100644 --- a/src/video/ataricommon/SDL_xbiosevents.c +++ b/src/video/ataricommon/SDL_xbiosevents.c @@ -26,10 +26,6 @@ * Patrice Mandin */ -#include -#include -#include - #include #include "SDL_events_c.h" diff --git a/src/video/bwindow/SDL_sysmouse.cc b/src/video/bwindow/SDL_sysmouse.cc index 56540c4a2..053fdfe31 100644 --- a/src/video/bwindow/SDL_sysmouse.cc +++ b/src/video/bwindow/SDL_sysmouse.cc @@ -20,12 +20,11 @@ slouken@libsdl.org */ -#include -#include - #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_BWin.h" diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc index 77e5e3c4c..29ebe32f7 100644 --- a/src/video/bwindow/SDL_sysvideo.cc +++ b/src/video/bwindow/SDL_sysvideo.cc @@ -22,13 +22,11 @@ /* BWindow based framebuffer implementation */ -#include -#include - -#include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_BeApp.h" #include "SDL_BWin.h" #include "SDL_timer.h" @@ -291,7 +289,7 @@ int BE_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Get the video modes we can switch to in fullscreen mode */ bscreen.GetModeList(&modes, &nmodes); - qsort(modes, nmodes, sizeof *modes, CompareModes); + SDL_qsort(modes, nmodes, sizeof *modes, CompareModes); for ( i=0; i -#include -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_sysyuv.h" @@ -158,7 +155,7 @@ SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD } /* Create the overlay structure */ - overlay = (SDL_Overlay*)calloc(1, sizeof(SDL_Overlay)); + overlay = (SDL_Overlay*)SDL_calloc(1, sizeof(SDL_Overlay)); if (overlay == NULL) { @@ -176,7 +173,7 @@ SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD overlay->hwfuncs = &be_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = (struct private_yuvhwdata*)calloc(1, sizeof(struct private_yuvhwdata)); + hwdata = (struct private_yuvhwdata*)SDL_calloc(1, sizeof(struct private_yuvhwdata)); if (hwdata == NULL) { @@ -215,8 +212,8 @@ SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD overlay->hwdata->bbitmap = bbitmap; overlay->planes = planes; - overlay->pitches = (Uint16*)calloc(overlay->planes, sizeof(Uint16)); - overlay->pixels = (Uint8**)calloc(overlay->planes, sizeof(Uint8*)); + overlay->pitches = (Uint16*)SDL_calloc(overlay->planes, sizeof(Uint16)); + overlay->pixels = (Uint8**)SDL_calloc(overlay->planes, sizeof(Uint8*)); if (!overlay->pitches || !overlay->pixels) { SDL_OutOfMemory(); diff --git a/src/video/cybergfx/SDL_cgximage.c b/src/video/cybergfx/SDL_cgximage.c index a8760fbfe..82a4ed3a5 100644 --- a/src/video/cybergfx/SDL_cgximage.c +++ b/src/video/cybergfx/SDL_cgximage.c @@ -20,8 +20,8 @@ slouken@libsdl.org */ -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_endian.h" #include "SDL_cgximage_c.h" diff --git a/src/video/cybergfx/SDL_cgxmodes.c b/src/video/cybergfx/SDL_cgxmodes.c index 2f114e609..f7d6e4f67 100644 --- a/src/video/cybergfx/SDL_cgxmodes.c +++ b/src/video/cybergfx/SDL_cgxmodes.c @@ -22,11 +22,6 @@ /* Utilities for getting and setting the X display mode */ -/* -#include -#include -*/ - #include "SDL_timer.h" #include "SDL_error.h" #include "SDL_events.h" diff --git a/src/video/cybergfx/SDL_cgxvideo.c b/src/video/cybergfx/SDL_cgxvideo.c index 3a1aa6e59..eedd9127d 100644 --- a/src/video/cybergfx/SDL_cgxvideo.c +++ b/src/video/cybergfx/SDL_cgxvideo.c @@ -25,18 +25,6 @@ * gabriele.greco@aruba.it */ -/* -#include -#include -#include -#include -#include -#ifdef MTRR_SUPPORT -#include -#include -#endif -*/ - #include "SDL.h" #include "SDL_error.h" #include "SDL_timer.h" diff --git a/src/video/cybergfx/SDL_cgxvideo.h b/src/video/cybergfx/SDL_cgxvideo.h index a15e1e56f..de3be482b 100644 --- a/src/video/cybergfx/SDL_cgxvideo.h +++ b/src/video/cybergfx/SDL_cgxvideo.h @@ -24,10 +24,6 @@ #define _SDL_cgxvideo_h -#include -#include -#include - #include #include #include @@ -47,9 +43,11 @@ #include #endif -#include "mydebug.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_mouse.h" #include "SDL_sysvideo.h" +#include "mydebug.h" #define USE_CGX_WRITELUTPIXEL diff --git a/src/video/cybergfx/SDL_cgxyuv.c b/src/video/cybergfx/SDL_cgxyuv.c index 36da414a1..73745a12e 100644 --- a/src/video/cybergfx/SDL_cgxyuv.c +++ b/src/video/cybergfx/SDL_cgxyuv.c @@ -24,14 +24,14 @@ #ifdef XFREE86_XV -#include -#include #include #include #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_x11yuv_c.h" diff --git a/src/video/dc/SDL_dcvideo.c b/src/video/dc/SDL_dcvideo.c index 98f098386..d7f2ab8ee 100644 --- a/src/video/dc/SDL_dcvideo.c +++ b/src/video/dc/SDL_dcvideo.c @@ -20,11 +20,9 @@ slouken@libsdl.org */ -#include -#include -#include - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/dga/SDL_dgavideo.c b/src/video/dga/SDL_dgavideo.c index 9bcad6fa8..1ac54f118 100644 --- a/src/video/dga/SDL_dgavideo.c +++ b/src/video/dga/SDL_dgavideo.c @@ -23,16 +23,14 @@ /* DGA 2.0 based SDL video driver implementation. */ -#include -#include +#include + #include #include -#ifdef HAVE_ALLOCA_H -#include -#endif - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -390,7 +388,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Query for the list of available video modes */ modes = SDL_NAME(XDGAQueryModes)(DGA_Display, DGA_Screen, &num_modes); - qsort(modes, num_modes, sizeof *modes, cmpmodes); + SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes); for ( i=0; i #include -#include -#include #include #include #include diff --git a/src/video/directfb/SDL_DirectFB_video.c b/src/video/directfb/SDL_DirectFB_video.c index d70aaa426..a7cd8d244 100644 --- a/src/video/directfb/SDL_DirectFB_video.c +++ b/src/video/directfb/SDL_DirectFB_video.c @@ -27,9 +27,6 @@ /* DirectFB video driver implementation. */ -#include -#include -#include #include #include #include @@ -38,6 +35,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -110,7 +109,7 @@ static SDL_VideoDevice *DirectFB_CreateDevice(int devindex) device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - memset (device, 0, (sizeof *device)); + SDL_memset (device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden)); } if (device == NULL || device->hidden == NULL) @@ -122,7 +121,7 @@ static SDL_VideoDevice *DirectFB_CreateDevice(int devindex) } return(0); } - memset (device->hidden, 0, sizeof (*device->hidden)); + SDL_memset (device->hidden, 0, sizeof (*device->hidden)); /* Set the function pointers */ device->VideoInit = DirectFB_VideoInit; @@ -195,7 +194,7 @@ static DFBEnumerationResult EnumModesCallback (int width, HIDDEN->nummodes++; - enumrect = calloc(1, sizeof(struct DirectFBEnumRect)); + enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect)); if (!enumrect) { SDL_OutOfMemory(); @@ -294,14 +293,14 @@ static SDL_Palette *AllocatePalette(int size) SDL_Palette *palette; SDL_Color *colors; - palette = calloc (1, sizeof(SDL_Palette)); + palette = SDL_calloc (1, sizeof(SDL_Palette)); if (!palette) { SDL_OutOfMemory(); return NULL; } - colors = calloc (size, sizeof(SDL_Color)); + colors = SDL_calloc (size, sizeof(SDL_Color)); if (!colors) { SDL_OutOfMemory(); @@ -432,7 +431,7 @@ int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat) goto error; } - HIDDEN->modelist = calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *)); + HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *)); if (!HIDDEN->modelist) { SDL_OutOfMemory(); @@ -614,7 +613,7 @@ static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width else if (!current->hwdata) { /* Allocate the hardware acceleration data */ - current->hwdata = (struct private_hwdata *) calloc (1, sizeof(*current->hwdata)); + current->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*current->hwdata)); if (!current->hwdata) { SDL_OutOfMemory(); @@ -821,7 +820,7 @@ static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface) return -1; /* Allocate the hardware acceleration data */ - surface->hwdata = (struct private_hwdata *) calloc (1, sizeof(*surface->hwdata)); + surface->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*surface->hwdata)); if (surface->hwdata == NULL) { SDL_OutOfMemory(); diff --git a/src/video/directfb/SDL_DirectFB_yuv.c b/src/video/directfb/SDL_DirectFB_yuv.c index 44cf2ff71..8f9b8ae24 100644 --- a/src/video/directfb/SDL_DirectFB_yuv.c +++ b/src/video/directfb/SDL_DirectFB_yuv.c @@ -22,9 +22,7 @@ /* This is the DirectFB implementation of YUV video overlays */ -#include -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_DirectFB_yuv.h" @@ -148,7 +146,7 @@ SDL_Overlay *DirectFB_CreateYUVOverlay(_THIS, int width, int height, Uint32 form struct private_yuvhwdata *hwdata; /* Create the overlay structure */ - overlay = calloc (1, sizeof(SDL_Overlay)); + overlay = SDL_calloc (1, sizeof(SDL_Overlay)); if (!overlay) { SDL_OutOfMemory(); @@ -164,7 +162,7 @@ SDL_Overlay *DirectFB_CreateYUVOverlay(_THIS, int width, int height, Uint32 form overlay->hwfuncs = &directfb_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = calloc(1, sizeof(struct private_yuvhwdata)); + hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata)); overlay->hwdata = hwdata; if (!hwdata) { diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 63e677ba9..b54395136 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -35,11 +35,9 @@ * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. */ -#include -#include -#include - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -145,7 +143,9 @@ VideoBootStrap DUMMY_bootstrap = { int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat) { + /* fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n"); + */ /* Determine the screen depth (use default 8-bit depth) */ /* we change this during the SDL_SetVideoMode implementation... */ diff --git a/src/video/epoc/SDL_epocvideo.cpp b/src/video/epoc/SDL_epocvideo.cpp index eecf288c2..643fcf278 100644 --- a/src/video/epoc/SDL_epocvideo.cpp +++ b/src/video/epoc/SDL_epocvideo.cpp @@ -29,11 +29,9 @@ -#include -#include -#include - extern "C" { +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_video.h" diff --git a/src/video/fbcon/SDL_fbelo.c b/src/video/fbcon/SDL_fbelo.c index 53d85c915..30bb01492 100644 --- a/src/video/fbcon/SDL_fbelo.c +++ b/src/video/fbcon/SDL_fbelo.c @@ -20,12 +20,12 @@ slouken@libsdl.org */ -#include #include #include #include -#include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_fbvideo.h" #include "SDL_fbelo.h" diff --git a/src/video/fbcon/SDL_fbevents.c b/src/video/fbcon/SDL_fbevents.c index a042aa935..d31daf3bb 100644 --- a/src/video/fbcon/SDL_fbevents.c +++ b/src/video/fbcon/SDL_fbevents.c @@ -22,14 +22,12 @@ /* Handle the event stream, converting console events into SDL events */ +#include #include #include #include -#include -#include #include #include -#include #include #include @@ -42,6 +40,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_mutex.h" #include "SDL_sysevents.h" #include "SDL_sysvideo.h" @@ -260,7 +260,7 @@ int FB_OpenKeyboard(_THIS) for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) { char vtpath[12]; - sprintf(vtpath, vcs[i], current_vt); + SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], current_vt); keyboard_fd = open(vtpath, O_RDWR, 0); #ifdef DEBUG_KEYBOARD fprintf(stderr, "vtpath = %s, fd = %d\n", @@ -345,7 +345,7 @@ static int find_pid(DIR *proc, const char *wanted_name) char path[PATH_MAX]; char name[PATH_MAX]; - sprintf(path, "/proc/%s/status", entry->d_name); + SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", entry->d_name); status=fopen(path, "r"); if ( status ) { name[0] = '\0'; @@ -379,7 +379,7 @@ static int gpm_available(void) proc = opendir("/proc"); if ( proc ) { while ( (pid=find_pid(proc, "gpm")) > 0 ) { - sprintf(path, "/proc/%d/cmdline", pid); + SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid); cmdline = open(path, O_RDONLY, 0); if ( cmdline >= 0 ) { len = read(cmdline, args, sizeof(args)); diff --git a/src/video/fbcon/SDL_fbvideo.c b/src/video/fbcon/SDL_fbvideo.c index 0ef5553dd..528e97ab9 100644 --- a/src/video/fbcon/SDL_fbvideo.c +++ b/src/video/fbcon/SDL_fbvideo.c @@ -23,16 +23,17 @@ /* Framebuffer console based SDL video driver implementation. */ -#include #include -#include #include #include #include #include #include /* For definition of PAGE_SIZE */ +#include /* For ioperm() */ #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -53,10 +54,12 @@ #ifndef FB_AUX_VGA_PLANES_VGA4 #define FB_AUX_VGA_PLANES_VGA4 0 #endif +/* static inline void outb (unsigned char value, unsigned short port) { __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port)); } +*/ #endif /* FB_TYPE_VGA_PLANES */ /* A list of video resolutions that we query for (sorted largest to smallest) */ @@ -438,7 +441,7 @@ static int FB_SortModes(_THIS) int i; for ( i=0; i 0 ) { - qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); + SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); } } } diff --git a/src/video/gapi/SDL_gapivideo.c b/src/video/gapi/SDL_gapivideo.c index 3604e09fc..a384d7b52 100644 --- a/src/video/gapi/SDL_gapivideo.c +++ b/src/video/gapi/SDL_gapivideo.c @@ -32,11 +32,8 @@ Inspired by http://arisme.free.fr/ports/SDL.php // TODO: windib on SH3 PPC2000 landscape test // TODO: optimize 8bpp landscape mode -#include -#include -#include - #include "SDL.h" +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -479,7 +476,7 @@ int GAPI_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Sort the mode lists */ for ( i=0; iSDL_nummodes[i] > 0 ) { - qsort(gapi->SDL_modelist[i], gapi->SDL_nummodes[i], sizeof *gapi->SDL_modelist[i], cmpmodes); + SDL_qsort(gapi->SDL_modelist[i], gapi->SDL_nummodes[i], sizeof *gapi->SDL_modelist[i], cmpmodes); } } diff --git a/src/video/gem/SDL_gemmouse.c b/src/video/gem/SDL_gemmouse.c index e563c0140..7546a9f2c 100644 --- a/src/video/gem/SDL_gemmouse.c +++ b/src/video/gem/SDL_gemmouse.c @@ -26,10 +26,9 @@ * Patrice Mandin */ -#include - #include +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_mouse.h" #include "SDL_events_c.h" diff --git a/src/video/gem/SDL_gemvideo.c b/src/video/gem/SDL_gemvideo.c index 3ffa4068a..44229e762 100644 --- a/src/video/gem/SDL_gemvideo.c +++ b/src/video/gem/SDL_gemvideo.c @@ -28,10 +28,6 @@ Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard */ -#include -#include -#include - /* Mint includes */ #include #include @@ -39,6 +35,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/ggi/SDL_ggievents.c b/src/video/ggi/SDL_ggievents.c index 2533f2c52..dad7f3d03 100644 --- a/src/video/ggi/SDL_ggievents.c +++ b/src/video/ggi/SDL_ggievents.c @@ -24,8 +24,6 @@ #include #include -#include -#include #include #include #include diff --git a/src/video/ggi/SDL_ggivideo.c b/src/video/ggi/SDL_ggivideo.c index 33b4fceb3..5362d21b4 100644 --- a/src/video/ggi/SDL_ggivideo.c +++ b/src/video/ggi/SDL_ggivideo.c @@ -23,8 +23,6 @@ /* GGI-based SDL video driver implementation. */ -#include -#include #include #include #include @@ -33,6 +31,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/ipod/SDL_ipodvideo.c b/src/video/ipod/SDL_ipodvideo.c index 2879bf859..add2d41d5 100644 --- a/src/video/ipod/SDL_ipodvideo.c +++ b/src/video/ipod/SDL_ipodvideo.c @@ -1,8 +1,6 @@ #include #include -#include -#include #include #include #include @@ -15,6 +13,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -93,15 +93,15 @@ static SDL_VideoDevice *iPod_CreateDevice (int devindex) { SDL_VideoDevice *this; - this = (SDL_VideoDevice *)malloc (sizeof(SDL_VideoDevice)); + this = (SDL_VideoDevice *)SDL_malloc (sizeof(SDL_VideoDevice)); if (this) { memset (this, 0, sizeof *this); - this->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof(struct SDL_PrivateVideoData)); + this->hidden = (struct SDL_PrivateVideoData *) SDL_malloc (sizeof(struct SDL_PrivateVideoData)); } if (!this || !this->hidden) { SDL_OutOfMemory(); if (this) - free (this); + SDL_free (this); return 0; } memset (this->hidden, 0, sizeof(struct SDL_PrivateVideoData)); @@ -178,7 +178,7 @@ static int iPod_VideoInit (_THIS, SDL_PixelFormat *vformat) for ( i=0; vcs[i] && (kbfd < 0); ++i ) { char vtpath[12]; - sprintf(vtpath, vcs[i], curvt); + SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], curvt); kbfd = open(vtpath, O_RDWR); } } @@ -320,8 +320,8 @@ static SDL_Surface *iPod_SetVideoMode (_THIS, SDL_Surface *current, int width, i Rmask = Gmask = Bmask = 0; } - if (this->hidden->buffer) free (this->hidden->buffer); - this->hidden->buffer = malloc (width * height * (bpp / 8)); + if (this->hidden->buffer) SDL_free (this->hidden->buffer); + this->hidden->buffer = SDL_malloc (width * height * (bpp / 8)); if (!this->hidden->buffer) { SDL_SetError ("Couldn't allocate buffer for requested mode"); return 0; @@ -331,7 +331,7 @@ static SDL_Surface *iPod_SetVideoMode (_THIS, SDL_Surface *current, int width, i if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { SDL_SetError ("Couldn't allocate new pixel format"); - free (this->hidden->buffer); + SDL_free (this->hidden->buffer); this->hidden->buffer = 0; return 0; } diff --git a/src/video/maccommon/SDL_macmouse.c b/src/video/maccommon/SDL_macmouse.c index 81697113f..3778e6141 100644 --- a/src/video/maccommon/SDL_macmouse.c +++ b/src/video/maccommon/SDL_macmouse.c @@ -20,8 +20,6 @@ slouken@libsdl.org */ -#include -#include #if defined(__APPLE__) && defined(__MACH__) #include #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) @@ -35,6 +33,8 @@ #include #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_mouse.h" #include "SDL_macmouse_c.h" diff --git a/src/video/maccommon/SDL_macwm.c b/src/video/maccommon/SDL_macwm.c index aab0030c9..67816a88e 100644 --- a/src/video/maccommon/SDL_macwm.c +++ b/src/video/maccommon/SDL_macwm.c @@ -20,9 +20,6 @@ slouken@libsdl.org */ -#include -#include - #if defined(__APPLE__) && defined(__MACH__) #include #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) @@ -32,6 +29,7 @@ #include #endif +#include "SDL_string.h" #include "SDL_macwm_c.h" void Mac_SetCaption(_THIS, const char *title, const char *icon) diff --git a/src/video/macdsp/SDL_dspvideo.c b/src/video/macdsp/SDL_dspvideo.c index bc22584ad..1478bd6c7 100644 --- a/src/video/macdsp/SDL_dspvideo.c +++ b/src/video/macdsp/SDL_dspvideo.c @@ -122,9 +122,6 @@ #define DSP_NO_SYNC_OPENGL -#include -#include - #if defined(__APPLE__) && defined(__MACH__) #include #include @@ -140,6 +137,8 @@ #include #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_video.h" #include "SDL_blit.h" #include "SDL_error.h" @@ -265,7 +264,7 @@ static SDL_VideoDevice *DSp_CreateDevice(int devindex) if ( device ) { if (device->hidden) - free (device->hidden); + SDL_free(device->hidden); SDL_free(device); } @@ -390,14 +389,14 @@ static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice) done: i++; /* i was not incremented before kicking out of the loop */ - mode_list = (SDL_Rect**) malloc (sizeof (SDL_Rect*) * (i+1)); + mode_list = (SDL_Rect**) SDL_malloc (sizeof (SDL_Rect*) * (i+1)); if (mode_list) { /* -dw- new stuff: build in reverse order so largest sizes list first */ for (j = i-1; j >= 0; j--) { - mode_list [j] = (SDL_Rect*) malloc (sizeof (SDL_Rect)); + mode_list [j] = (SDL_Rect*) SDL_malloc (sizeof (SDL_Rect)); if (mode_list [j]) - memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect)); + SDL_memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect)); else { SDL_OutOfMemory (); return NULL; @@ -475,7 +474,7 @@ static int DSp_GetMainDevice (_THIS, GDHandle *device) return 0; } - memset (&attrib, 0, sizeof (DSpContextAttributes)); + SDL_memset (&attrib, 0, sizeof (DSpContextAttributes)); /* These attributes are hopefully supported on all devices...*/ attrib.displayWidth = 640; @@ -657,7 +656,7 @@ static void DSp_SetHWError (OSStatus err, int is_agp) fmt = "Hardware surface could not be allocated in %s - unknown error"; break; } - sprintf(message, fmt, mem); + SDL_snprintf(message, SDL_arraysize(message), fmt, mem); SDL_SetError(message); } #endif // TARGET_API_MAC_OSX @@ -735,7 +734,7 @@ static void DSp_UnsetVideoMode(_THIS, SDL_Surface *current) DisposeGWorld (dsp_back_buffer); if (current->hwdata) - free (current->hwdata); + SDL_free(current->hwdata); DSpContext_SetState (dsp_context, kDSpContextState_Inactive ); DSpContext_Release (dsp_context); @@ -788,7 +787,7 @@ static SDL_Surface *DSp_SetVideoMode(_THIS, page_count = 1; } - memset (&attrib, 0, sizeof (DSpContextAttributes)); + SDL_memset (&attrib, 0, sizeof (DSpContextAttributes)); attrib.displayWidth = width; attrib.displayHeight = height; attrib.displayBestDepth = bpp; @@ -867,7 +866,7 @@ static SDL_Surface *DSp_SetVideoMode(_THIS, /* single-buffer context */ DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer); - current->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata)); + current->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata)); if (current ->hwdata == NULL) { SDL_OutOfMemory (); return NULL; @@ -885,13 +884,13 @@ static SDL_Surface *DSp_SetVideoMode(_THIS, } else if ( DSp_NewHWSurface(this, &dsp_back_buffer, bpp, width-1, height-1) == 0 ) { - current->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata)); + current->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata)); if (current ->hwdata == NULL) { SDL_OutOfMemory (); return NULL; } - memset (current->hwdata, 0, sizeof (private_hwdata)); + SDL_memset (current->hwdata, 0, sizeof (private_hwdata)); current->hwdata->offscreen = dsp_back_buffer; current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */ @@ -1084,13 +1083,13 @@ static int DSp_AllocHWSurface(_THIS, SDL_Surface *surface) if ( DSp_NewHWSurface (this, &temp, surface->format->BitsPerPixel, surface->w, surface->h) < 0 ) return (-1); - surface->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata)); + surface->hwdata = (private_hwdata*) SDL_malloc (sizeof (private_hwdata)); if (surface->hwdata == NULL) { SDL_OutOfMemory (); return -1; } - memset (surface->hwdata, 0, sizeof(private_hwdata)); + SDL_memset (surface->hwdata, 0, sizeof(private_hwdata)); surface->hwdata->offscreen = temp; surface->pitch = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF; surface->pixels = GetPixBaseAddr (GetPortPixMap (temp)); @@ -1105,7 +1104,7 @@ static void DSp_FreeHWSurface(_THIS, SDL_Surface *surface) { if (surface->hwdata->offscreen != NULL) DisposeGWorld (surface->hwdata->offscreen); - free (surface->hwdata); + SDL_free(surface->hwdata); surface->pixels = NULL; } diff --git a/src/video/macrom/SDL_romvideo.c b/src/video/macrom/SDL_romvideo.c index 5b3cc7c2d..082fbbfb7 100644 --- a/src/video/macrom/SDL_romvideo.c +++ b/src/video/macrom/SDL_romvideo.c @@ -20,9 +20,6 @@ slouken@libsdl.org */ -#include -#include - #if defined(__APPLE__) && defined(__MACH__) #include #if USE_QUICKTIME @@ -44,6 +41,8 @@ #include #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_video.h" #include "SDL_error.h" #include "SDL_syswm.h" diff --git a/src/video/nanox/SDL_nximage.c b/src/video/nanox/SDL_nximage.c index 05b010b58..5a9b779e5 100644 --- a/src/video/nanox/SDL_nximage.c +++ b/src/video/nanox/SDL_nximage.c @@ -25,9 +25,8 @@ clare@setabox.com */ -#include -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_nximage_c.h" @@ -106,7 +105,7 @@ void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) else { for (j = h; j > 0; -- j, src += yinc, dest += destinc) - memcpy (dest, src, rowinc) ; + SDL_memcpy (dest, src, rowinc) ; } if (!Clientfb) { if (currently_fullscreen) { @@ -128,13 +127,13 @@ int NX_SetupImage (_THIS, SDL_Surface * screen) Dprintf ("enter NX_SetupImage\n") ; - screen -> pixels = (void *) malloc (size) ; + screen -> pixels = (void *) SDL_malloc (size) ; if (!Clientfb) { - Image_buff = (unsigned char *) malloc (size) ; + Image_buff = (unsigned char *) SDL_malloc (size) ; if (screen -> pixels == NULL || Image_buff == NULL) { - free (screen -> pixels) ; - free (Image_buff) ; + SDL_free (screen -> pixels) ; + SDL_free (Image_buff) ; SDL_OutOfMemory () ; return -1 ; } @@ -152,8 +151,8 @@ void NX_DestroyImage (_THIS, SDL_Surface * screen) { Dprintf ("enter NX_DestroyImage\n") ; - if (SDL_Image) free (SDL_Image) ; - if (Image_buff) free (Image_buff) ; + if (SDL_Image) SDL_free (SDL_Image) ; + if (Image_buff) SDL_free (Image_buff) ; if (screen) screen -> pixels = NULL ; Dprintf ("leave NX_DestroyImage\n") ; @@ -215,7 +214,7 @@ void NX_RefreshDisplay (_THIS) rowinc = xinc * this -> screen -> w; for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch) - memcpy (dest, src, rowinc) ; + SDL_memcpy (dest, src, rowinc) ; } else #endif diff --git a/src/video/nanox/SDL_nxmodes.c b/src/video/nanox/SDL_nxmodes.c index da89aa021..61025f9f7 100644 --- a/src/video/nanox/SDL_nxmodes.c +++ b/src/video/nanox/SDL_nxmodes.c @@ -24,8 +24,8 @@ clare@setabox.com */ -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_nxmodes_c.h" SDL_Rect ** NX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) @@ -46,9 +46,9 @@ void NX_FreeVideoModes (_THIS) if (SDL_modelist) { for (i = 0; SDL_modelist [i]; ++ i) { - free (SDL_modelist [i]) ; + SDL_free (SDL_modelist [i]) ; } - free (SDL_modelist) ; + SDL_free (SDL_modelist) ; SDL_modelist = NULL; } } diff --git a/src/video/nanox/SDL_nxmouse.c b/src/video/nanox/SDL_nxmouse.c index b6cd347f0..581498893 100644 --- a/src/video/nanox/SDL_nxmouse.c +++ b/src/video/nanox/SDL_nxmouse.c @@ -24,8 +24,7 @@ clare@setabox.com */ -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_events_c.h" @@ -43,7 +42,7 @@ WMcursor * NX_CreateWMCursor (_THIS, Dprintf ("enter NX_CreateWMCursor\n") ; - cursor = (WMcursor *) malloc (sizeof (WMcursor)) ; + cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)) ; if (cursor == NULL) { SDL_OutOfMemory () ; return NULL ; @@ -56,7 +55,7 @@ WMcursor * NX_CreateWMCursor (_THIS, void NX_FreeWMCursor (_THIS, WMcursor * cursor) { Dprintf ("NX_FreeWMCursor\n") ; - free (cursor) ; + SDL_free (cursor) ; return ; } diff --git a/src/video/nanox/SDL_nxvideo.c b/src/video/nanox/SDL_nxvideo.c index 87206bd0e..da08f5231 100644 --- a/src/video/nanox/SDL_nxvideo.c +++ b/src/video/nanox/SDL_nxvideo.c @@ -25,9 +25,8 @@ clare@setabox.com */ -#include -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_video.h" #include "SDL_pixels_c.h" #include "SDL_events_c.h" @@ -84,11 +83,11 @@ static SDL_VideoDevice * NX_CreateDevice (int devindex) Dprintf ("enter NX_CreateDevice\n") ; // Initialize all variables that we clean on shutdown - device = (SDL_VideoDevice *) malloc (sizeof (SDL_VideoDevice)) ; + device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)) ; if (device) { - memset (device, 0, (sizeof * device)) ; + SDL_memset (device, 0, (sizeof * device)) ; device -> hidden = (struct SDL_PrivateVideoData *) - malloc ((sizeof * device -> hidden)) ; + SDL_malloc ((sizeof * device -> hidden)) ; device -> gl_data = NULL ; } if ((device == NULL) || (device -> hidden == NULL)) { @@ -96,7 +95,7 @@ static SDL_VideoDevice * NX_CreateDevice (int devindex) NX_DeleteDevice (device) ; return 0 ; } - memset (device -> hidden, 0, (sizeof * device -> hidden)) ; + SDL_memset (device -> hidden, 0, (sizeof * device -> hidden)) ; // Set the function pointers device -> VideoInit = NX_VideoInit ; @@ -212,9 +211,9 @@ int NX_VideoInit (_THIS, SDL_PixelFormat * vformat) SDL_Visual.bpp = si.bpp ; // GetVideoMode - SDL_modelist = (SDL_Rect **) malloc (sizeof (SDL_Rect *) * 2) ; + SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2) ; if (SDL_modelist) { - SDL_modelist [0] = (SDL_Rect *) malloc (sizeof(SDL_Rect)) ; + SDL_modelist [0] = (SDL_Rect *) SDL_malloc (sizeof(SDL_Rect)) ; if (SDL_modelist [0]) { SDL_modelist [0] -> x = 0 ; SDL_modelist [0] -> y = 0 ; @@ -486,9 +485,9 @@ static int NX_SetGammaRamp (_THIS, Uint16 * ramp) if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1 ; - if (! GammaRamp_R) GammaRamp_R = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ; - if (! GammaRamp_G) GammaRamp_G = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ; - if (! GammaRamp_B) GammaRamp_B = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ; + if (! GammaRamp_R) GammaRamp_R = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ; + if (! GammaRamp_G) GammaRamp_G = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ; + if (! GammaRamp_B) GammaRamp_B = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ; if ((! GammaRamp_R) || (! GammaRamp_G) || (! GammaRamp_B)) { SDL_OutOfMemory () ; return -1 ; diff --git a/src/video/nanox/SDL_nxwm.c b/src/video/nanox/SDL_nxwm.c index d303c6fd2..5bb504827 100644 --- a/src/video/nanox/SDL_nxwm.c +++ b/src/video/nanox/SDL_nxwm.c @@ -24,8 +24,6 @@ clare@setabox.com */ -#include - #include "SDL_syswm.h" #include "SDL_error.h" #include "SDL_events_c.h" diff --git a/src/video/os2fslib/SDL_os2fslib.c b/src/video/os2fslib/SDL_os2fslib.c index d81bf6fc9..b1676de12 100644 --- a/src/video/os2fslib/SDL_os2fslib.c +++ b/src/video/os2fslib/SDL_os2fslib.c @@ -20,13 +20,12 @@ slouken@libsdl.org */ -#include -#include -#include #include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/photon/SDL_ph_image.c b/src/video/photon/SDL_ph_image.c index 9f43b1500..1ee9585c3 100644 --- a/src/video/photon/SDL_ph_image.c +++ b/src/video/photon/SDL_ph_image.c @@ -20,12 +20,12 @@ slouken@libsdl.org */ -#include - #include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_endian.h" #include "SDL_video.h" diff --git a/src/video/photon/SDL_ph_modes.c b/src/video/photon/SDL_ph_modes.c index 433c2c1e7..c84d73f15 100644 --- a/src/video/photon/SDL_ph_modes.c +++ b/src/video/photon/SDL_ph_modes.c @@ -173,7 +173,7 @@ int get_mode_any_format(int width, int height, int bpp) return -1; } - qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res); + SDL_qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res); for(i=0;i -#include -#include - +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_mouse.h" #include "SDL_events_c.h" diff --git a/src/video/photon/SDL_ph_video.c b/src/video/photon/SDL_ph_video.c index cf017f8eb..9cb060397 100644 --- a/src/video/photon/SDL_ph_video.c +++ b/src/video/photon/SDL_ph_video.c @@ -20,13 +20,12 @@ slouken@libsdl.org */ -#include -#include #include -#include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_thread.h" diff --git a/src/video/photon/SDL_ph_wm.c b/src/video/photon/SDL_ph_wm.c index 8b657db15..a8643e3d6 100644 --- a/src/video/photon/SDL_ph_wm.c +++ b/src/video/photon/SDL_ph_wm.c @@ -22,13 +22,13 @@ #define DISABLE_X11 -#include -#include #include #include #include #include + #include "SDL_version.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_video.h" diff --git a/src/video/photon/SDL_phyuv.c b/src/video/photon/SDL_phyuv.c index 89e2b4627..ac59a2091 100644 --- a/src/video/photon/SDL_phyuv.c +++ b/src/video/photon/SDL_phyuv.c @@ -22,13 +22,13 @@ /* This is the QNX Realtime Platform version of SDL YUV video overlays */ -#include -#include #include #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_phyuv_c.h" @@ -81,7 +81,7 @@ SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD PhPoint_t pos; /* Create the overlay structure */ - overlay = calloc(1, sizeof(SDL_Overlay)); + overlay = SDL_calloc(1, sizeof(SDL_Overlay)); if (overlay == NULL) { @@ -99,7 +99,7 @@ SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD overlay->hwfuncs = &ph_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = calloc(1, sizeof(struct private_yuvhwdata)); + hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata)); if (hwdata == NULL) { @@ -132,8 +132,8 @@ SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD overlay->hwdata->CurrentViewPort.size.w = width; overlay->hwdata->CurrentViewPort.size.h = height; overlay->hwdata->State = OVERLAY_STATE_UNINIT; - overlay->hwdata->FrameData0 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA)); - overlay->hwdata->FrameData1 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA)); + overlay->hwdata->FrameData0 = (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA)); + overlay->hwdata->FrameData1 = (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA)); vidport = -1; i=0; @@ -246,8 +246,8 @@ SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SD /* Find the pitch and offset values for the overlay */ overlay->planes = planes; - overlay->pitches = calloc(overlay->planes, sizeof(Uint16)); - overlay->pixels = calloc(overlay->planes, sizeof(Uint8*)); + overlay->pitches = SDL_calloc(overlay->planes, sizeof(Uint16)); + overlay->pixels = SDL_calloc(overlay->planes, sizeof(Uint8*)); if (!overlay->pitches || !overlay->pixels) { SDL_OutOfMemory(); diff --git a/src/video/picogui/SDL_pgvideo.c b/src/video/picogui/SDL_pgvideo.c index 45ae78119..9cb0d7c47 100644 --- a/src/video/picogui/SDL_pgvideo.c +++ b/src/video/picogui/SDL_pgvideo.c @@ -23,11 +23,9 @@ micahjd@users.sourceforge.net */ -#include -#include -#include - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/ps2gs/SDL_gsevents.c b/src/video/ps2gs/SDL_gsevents.c index a61a165ac..6bc4500ec 100644 --- a/src/video/ps2gs/SDL_gsevents.c +++ b/src/video/ps2gs/SDL_gsevents.c @@ -25,11 +25,8 @@ #include #include #include -#include -#include #include #include -#include #include #include @@ -42,6 +39,7 @@ #include #include "SDL.h" +#include "SDL_string.h" #include "SDL_mutex.h" #include "SDL_sysevents.h" #include "SDL_sysvideo.h" @@ -257,7 +255,7 @@ int GS_OpenKeyboard(_THIS) for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) { char vtpath[12]; - sprintf(vtpath, vcs[i], current_vt); + SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], current_vt); keyboard_fd = open(vtpath, O_RDWR, 0); #ifdef DEBUG_KEYBOARD fprintf(stderr, "vtpath = %s, fd = %d\n", @@ -333,7 +331,7 @@ static int find_pid(DIR *proc, const char *wanted_name) char path[PATH_MAX]; char name[PATH_MAX]; - sprintf(path, "/proc/%s/status", entry->d_name); + SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", entry->d_name); status=fopen(path, "r"); if ( status ) { name[0] = '\0'; @@ -367,7 +365,7 @@ static int gpm_available(void) proc = opendir("/proc"); if ( proc ) { while ( (pid=find_pid(proc, "gpm")) > 0 ) { - sprintf(path, "/proc/%d/cmdline", pid); + SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid); cmdline = open(path, O_RDONLY, 0); if ( cmdline >= 0 ) { len = read(cmdline, args, sizeof(args)); diff --git a/src/video/ps2gs/SDL_gsmouse.c b/src/video/ps2gs/SDL_gsmouse.c index b860497bf..9567a1f31 100644 --- a/src/video/ps2gs/SDL_gsmouse.c +++ b/src/video/ps2gs/SDL_gsmouse.c @@ -20,8 +20,6 @@ slouken@libsdl.org */ -#include -#include #include #include "SDL_error.h" diff --git a/src/video/ps2gs/SDL_gsvideo.c b/src/video/ps2gs/SDL_gsvideo.c index c26326bda..78a972c2d 100644 --- a/src/video/ps2gs/SDL_gsvideo.c +++ b/src/video/ps2gs/SDL_gsvideo.c @@ -23,14 +23,14 @@ /* Framebuffer console based SDL video driver implementation. */ -#include -#include #include #include #include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/ps2gs/SDL_gsyuv.c b/src/video/ps2gs/SDL_gsyuv.c index d93805b8b..62d31c777 100644 --- a/src/video/ps2gs/SDL_gsyuv.c +++ b/src/video/ps2gs/SDL_gsyuv.c @@ -22,14 +22,14 @@ /* This is the Playstation 2 implementation of YUV video overlays */ -#include -#include #include #include #include #include #include /* For definition of PAGE_SIZE */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_gsyuv_c.h" diff --git a/src/video/qtopia/SDL_sysmouse.cc b/src/video/qtopia/SDL_sysmouse.cc index 4d11f425d..ba0d525f6 100644 --- a/src/video/qtopia/SDL_sysmouse.cc +++ b/src/video/qtopia/SDL_sysmouse.cc @@ -20,11 +20,6 @@ slouken@libsdl.org */ -#include -#include - - -#include "SDL_error.h" #include "SDL_QWin.h" extern "C" { diff --git a/src/video/qtopia/SDL_sysvideo.cc b/src/video/qtopia/SDL_sysvideo.cc index 2b39f8b69..3f78bb31f 100644 --- a/src/video/qtopia/SDL_sysvideo.cc +++ b/src/video/qtopia/SDL_sysvideo.cc @@ -22,16 +22,14 @@ /* Qtopia based framebuffer implementation */ -#include -#include - -#include #include #include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_timer.h" #include "SDL_QWin.h" diff --git a/src/video/quartz/SDL_QuartzEvents.m b/src/video/quartz/SDL_QuartzEvents.m index 88c6d52dd..6ccddfdbb 100644 --- a/src/video/quartz/SDL_QuartzEvents.m +++ b/src/video/quartz/SDL_QuartzEvents.m @@ -20,9 +20,9 @@ slouken@libsdl.org */ +#include "SDL_stdlib.h" #include "SDL_QuartzVideo.h" -#include // For getenv() #include // For wake from sleep detection #include // For wake from sleep detection #include "SDL_QuartzKeys.h" @@ -295,7 +295,7 @@ static void QZ_DoKey (_THIS, int state, NSEvent *event) { } } - if (getenv ("SDL_ENABLEAPPEVENTS")) + if (SDL_getenv ("SDL_ENABLEAPPEVENTS")) [ NSApp sendEvent:event ]; } @@ -773,7 +773,7 @@ void QZ_PumpEvents (_THIS) switch (type) { case NSLeftMouseDown: - if ( getenv("SDL_HAS3BUTTONMOUSE") ) { + if ( SDL_getenv("SDL_HAS3BUTTONMOUSE") ) { DO_MOUSE_DOWN (SDL_BUTTON_LEFT); } else { if ( NSCommandKeyMask & current_mods ) { diff --git a/src/video/riscos/SDL_riscosFullScreenVideo.c b/src/video/riscos/SDL_riscosFullScreenVideo.c index 81cc30258..d52e3ffc2 100644 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c @@ -27,11 +27,9 @@ Implements RISC OS full screen display. */ -#include -#include -#include - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -357,7 +355,7 @@ void FULLSCREEN_BuildModeList(_THIS) /* Sort the mode lists */ for ( j=0; j 0 ) { - qsort(SDL_modelist[j], SDL_nummodes[j], sizeof *SDL_modelist[j], cmpmodes); + SDL_qsort(SDL_modelist[j], SDL_nummodes[j], sizeof *SDL_modelist[j], cmpmodes); } } } diff --git a/src/video/riscos/SDL_riscosmouse.c b/src/video/riscos/SDL_riscosmouse.c index 67549aa34..76599f455 100644 --- a/src/video/riscos/SDL_riscosmouse.c +++ b/src/video/riscos/SDL_riscosmouse.c @@ -27,9 +27,7 @@ Implements mouse cursor shape definitions and positioning */ -#include -#include - +#include "SDL_stdlib.h" #include "SDL_error.h" #include "SDL_mouse.h" #include "SDL_events_c.h" diff --git a/src/video/riscos/SDL_riscossprite.c b/src/video/riscos/SDL_riscossprite.c index 8a41830f1..e63a353ce 100644 --- a/src/video/riscos/SDL_riscossprite.c +++ b/src/video/riscos/SDL_riscossprite.c @@ -27,9 +27,10 @@ Implements Sprite plotting code for wimp display.window */ -#include #include "kernel.h" #include "swis.h" + +#include "SDL_stdlib.h" #include "SDL_riscosvideo.h" extern void WIMP_ReadModeInfo(_THIS); diff --git a/src/video/riscos/SDL_riscostask.c b/src/video/riscos/SDL_riscostask.c index 20026a4fa..5c99691ad 100644 --- a/src/video/riscos/SDL_riscostask.c +++ b/src/video/riscos/SDL_riscostask.c @@ -31,12 +31,11 @@ Restoring desktop after switching to full screen */ -#include -#include - #include "kernel.h" #include "swis.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_riscostask.h" #ifndef DISABLE_THREADS diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 6b4c53742..d07d8a939 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -29,11 +29,9 @@ into other source files. */ -#include -#include -#include - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_syswm.h" #include "SDL_error.h" #include "SDL_video.h" diff --git a/src/video/riscos/SDL_wimpvideo.c b/src/video/riscos/SDL_wimpvideo.c index 144ad5813..99bf49769 100644 --- a/src/video/riscos/SDL_wimpvideo.c +++ b/src/video/riscos/SDL_wimpvideo.c @@ -27,11 +27,9 @@ Implements RISC OS Wimp display. */ -#include -#include -#include - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/svga/SDL_svgaevents.c b/src/video/svga/SDL_svgaevents.c index 2afdcbe91..006c6fc9f 100644 --- a/src/video/svga/SDL_svgaevents.c +++ b/src/video/svga/SDL_svgaevents.c @@ -22,9 +22,6 @@ /* Handle the event stream, converting X11 events into SDL events */ -#include -#include - #include #include #include @@ -38,6 +35,8 @@ #endif #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_sysevents.h" #include "SDL_events_c.h" #include "SDL_svgavideo.h" diff --git a/src/video/svga/SDL_svgavideo.c b/src/video/svga/SDL_svgavideo.c index 8930a9b4a..d6fd79edb 100644 --- a/src/video/svga/SDL_svgavideo.c +++ b/src/video/svga/SDL_svgavideo.c @@ -23,8 +23,6 @@ /* SVGAlib based SDL video driver implementation. */ -#include -#include #include #include #include @@ -43,6 +41,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/vgl/SDL_vglvideo.c b/src/video/vgl/SDL_vglvideo.c index 2cbd06fbd..2baa817df 100644 --- a/src/video/vgl/SDL_vglvideo.c +++ b/src/video/vgl/SDL_vglvideo.c @@ -25,8 +25,6 @@ #include #include -#include -#include #include #include @@ -36,6 +34,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/wincommon/SDL_sysevents.c b/src/video/wincommon/SDL_sysevents.c index 7441d5742..8c20d3908 100644 --- a/src/video/wincommon/SDL_sysevents.c +++ b/src/video/wincommon/SDL_sysevents.c @@ -22,12 +22,12 @@ #include "SDL_windows.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_events.h" #include "SDL_video.h" #include "SDL_error.h" #include "SDL_syswm.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_getenv.h" #include "SDL_sysevents.h" #include "SDL_events_c.h" diff --git a/src/video/wincommon/SDL_sysmouse.c b/src/video/wincommon/SDL_sysmouse.c index 4935c9c79..6414e511a 100644 --- a/src/video/wincommon/SDL_sysmouse.c +++ b/src/video/wincommon/SDL_sysmouse.c @@ -22,10 +22,10 @@ #include "SDL_windows.h" -#include "SDL_error.h" -#include "SDL_mouse.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_mouse.h" #include "SDL_sysmouse_c.h" #include "SDL_events_c.h" #include "SDL_cursor_c.h" diff --git a/src/video/wincommon/SDL_syswm.c b/src/video/wincommon/SDL_syswm.c index ebb39db20..87fb1cfae 100644 --- a/src/video/wincommon/SDL_syswm.c +++ b/src/video/wincommon/SDL_syswm.c @@ -23,11 +23,11 @@ #include "SDL_windows.h" #include "SDL_version.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_syswm.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_syswm_c.h" #include "SDL_wingl_c.h" #include "SDL_pixels_c.h" diff --git a/src/video/wincommon/SDL_wingl.c b/src/video/wincommon/SDL_wingl.c index 179b1ef57..286497ffb 100644 --- a/src/video/wincommon/SDL_wingl.c +++ b/src/video/wincommon/SDL_wingl.c @@ -22,12 +22,12 @@ /* WGL implementation of SDL OpenGL support */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #ifdef HAVE_OPENGL #include "SDL_opengl.h" #endif #include "SDL_error.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_lowvideo.h" #include "SDL_wingl_c.h" diff --git a/src/video/windib/SDL_dibevents.c b/src/video/windib/SDL_dibevents.c index ec690cf13..ae9050708 100644 --- a/src/video/windib/SDL_dibevents.c +++ b/src/video/windib/SDL_dibevents.c @@ -22,11 +22,11 @@ #include "SDL_windows.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_events.h" #include "SDL_error.h" #include "SDL_syswm.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_sysevents.h" #include "SDL_events_c.h" #include "SDL_lowvideo.h" diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index 2242b3b83..051afb4bc 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -35,10 +35,10 @@ extern HINSTANCE aygshell; #endif #include "SDL.h" -#include "SDL_mutex.h" -#include "SDL_syswm.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_mutex.h" +#include "SDL_syswm.h" #include "SDL_sysvideo.h" #include "SDL_sysevents.h" #include "SDL_events_c.h" diff --git a/src/video/windx5/SDL_dx5events.c b/src/video/windx5/SDL_dx5events.c index 58ea42192..ce9205042 100644 --- a/src/video/windx5/SDL_dx5events.c +++ b/src/video/windx5/SDL_dx5events.c @@ -24,12 +24,12 @@ #include "directx.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_events.h" #include "SDL_video.h" #include "SDL_error.h" #include "SDL_syswm.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_sysevents.h" #include "SDL_events_c.h" #include "SDL_lowvideo.h" diff --git a/src/video/windx5/SDL_dx5video.c b/src/video/windx5/SDL_dx5video.c index a73efb9b3..89b1b5a75 100644 --- a/src/video/windx5/SDL_dx5video.c +++ b/src/video/windx5/SDL_dx5video.c @@ -28,12 +28,12 @@ #define CDS_FULLSCREEN 4 #endif +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_events.h" #include "SDL_syswm.h" -#include "SDL_stdlib.h" -#include "SDL_string.h" #include "SDL_sysvideo.h" #include "SDL_blit.h" #include "SDL_pixels_c.h" diff --git a/src/video/windx5/SDL_dx5yuv.c b/src/video/windx5/SDL_dx5yuv.c index 7e83931bd..0cdc59b8c 100644 --- a/src/video/windx5/SDL_dx5yuv.c +++ b/src/video/windx5/SDL_dx5yuv.c @@ -22,10 +22,10 @@ /* This is the DirectDraw implementation of YUV video overlays */ -#include "SDL_error.h" -#include "SDL_video.h" #include "SDL_stdlib.h" #include "SDL_string.h" +#include "SDL_error.h" +#include "SDL_video.h" #include "SDL_dx5yuv_c.h" #include "SDL_yuvfuncs.h" diff --git a/src/video/wscons/SDL_wsconsvideo.c b/src/video/wscons/SDL_wsconsvideo.c index d7a3f86ee..e648df3ab 100644 --- a/src/video/wscons/SDL_wsconsvideo.c +++ b/src/video/wscons/SDL_wsconsvideo.c @@ -26,13 +26,11 @@ #include #include #include -#include -#include -#include -#include #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/x11/SDL_x11dga.c b/src/video/x11/SDL_x11dga.c index 6a6665b1b..46bc0d25c 100644 --- a/src/video/x11/SDL_x11dga.c +++ b/src/video/x11/SDL_x11dga.c @@ -25,7 +25,8 @@ There will be a completely separate DGA driver that is fullscreen-only. */ -#include /* For SDL_getenv() */ +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_video.h" #include "SDL_cursor_c.h" #include "SDL_x11dga_c.h" diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 4e7247f4d..bea0db170 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -22,9 +22,6 @@ /* Handle the event stream, converting X11 events into SDL events */ -#include -#include -#include #include #include #include @@ -37,6 +34,7 @@ #include #include "SDL.h" +#include "SDL_string.h" #include "SDL_syswm.h" #include "SDL_sysevents.h" #include "SDL_sysvideo.h" diff --git a/src/video/x11/SDL_x11gl.c b/src/video/x11/SDL_x11gl.c index c1e373222..f07af7663 100644 --- a/src/video/x11/SDL_x11gl.c +++ b/src/video/x11/SDL_x11gl.c @@ -20,12 +20,11 @@ slouken@libsdl.org */ -#include /* For SDL_getenv() prototype */ -#include - -#include "SDL_events_c.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_x11video.h" +#include "SDL_events_c.h" #include "SDL_x11dga_c.h" #include "SDL_x11gl_c.h" diff --git a/src/video/x11/SDL_x11image.c b/src/video/x11/SDL_x11image.c index a6320666e..05cb9adfc 100644 --- a/src/video/x11/SDL_x11image.c +++ b/src/video/x11/SDL_x11image.c @@ -20,9 +20,11 @@ slouken@libsdl.org */ -#include +#include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_endian.h" #include "SDL_events_c.h" diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index a3da7f7a3..2c454e87a 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -22,9 +22,10 @@ /* Utilities for getting and setting the X display mode */ -#include -#include +#include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_timer.h" #include "SDL_error.h" #include "SDL_events.h" @@ -359,7 +360,7 @@ int X11_GetVideoModes(_THIS) } #endif - qsort(modes, nmodes, sizeof *modes, cmpmodes); + SDL_qsort(modes, nmodes, sizeof *modes, cmpmodes); SDL_modelist = (SDL_Rect **)SDL_malloc((nmodes+2)*sizeof(SDL_Rect *)); if ( SDL_modelist ) { n = 0; diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 989c6977e..255e0833c 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -20,13 +20,11 @@ slouken@libsdl.org */ -#include -#include -#include - #include #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_mouse.h" #include "SDL_events_c.h" diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 207bfb6a8..0635ea1eb 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -27,29 +27,16 @@ if full locking is neccessary, take a look at XInitThreads(). */ -#include -#include #include -#include #include #ifdef MTRR_SUPPORT #include #include #endif -#ifdef HAVE_ALLOCA_H -#include -#endif - -#ifdef HAVE_ALLOCA -#define ALLOCA(n) ((void*)alloca(n)) -#define FREEA(p) -#else -#define ALLOCA(n) SDL_malloc(n) -#define FREEA(p) SDL_free(p) -#endif - #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_thread.h" @@ -299,9 +286,9 @@ static char *get_classname(char *classname, int maxlen) /* Next look at the application's executable name */ #if defined(linux) || defined(__FreeBSD__) #if defined(linux) - sprintf(procfile, "/proc/%d/exe", getpid()); + SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid()); #elif defined(__FreeBSD__) - sprintf(procfile, "/proc/%d/file", getpid()); + SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file", getpid()); #else #error Where can we find the executable name? #endif @@ -1215,7 +1202,7 @@ int X11_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) /* private writable colormap: just set the colours we need */ XColor *xcmap; int i; - xcmap = ALLOCA(ncolors*sizeof(*xcmap)); + xcmap = SDL_stack_alloc(XColor, ncolors); if(xcmap == NULL) return 0; for ( i=0; iscreen->format->palette->ncolors; colors = this->screen->format->palette->colors; - freelist = ALLOCA(nc * sizeof(*freelist)); + freelist = SDL_stack_alloc(unsigned long, nc); /* make sure multiple allocations of the same cell are freed */ for(i = 0; i < ncolors; i++) { int pixel = firstcolor + i; @@ -1255,10 +1242,10 @@ int X11_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) } } pXFreeColors(GFX_Display, SDL_XColorMap, freelist, nfree, 0); - FREEA(freelist); + SDL_stack_free(freelist); - want = ALLOCA(ncolors * sizeof(SDL_Color)); - reject = ALLOCA(ncolors * sizeof(SDL_Color)); + want = SDL_stack_alloc(SDL_Color, ncolors); + reject = SDL_stack_alloc(SDL_Color, ncolors); SDL_memcpy(want, colors + firstcolor, ncolors * sizeof(SDL_Color)); /* make sure the user isn't fooled by her own wishes (black is safe, always available in the default colormap) */ @@ -1288,8 +1275,8 @@ int X11_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) } if(nrej) allocate_nearest(this, colors, reject, nrej); - FREEA(reject); - FREEA(want); + SDL_stack_free(reject); + SDL_stack_free(want); } return nrej == 0; } diff --git a/src/video/x11/SDL_x11wm.c b/src/video/x11/SDL_x11wm.c index 2cd69d04f..24f10ea60 100644 --- a/src/video/x11/SDL_x11wm.c +++ b/src/video/x11/SDL_x11wm.c @@ -20,12 +20,12 @@ slouken@libsdl.org */ -#include -#include #include #include #include "SDL_version.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_video.h" diff --git a/src/video/x11/SDL_x11yuv.c b/src/video/x11/SDL_x11yuv.c index 9e31d05e9..666b86d9f 100644 --- a/src/video/x11/SDL_x11yuv.c +++ b/src/video/x11/SDL_x11yuv.c @@ -24,8 +24,6 @@ #ifdef XFREE86_XV -#include -#include #include #ifndef NO_SHARED_MEMORY #include @@ -34,6 +32,8 @@ #endif #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_x11yuv_c.h" diff --git a/src/video/xbios/SDL_xbios.c b/src/video/xbios/SDL_xbios.c index 1607d8f4c..796e4ac3d 100644 --- a/src/video/xbios/SDL_xbios.c +++ b/src/video/xbios/SDL_xbios.c @@ -26,9 +26,6 @@ * Patrice Mandin */ -#include -#include -#include #include #include @@ -38,6 +35,8 @@ #include #include "SDL.h" +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_mouse.h" diff --git a/src/video/xbios/SDL_xbios_centscreen.c b/src/video/xbios/SDL_xbios_centscreen.c index f222a2845..5d65ee8f7 100644 --- a/src/video/xbios/SDL_xbios_centscreen.c +++ b/src/video/xbios/SDL_xbios_centscreen.c @@ -26,11 +26,10 @@ Patrice Mandin */ -#include -#include - #include +#include "SDL_stdlib.h" +#include "SDL_string.h" #include "SDL_xbios.h" #include "SDL_xbios_centscreen.h" diff --git a/src/video/xbios/SDL_xbios_sb3.c b/src/video/xbios/SDL_xbios_sb3.c index 7e05b45f2..1c34b5294 100644 --- a/src/video/xbios/SDL_xbios_sb3.c +++ b/src/video/xbios/SDL_xbios_sb3.c @@ -28,8 +28,7 @@ /*--- Includes ---*/ -#include - +#include "SDL_stdlib.h" #include "SDL_xbios.h" #include "SDL_xbios_sb3.h"