diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-06-30 05:44:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-06-30 05:55:01 +0400 |
commit | 5588e45f0197694d14ba92b6097ccdfbb8e1ed66 (patch) | |
tree | 58f83344d1a5f7898ad8f230b445e17ca7274639 /source/blender/blenlib/BLI_stack.h | |
parent | 228361973dcbefbc89d9dfeff40444bbcb8a3ae2 (diff) |
BLI_stack, use memory chunks rather then realloc when resizing
Diffstat (limited to 'source/blender/blenlib/BLI_stack.h')
-rw-r--r-- | source/blender/blenlib/BLI_stack.h | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/source/blender/blenlib/BLI_stack.h b/source/blender/blenlib/BLI_stack.h index ac96195d390..d65c8f02462 100644 --- a/source/blender/blenlib/BLI_stack.h +++ b/source/blender/blenlib/BLI_stack.h @@ -28,27 +28,22 @@ * \ingroup bli */ +#include "BLI_compiler_attrs.h" + typedef struct BLI_Stack BLI_Stack; -/* Create a new homogeneous stack with elements of 'elem_size' bytes */ -BLI_Stack *BLI_stack_new(size_t elem_size, const char *description); +BLI_Stack *BLI_stack_new_ex( + const size_t elem_size, const char *description, + const size_t chunk_size) ATTR_NONNULL(); +BLI_Stack *BLI_stack_new( + const size_t elem_size, const char *description) ATTR_NONNULL(); -/* Free the stack's data and the stack itself */ -void BLI_stack_free(BLI_Stack *stack); +void BLI_stack_free(BLI_Stack *stack) ATTR_NONNULL(); -/* Copies the source value onto the stack (note that it copies - * elem_size bytes from 'src', the pointer itself is not stored) */ -void BLI_stack_push(BLI_Stack *stack, void *src); +void BLI_stack_push(BLI_Stack *stack, const void *src) ATTR_NONNULL(); -/* Retrieves and removes the top element from the stack. The value is - * copies to 'dst', which must be at least elem_size bytes. - * - * Does not reduce amount of allocated memory. - * - * If stack is empty, 'dst' will not be modified. */ -void BLI_stack_pop(BLI_Stack *stack, void *dst); +void BLI_stack_pop(BLI_Stack *stack, void *dst) ATTR_NONNULL(); -/* Returns true if the stack is empty, false otherwise */ -bool BLI_stack_is_empty(const BLI_Stack *stack); +bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_NONNULL(); #endif |