Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_stack.h
Go to the documentation of this file.
1#ifndef VL_STACK_H
2#define VL_STACK_H
3
4#include "vl_buffer.h"
5
7
26
35void vlStackInit(vl_stack* stack);
36
46void vlStackFree(vl_stack* stack);
47
55
63void vlStackDelete(vl_stack* stack);
64
73void vlStackReset(vl_stack* stack);
74
92
110vl_stack_offset vlStackPushValue(vl_stack* stack, const void* data, vl_memsize_t size);
111
122
133
145
146#ifndef vlStackSize
147
154#define vlStackSize(stackPtr) ((stackPtr)->depth)
155#endif
156
157#ifndef vlStackEmpty
164#define vlStackEmpty(stackPtr) ((stackPtr)->depth == 0)
165#endif
166
178
185void vlStackPop(vl_stack* stack);
186
187#endif //VL_STACK_H
A multi-purpose byte buffer.
Definition vl_buffer.h:19
VL_MEMORY_SIZE_T vl_memsize_t
Definition vl_memory.h:18
VL_MEMORY_T vl_transient
Definition vl_memory.h:85
VL_UPTR_T vl_uintptr_t
Unsigned integer type suitable for expressing memory addresses.
Definition vl_numtypes.h:101
VL_STRUCTURE_INDEX_T vl_dsidx_t
Index type for data structures.
Definition vl_numtypes.h:13
VL_STRUCTURE_OFFSET_T vl_dsoffs_t
Byte offset type for data structures.
Definition vl_numtypes.h:8
void vlStackInit(vl_stack *stack)
Definition vl_stack.c:14
void vlStackPop(vl_stack *stack)
Pops the top level of the stack, allowing it to be overwritten in the future.
Definition vl_stack.c:81
void vlStackReset(vl_stack *stack)
Resets the specified stack allocator, allowing it to be used as if it had just been initialized.
Definition vl_stack.c:39
vl_memsize_t vlStackPeekSize(vl_stack *stack)
Returns the size of the top level of the stack, in bytes.
Definition vl_stack.c:76
void vlStackDelete(vl_stack *stack)
Deletes the specified stack. This stack allocator should be initialized via vlStackNew.
Definition vl_stack.c:34
vl_stack_offset vlStackPushValue(vl_stack *stack, const void *data, vl_memsize_t size)
Reserves and assigns new block of memory at the top of the stack, returning its offset.
Definition vl_stack.c:57
vl_transient * vlStackSample(vl_stack *stack, vl_stack_offset offset)
Samples the stack at the specified offset.
Definition vl_stack.c:63
vl_uintptr_t headOffset
Definition vl_stack.h:23
vl_stack * vlStackNew()
Allocates on the heap, initializes, and returns a stack allocator instance.
Definition vl_stack.c:28
vl_stack_offset vlStackPush(vl_stack *stack, vl_memsize_t size)
Reserves a new block of memory at the top of the stack, returning its offset.
Definition vl_stack.c:45
vl_buffer buffer
Definition vl_stack.h:24
vl_dsoffs_t vl_stack_offset
Definition vl_stack.h:6
vl_dsidx_t depth
Definition vl_stack.h:22
vl_memsize_t vlStackSampleSize(vl_stack *stack, vl_stack_offset offset)
Samples the size of the stack level at the specified offset.
Definition vl_stack.c:67
void vlStackFree(vl_stack *stack)
Frees the specified stack instance's allocation.
Definition vl_stack.c:24
vl_transient * vlStackPeek(vl_stack *stack)
Returns a pointer to the top level of the stack.
Definition vl_stack.c:72
A virtual stack allocator.
Definition vl_stack.h:21