diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-06-28 17:07:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-06-28 17:17:11 +0400 |
commit | dcc361708c3a8af16d433ce0326e292f8d4732cc (patch) | |
tree | 519774ea6125c00f84ab3dfa4be3d2fa80c325a6 /source/blender/blenlib/intern/stack.c | |
parent | c0c75ff1ac742ac7871e3c67a56ffe71ff5d918d (diff) |
BLI_stack: use strict flags
also use size_t, rename BLI_stack_empty
Diffstat (limited to 'source/blender/blenlib/intern/stack.c')
-rw-r--r-- | source/blender/blenlib/intern/stack.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/stack.c b/source/blender/blenlib/intern/stack.c index 5be2ed941a7..b0177cce642 100644 --- a/source/blender/blenlib/intern/stack.c +++ b/source/blender/blenlib/intern/stack.c @@ -28,21 +28,23 @@ #include <string.h> #include <stdlib.h> /* abort() */ -#include "BLI_stack.h" /* own include */ - #include "BLI_utildefines.h" #include "MEM_guardedalloc.h" +#include "BLI_stack.h" /* own include */ + +#include "BLI_strict_flags.h" + struct BLI_Stack { void *data; - int totelem; - int maxelem; + size_t totelem; + size_t maxelem; - int elem_size; + size_t elem_size; }; -BLI_Stack *BLI_stack_new(int elem_size, const char *description) +BLI_Stack *BLI_stack_new(size_t elem_size, const char *description) { BLI_Stack *stack = MEM_callocN(sizeof(*stack), description); @@ -74,11 +76,11 @@ void BLI_stack_push(BLI_Stack *stack, void *src) * number of elements */ stack->maxelem = 32; stack->data = MEM_mallocN((stack->elem_size * - stack->maxelem), AT); + stack->maxelem), __func__); } else { /* Double stack size */ - int maxelem = stack->maxelem + stack->maxelem; + size_t maxelem = stack->maxelem + stack->maxelem; /* Check for overflow */ BLI_assert(maxelem > stack->maxelem); stack->data = MEM_reallocN(stack->data, @@ -104,7 +106,7 @@ void BLI_stack_pop(BLI_Stack *stack, void *dst) } } -int BLI_stack_empty(const BLI_Stack *stack) +bool BLI_stack_is_empty(const BLI_Stack *stack) { return stack->totelem == 0; } |