Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-12-11 19:10:19 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-11 19:10:19 +0400
commit71730f26d7c816854a471c9733ad4c10b88fd357 (patch)
tree0201ace6eac1fd2f48ae404bda6ea552cc1259d4 /source/blender/blenlib/BLI_array.h
parent3520dd56e3894d2b5c825dc98cdd5d846b6756c0 (diff)
replace BLI_array_fixedstack_declare with() new macro BLI_array_alloca() which uses stack memory always and doesn't need to be freed explicitly.
Diffstat (limited to 'source/blender/blenlib/BLI_array.h')
-rw-r--r--source/blender/blenlib/BLI_array.h19
1 files changed, 19 insertions, 0 deletions
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