sdl2-compat: events: SDL_PeepEvents should small_alloc its temporary SDL3 event array.

From d1e842e714ba2129a31377955d0a0a688cf384c3 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 11 Nov 2024 21:23:10 -0500
Subject: [PATCH] events: SDL_PeepEvents should small_alloc its temporary SDL3
 event array.

Most of this will likely get away with stack allocation for speed, but it
protects against extremely large allocation needs too.
---
 src/sdl2_compat.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 84c6afb..bcf8d22 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -1753,7 +1753,8 @@ SDL_GetEventFilter(SDL2_EventFilter *filter2, void **userdata)
 SDL_DECLSPEC int SDLCALL
 SDL_PeepEvents(SDL2_Event *events2, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType)
 {
-    SDL_Event *events3 = (SDL_Event *) SDL3_malloc(numevents * sizeof (SDL_Event));
+    int isstack = 0;
+    SDL_Event *events3 = SDL3_small_alloc(SDL_Event, numevents ? numevents : 1, &isstack);
     int retval = 0;
     int i;
 
@@ -1772,7 +1773,7 @@ SDL_PeepEvents(SDL2_Event *events2, int numevents, SDL_eventaction action, Uint3
         }
     }
 
-    SDL3_free(events3);
+    SDL3_small_free(events3, isstack);
     return retval;
 }