Mercurial > sdl-ios-xcode
diff src/video/windx5/SDL_dx5video.c @ 1330:450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
using Visual C++ 2005
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 06 Feb 2006 08:28:51 +0000 |
parents | c9b51268668f |
children | 3692456e7b0f |
line wrap: on
line diff
--- a/src/video/windx5/SDL_dx5video.c Sat Feb 04 22:01:44 2006 +0000 +++ b/src/video/windx5/SDL_dx5video.c Mon Feb 06 08:28:51 2006 +0000 @@ -20,10 +20,7 @@ slouken@libsdl.org */ -#include <stdio.h> -#include <stdlib.h> -#include <malloc.h> -#include <windows.h> +#include "SDL_windows.h" #include "directx.h" /* Not yet in the mingw32 cross-compile headers */ @@ -35,6 +32,8 @@ #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" @@ -810,12 +809,13 @@ error = "Interface not present"; break; default: - sprintf(errbuf, "%s: Unknown DirectDraw error: 0x%x", + snprintf(errbuf, SDL_arraysize(errbuf), + "%s: Unknown DirectDraw error: 0x%x", function, code); break; } if ( ! errbuf[0] ) { - sprintf(errbuf, "%s: %s", function, error); + snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error); } SDL_SetError("%s", errbuf); return; @@ -1109,7 +1109,8 @@ settings.dmPelsWidth = width; settings.dmPelsHeight = height; settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; - if ( width <= SDL_desktop_mode.dmPelsWidth && height <= SDL_desktop_mode.dmPelsHeight ) { + if ( width <= (int)SDL_desktop_mode.dmPelsWidth && + height <= (int)SDL_desktop_mode.dmPelsHeight ) { settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency; settings.dmFields |= DM_DISPLAYFREQUENCY; } @@ -2170,7 +2171,7 @@ } #else /* Allocate memory for the arrays we use */ - pool = (int *)alloca(2*ncolors*sizeof(int)); + pool = SDL_stack_alloc(int, 2*ncolors); if ( pool == NULL ) { /* No worries, just return */; return; @@ -2217,6 +2218,7 @@ SDL_colors[j].peGreen = colors[order[i]].g; SDL_colors[j].peBlue = colors[order[i]].b; } + SDL_stack_free(pool); #endif /* SIMPLE_COMPRESSION */ } @@ -2458,12 +2460,12 @@ if ( palette == NULL ) { /* Sometimes we don't have a palette */ return; } - entries = (PALETTEENTRY *)alloca(palette->ncolors*sizeof(*entries)); + entries = SDL_stack_alloc(PALETTEENTRY, palette->ncolors); hdc = GetDC(window); GetSystemPaletteEntries(hdc, 0, palette->ncolors, entries); ReleaseDC(window, hdc); if ( ! colorchange_expected ) { - saved = (SDL_Color *)alloca(palette->ncolors*sizeof(SDL_Color)); + saved = SDL_stack_alloc(SDL_Color, palette->ncolors); memcpy(saved, palette->colors, palette->ncolors*sizeof(SDL_Color)); } @@ -2472,6 +2474,7 @@ palette->colors[i].g = entries[i].peGreen; palette->colors[i].b = entries[i].peBlue; } + SDL_stack_free(entries); if ( ! colorchange_expected ) { Uint8 mapping[256]; @@ -2481,6 +2484,7 @@ saved[i].r, saved[i].g, saved[i].b); } DX5_Recolor8Bit(this, SDL_VideoSurface, mapping); + SDL_stack_free(saved); } colorchange_expected = 0;