mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-31 02:43:38 +00:00
Small stack allocations fall back to malloc if they're unexpectedly large.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_bool isstack;
|
||||
size_t size;
|
||||
LPBITMAPINFO info;
|
||||
HBITMAP hbm;
|
||||
@@ -41,7 +42,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
|
||||
|
||||
/* Find out the format of the screen */
|
||||
size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD);
|
||||
info = (LPBITMAPINFO)SDL_stack_alloc(Uint8, size);
|
||||
info = (LPBITMAPINFO)SDL_small_alloc(Uint8, size, &isstack);
|
||||
if (!info) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
@@ -85,7 +86,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
|
||||
|
||||
data->mdc = CreateCompatibleDC(data->hdc);
|
||||
data->hbm = CreateDIBSection(data->hdc, info, DIB_RGB_COLORS, pixels, NULL, 0);
|
||||
SDL_stack_free(info);
|
||||
SDL_small_free(info, isstack);
|
||||
|
||||
if (!data->hbm) {
|
||||
return WIN_SetError("Unable to create DIB");
|
||||
|
||||
Reference in New Issue
Block a user