BLI_stack: various small additions

- add BLI_stack_count
- add BLI_stack_pop_n to pop into an array
- add BLI_stack_push_r, which returns a pointer that can be filled in

Also remove sanity check in BLI_stack_pop, assert if the stack is empty.
This commit is contained in:
2014-07-15 20:37:06 +10:00
parent a378f8d2d8
commit 5c4180d898
3 changed files with 75 additions and 21 deletions

View File

@@ -34,16 +34,20 @@ typedef struct BLI_Stack BLI_Stack;
BLI_Stack *BLI_stack_new_ex(
const size_t elem_size, const char *description,
const size_t chunk_size) ATTR_NONNULL();
const size_t chunk_size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BLI_Stack *BLI_stack_new(
const size_t elem_size, const char *description) ATTR_NONNULL();
const size_t elem_size, const char *description) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BLI_stack_free(BLI_Stack *stack) ATTR_NONNULL();
void BLI_stack_push(BLI_Stack *stack, const void *src) ATTR_NONNULL();
void *BLI_stack_push_r(BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BLI_stack_push(BLI_Stack *stack, const void *src) ATTR_NONNULL();
void BLI_stack_pop_n(BLI_Stack *stack, void *dst, unsigned int n) ATTR_NONNULL();
void BLI_stack_pop(BLI_Stack *stack, void *dst) ATTR_NONNULL();
bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_NONNULL();
size_t BLI_stack_count(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
#endif
bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
#endif /* __BLI_STACK_H__ */