diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-12-24 11:48:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-12-24 12:05:45 +0300 |
commit | c8c7d04d69d62f6c220af8ec5a401a17c6082295 (patch) | |
tree | 548cedd1d9fba0bc4390b134ef206d786c2a290f | |
parent | 8e07b878660550b8c3fbbdb5a2890b91b85aecaa (diff) |
Add STACK_CLEAR macro
-rw-r--r-- | source/blender/blenlib/BLI_stackdefines.h | 9 |
1 files 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__ */ |