diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-10-01 17:35:17 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-10-01 17:36:29 +0300 |
commit | bdd142bc022b131db7435a9d01ceaf1fdb1d8f24 (patch) | |
tree | b6be39f3800d39c801fa128bb21e956d208a0f9a /source/blender/blenlib/intern/stack.c | |
parent | 2bddf44b117b0dc0d2443a0d21ab2d1103e87e5e (diff) |
Cleanup: convert some macros to functions
Diffstat (limited to 'source/blender/blenlib/intern/stack.c')
-rw-r--r-- | source/blender/blenlib/intern/stack.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/blenlib/intern/stack.c b/source/blender/blenlib/intern/stack.c index 76aef3761ae..301675c026e 100644 --- a/source/blender/blenlib/intern/stack.c +++ b/source/blender/blenlib/intern/stack.c @@ -36,10 +36,6 @@ /* ensure we get at least this many elems per chunk */ #define CHUNK_ELEM_MIN 32 -/* Gets the last element in the stack */ -#define CHUNK_LAST_ELEM(_stack) \ - ((void)0, (((char *)(_stack)->chunk_curr->data) + ((_stack)->elem_size * (_stack)->chunk_index))) - struct StackChunk { struct StackChunk *next; char data[0]; @@ -56,6 +52,11 @@ struct BLI_Stack { #endif }; +static void *stack_get_last_elem(BLI_Stack *stack) +{ + return ((char *)(stack)->chunk_curr->data) + ((stack)->elem_size * (stack)->chunk_index); +} + /** * \return number of elements per chunk, optimized for slop-space. */ @@ -148,7 +149,7 @@ void *BLI_stack_push_r(BLI_Stack *stack) #endif /* Return end of stack */ - return CHUNK_LAST_ELEM(stack); + return stack_get_last_elem(stack); } /** @@ -175,7 +176,7 @@ void BLI_stack_pop(BLI_Stack *stack, void *dst) { BLI_assert(BLI_stack_is_empty(stack) == false); - memcpy(dst, CHUNK_LAST_ELEM(stack), stack->elem_size); + memcpy(dst, stack_get_last_elem(stack), stack->elem_size); BLI_stack_discard(stack); } @@ -220,7 +221,7 @@ void *BLI_stack_peek(BLI_Stack *stack) { BLI_assert(BLI_stack_is_empty(stack) == false); - return CHUNK_LAST_ELEM(stack); + return stack_get_last_elem(stack); } /** |