mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-19 01:38:12 +00:00
Small stack allocations fall back to malloc if they're unexpectedly large.
This commit is contained in:
@@ -752,13 +752,14 @@ static void UpdateEventsForDeviceRemoval()
|
||||
{
|
||||
int i, num_events;
|
||||
SDL_Event *events;
|
||||
SDL_bool isstack;
|
||||
|
||||
num_events = SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEADDED);
|
||||
if (num_events <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
events = SDL_stack_alloc(SDL_Event, num_events);
|
||||
events = SDL_small_alloc(SDL_Event, num_events, &isstack);
|
||||
if (!events) {
|
||||
return;
|
||||
}
|
||||
@@ -769,7 +770,7 @@ static void UpdateEventsForDeviceRemoval()
|
||||
}
|
||||
SDL_PeepEvents(events, num_events, SDL_ADDEVENT, 0, 0);
|
||||
|
||||
SDL_stack_free(events);
|
||||
SDL_small_free(events, isstack);
|
||||
}
|
||||
|
||||
void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
|
||||
|
Reference in New Issue
Block a user