diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-28 13:05:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-28 13:05:27 +0400 |
commit | 72f29170325e6c01afb667be209ea5939b445551 (patch) | |
tree | f90b3b8abe870095fad06178c31ed94289099276 /source/blender/blenlib/BLI_array.h | |
parent | b5890b35198add206e47b7edb523b7c4ff1fcf12 (diff) |
bmesh: skip error checks when building in release mode (minor speedup),
also more strict use of BLI_array_declare(), only allow after array is declared.
Diffstat (limited to 'source/blender/blenlib/BLI_array.h')
-rw-r--r-- | source/blender/blenlib/BLI_array.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index 3fb50afdeac..252b37d9aae 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -66,8 +66,9 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static, /* -------------------------------------------------------------------- */ /* public defines */ +/* use sizeof(*arr) to ensure the array exists and is an array */ #define BLI_array_declare(arr) \ - int _##arr##_count = 0; \ + int _##arr##_count = ((void)(sizeof(*arr)), 0); \ void *_##arr##_static = NULL /* this will use stack space, up to maxstatic array elements, before @@ -148,8 +149,8 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static, /* only to prevent unused warnings */ #define BLI_array_fake_user(arr) \ - (void)_##arr##_count, \ - (void)_##arr##_static + ((void)_##arr##_count, \ + (void)_##arr##_static) /* -------------------------------------------------------------------- */ @@ -161,7 +162,7 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static, * but use when the max size is known ahead of time */ #define BLI_array_fixedstack_declare(arr, maxstatic, realsize, allocstr) \ char _##arr##_static[maxstatic * sizeof(*(arr))]; \ - const int _##arr##_is_static = ((void *)_##arr##_static) != ( \ + const bool _##arr##_is_static = ((void *)_##arr##_static) != ( \ arr = ((realsize) <= maxstatic) ? \ (void *)_##arr##_static : \ MEM_mallocN(sizeof(*(arr)) * (realsize), allocstr) \ |