Use SDL_small_alloc() instead of SDL_stack_alloc() in CreateMaskBitmap()

This commit is contained in:
Dimitriy Ryazantcev
2023-11-21 14:09:41 +02:00
committed by Sam Lantinga
parent b76f8de298
commit 91e122316c

View File

@@ -114,15 +114,16 @@ static HBITMAP CreateColorBitmap(SDL_Surface *surface)
static HBITMAP CreateMaskBitmap(SDL_Surface *surface) static HBITMAP CreateMaskBitmap(SDL_Surface *surface)
{ {
HBITMAP bitmap; HBITMAP bitmap;
SDL_bool isstack;
void *pixels; void *pixels;
int x, y; int x, y;
Uint8 *src, *dst; Uint8 *src, *dst;
const int pitch = (((surface->w + 15) & ~15) / 8); const int pitch = ((surface->w + 15) & ~15) / 8;
static const unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 }; static const unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 };
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
pixels = SDL_stack_alloc(Uint8, pitch * surface->h); pixels = SDL_small_alloc(Uint8, pitch * surface->h, &isstack);
if (!pixels) { if (!pixels) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
@@ -148,7 +149,7 @@ static HBITMAP CreateMaskBitmap(SDL_Surface *surface)
SDL_UnlockSurface(surface); SDL_UnlockSurface(surface);
bitmap = CreateBitmap(surface->w, surface->h, 1, 1, pixels); bitmap = CreateBitmap(surface->w, surface->h, 1, 1, pixels);
SDL_stack_free(pixels); SDL_small_free(pixels, isstack);
if (!bitmap) { if (!bitmap) {
WIN_SetError("CreateBitmap()"); WIN_SetError("CreateBitmap()");
return NULL; return NULL;