Small stack allocations fall back to malloc if they're unexpectedly large.

This commit is contained in:
Ryan C. Gordon 2018-10-22 20:50:32 -04:00
parent eedf2c965d
commit b262b0ebc9
19 changed files with 84 additions and 52 deletions

View file

@ -35,6 +35,10 @@
#define SDL_VARIABLE_LENGTH_ARRAY
#endif
#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128
#define SDL_small_alloc(type, count, pisstack) ( (*(pisstack) = ((sizeof(type)*(count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type*)SDL_malloc(sizeof(type)*(count))) )
#define SDL_small_free(ptr, isstack) if ((isstack)) { SDL_stack_free(ptr); } else { SDL_free(ptr); }
#include "dynapi/SDL_dynapi.h"
#if SDL_DYNAMIC_API