Go to the documentation of this file.
11 #ifndef __UT_StackAlloc__
12 #define __UT_StackAlloc__
19 #if defined(LINUX) || defined(MBSD)
28 #define UT_STACK_LIMIT 131072
31 #define UT_STACK_ALLOCA 100
32 #define UT_STACK_MALLOC 200
34 #define UTstackAlloc(size) (void *)(&((size < UT_STACK_LIMIT) ? \
35 (*((int32 *)::alloca(size+2*sizeof(int32))) = UT_STACK_ALLOCA) : \
36 (*((int32 *)::malloc(size+2*sizeof(int32))) = UT_STACK_MALLOC)) + 2)
38 #define UTstackFree(ptr) \
41 *((int32 *)ptr - 2) == UT_STACK_MALLOC || \
42 *((int32 *)ptr - 2) == UT_STACK_ALLOCA); \
43 if (ptr && (*((int32 *)ptr - 2) == UT_STACK_MALLOC)) \
44 ::free(((int32 *)ptr - 2)); \