Small stack allocations fall back to malloc if they're unexpectedly large.
--HG-- branch : SDL-ryan-batching-renderer
This commit is contained in:
parent
1c7254cb58
commit
637cfa5d6b
19 changed files with 84 additions and 52 deletions
|
@ -203,13 +203,14 @@ static void UpdateEventsForDeviceRemoval()
|
|||
{
|
||||
int i, num_events;
|
||||
SDL_Event *events;
|
||||
SDL_bool isstack;
|
||||
|
||||
num_events = SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEADDED);
|
||||
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;
|
||||
}
|
||||
|
@ -220,7 +221,7 @@ static void UpdateEventsForDeviceRemoval()
|
|||
}
|
||||
SDL_PeepEvents(events, num_events, SDL_ADDEVENT, 0, 0);
|
||||
|
||||
SDL_stack_free(events);
|
||||
SDL_small_free(events, isstack);
|
||||
}
|
||||
|
||||
static SDL_bool HasSameOutput(SDL_ExtendedGameControllerBind *a, SDL_ExtendedGameControllerBind *b)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue