diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-13 14:12:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-13 14:12:07 +0400 |
commit | ad9af56a6e475217343b55bbdedb2ae30802fdfc (patch) | |
tree | 0bd67fd64e2cdddc5fc11fa66e52dc92c7b15230 /source/blender/blenlib | |
parent | 2025e4cbb9772ad6c72b56ad28e5bdd62d596b9a (diff) |
LinkList stack macros to swap and pop into a separate stack.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_linklist_stack.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h index ce82ab491c3..1933dd733c3 100644 --- a/source/blender/blenlib/BLI_linklist_stack.h +++ b/source/blender/blenlib/BLI_linklist_stack.h @@ -136,17 +136,25 @@ } (void)0 /* internal use, no null check */ +#define _BLI_SMALLSTACK_DEL_EX(var_src, var_dst) \ + (void)((_##var_src##_temp = _##var_src##_stack->next), \ + (_##var_src##_stack->next = _##var_dst##_free), \ + (_##var_dst##_free = _##var_src##_stack), \ + (_##var_src##_stack = _##var_src##_temp)) \ + #define _BLI_SMALLSTACK_DEL(var) \ - (void)((_##var##_temp = _##var##_stack->next), \ - (_##var##_stack->next = _##var##_free), \ - (_##var##_free = _##var##_stack), \ - (_##var##_stack = _##var##_temp)) \ + _BLI_SMALLSTACK_DEL_EX(var, var) \ /* check for typeof() */ #define BLI_SMALLSTACK_POP(var) \ (_BLI_SMALLSTACK_CAST(var) ((_##var##_stack) ? \ (_BLI_SMALLSTACK_DEL(var), (_##var##_free->link)) : NULL)) +/* support to put the free-node into another stack */ +#define BLI_SMALLSTACK_POP_EX(var_src, var_dst) \ + (_BLI_SMALLSTACK_CAST(var_src) ((_##var_src##_stack) ? \ + (_BLI_SMALLSTACK_DEL_EX(var_src, var_dst), (_##var_dst##_free->link)) : NULL)) + /* loop over stack members last-added-first */ #define BLI_SMALLSTACK_ITER_BEGIN(var, item) \ { \ @@ -158,6 +166,13 @@ } \ } (void)0 +#define BLI_SMALLSTACK_SWAP(var_a, var_b) \ +{ \ + CHECK_TYPE_PAIR(_##var_a##_type, _##var_b##_type); \ + SWAP(LinkNode *, _##var_a##_stack, _##var_b##_stack); \ + SWAP(LinkNode *, _##var_a##_free, _##var_b##_free); \ +} (void)0 + #define BLI_SMALLSTACK_FREE(var) { \ (void)&(_##var##_type); \ } (void)0 |