From aca8c24c3af6711cd0d020c30dad75606e15b4de Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 11 Jan 2020 15:40:40 +0100 Subject: [PATCH] Assertions in _alloca() and _alloca16() for too big stack allocations not on Windows though, for some reason MSVC doesn't like my ugly hack to add an assert() to the _alloca16() macro :-/ --- neo/renderer/Image_init.cpp | 2 +- neo/sys/platform.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/neo/renderer/Image_init.cpp b/neo/renderer/Image_init.cpp index baed7c66..b231bdbc 100644 --- a/neo/renderer/Image_init.cpp +++ b/neo/renderer/Image_init.cpp @@ -1197,7 +1197,7 @@ void R_ListImages_f( const idCmdArgs &args ) { totalSize = 0; - sortedImage_t *sortedArray = (sortedImage_t *)alloca( sizeof( sortedImage_t ) * globalImages->images.Num() ); + sortedImage_t *sortedArray = (sortedImage_t *)_alloca( sizeof( sortedImage_t ) * globalImages->images.Num() ); for ( i = 0 ; i < globalImages->images.Num() ; i++ ) { image = globalImages->images[ i ]; diff --git a/neo/sys/platform.h b/neo/sys/platform.h index 2c4ce984..1910ad4b 100644 --- a/neo/sys/platform.h +++ b/neo/sys/platform.h @@ -136,8 +136,8 @@ If you have questions concerning this license or the applicable additional terms // Unix #ifdef __unix__ -#define _alloca alloca -#define _alloca16( x ) ((void *)((((uintptr_t)alloca( (x)+15 )) + 15) & ~15)) +#define _alloca( x ) (({assert( (x)<600000 );}), alloca( (x) )) +#define _alloca16( x ) (({assert( (x)<600000 );}),((void *)((((uintptr_t)alloca( (x)+15 )) + 15) & ~15))) #ifdef GAME_DLL #define ID_GAME_API __attribute__((visibility ("default")))