diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-04 05:14:20 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-04 05:18:33 +0400 |
commit | a039f2bfc468ae293b1aa3643419f91c1723f5c9 (patch) | |
tree | d457662bbc02be1269c9007ed3d585c9291d2473 /source/blender/blenlib/BLI_stackdefines.h | |
parent | cc28e02a85d137d923045b29e584e9264da74c0d (diff) |
Macros: prevent instantiation of args for type checks
also make CHECK_TYPE_INLINE more strict
Diffstat (limited to 'source/blender/blenlib/BLI_stackdefines.h')
-rw-r--r-- | source/blender/blenlib/BLI_stackdefines.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_stackdefines.h b/source/blender/blenlib/BLI_stackdefines.h index 24cb043cd43..da9bf5ea04c 100644 --- a/source/blender/blenlib/BLI_stackdefines.h +++ b/source/blender/blenlib/BLI_stackdefines.h @@ -36,7 +36,7 @@ # define _STACK_SWAP_TOTALLOC(stack_a, stack_b) SWAP(unsigned int, _##stack_a##_totalloc, _##stack_b##_totalloc) #else # define STACK_DECLARE(stack) unsigned int _##stack##_index -# define STACK_INIT(stack, tot) ((void)stack, (void)((_##stack##_index) = 0), (void)(tot)) +# define STACK_INIT(stack, tot) ((void)stack, (void)((_##stack##_index) = 0), (void)(0 ? tot : 0)) # define _STACK_SIZETEST(stack, off) (void)(stack), (void)(off) # define _STACK_SWAP_TOTALLOC(stack_a, stack_b) (void)(stack_a), (void)(stack_b) #endif @@ -57,9 +57,12 @@ #define STACK_PEEK_PTR(stack) (BLI_assert(_##stack##_index), &((stack)[_##stack##_index - 1])) /** remove any item from the stack, take care, re-orders */ #define STACK_REMOVE(stack, i) \ - _STACK_BOUNDSTEST(stack, i); \ - if (--_##stack##_index != i) { \ - stack[i] = stack[_##stack##_index]; \ + { \ + const unsigned int _i = i; \ + _STACK_BOUNDSTEST(stack, _i); \ + if (--_##stack##_index != _i) { \ + stack[_i] = stack[_##stack##_index]; \ + } \ } (void)0 #ifdef __GNUC__ #define STACK_SWAP(stack_a, stack_b) { \ |