From 71730f26d7c816854a471c9733ad4c10b88fd357 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Dec 2012 15:10:19 +0000 Subject: replace BLI_array_fixedstack_declare with() new macro BLI_array_alloca() which uses stack memory always and doesn't need to be freed explicitly. --- source/blender/blenlib/BLI_array.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source/blender/blenlib/BLI_array.h') diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index a21778307c1..975476a669b 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -196,3 +196,22 @@ if (_##arr##_is_static) { \ MEM_freeN(arr); \ } (void)0 + + +/* alloca */ +#if defined(__GNUC__) || defined(__clang__) +#define BLI_array_alloca(arr, realsize) \ + (typeof(arr))alloca(sizeof(*arr) * (realsize)) + +#define BLI_array_alloca_and_count(arr, realsize) \ + (typeof(arr))alloca(sizeof(*arr) * (realsize)); \ + const int _##arr##_count = (realsize) + +#else +#define BLI_array_alloca(arr, realsize) \ + alloca(sizeof(*arr) * (realsize)) + +#define BLI_array_alloca_and_count(arr, realsize) \ + alloca(sizeof(*arr) * (realsize)); \ + const int _##arr##_count = (realsize) +#endif -- cgit v1.2.3