From c8c7d04d69d62f6c220af8ec5a401a17c6082295 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Dec 2015 19:48:18 +1100 Subject: Add STACK_CLEAR macro --- source/blender/blenlib/BLI_stackdefines.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/BLI_stackdefines.h b/source/blender/blenlib/BLI_stackdefines.h index 2d8d6e4482d..b26dc3e26aa 100644 --- a/source/blender/blenlib/BLI_stackdefines.h +++ b/source/blender/blenlib/BLI_stackdefines.h @@ -44,6 +44,7 @@ #define STACK_SIZE(stack) ((void)stack, (_##stack##_index)) +#define STACK_CLEAR(stack) {(void)stack; _##stack##_index = 0; } ((void)0) /** add item to stack */ #define STACK_PUSH(stack, val) ((void)stack, _STACK_SIZETEST(stack, 1), ((stack)[(_##stack##_index)++] = val)) #define STACK_PUSH_RET(stack) ((void)stack, _STACK_SIZETEST(stack, 1), ((stack)[(_##stack##_index)++])) @@ -63,26 +64,26 @@ if (--_##stack##_index != _i) { \ stack[_i] = stack[_##stack##_index]; \ } \ - } (void)0 + } ((void)0) #define STACK_DISCARD(stack, n) \ { \ const unsigned int _n = n; \ BLI_assert(_##stack##_index >= _n); \ (void)stack; \ _##stack##_index -= _n; \ - } (void)0 + } ((void)0) #ifdef __GNUC__ #define STACK_SWAP(stack_a, stack_b) { \ SWAP(typeof(stack_a), stack_a, stack_b); \ SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \ _STACK_SWAP_TOTALLOC(stack_a, stack_b); \ - } (void)0 + } ((void)0) #else #define STACK_SWAP(stack_a, stack_b) { \ SWAP(void *, stack_a, stack_b); \ SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \ _STACK_SWAP_TOTALLOC(stack_a, stack_b); \ - } (void)0 + } ((void)0) #endif #endif /* __BLI_STACKDEFINES_H__ */ -- cgit v1.2.3