61 Free((*stack)->stack_array);
72 if (!stack)
return false;
82 if (!stack)
return false;
101 if (position >= stack->
tail && position < stack->head && position < stack->size && stack->
stack_array[position].
is_set) {
104 }
else if (stack->
tail > stack->
head) {
105 if ((position >= stack->
tail || position < stack->head) && position < stack->size && stack->
stack_array[position].
is_set) {
126 size_t next_pos = (stack->
head + 1) % stack->
size;
129 if (next_pos == stack->
tail) {
166 next_pos = (stack->
tail + 1) % stack->
size;
171 prev_pos = stack->
tail;
173 stack->
tail = next_pos;
192 stack->
head = next_pos;
220 (*status) = pop_status;
241 stack->
head = next_pos;
269 (*status) = pop_status;
290 stack->
head = next_pos;
318 (*status) = pop_status;
339 stack->
head = next_pos;
367 (*status) = pop_status;
388 stack->
head = next_pos;
416 (*status) = pop_status;
437 stack->
head = next_pos;
465 (*status) = pop_status;
486 stack->
head = next_pos;
514 (*status) = pop_status;
535 stack->
head = next_pos;
563 (*status) = pop_status;
586 stack->
head = next_pos;
614 (*status) = pop_status;
637bool stack_push_ui64(
STACK* stack, uint64_t ui64) {
646 stack->
head = next_pos;
657uint64_t stack_pop_ui64(
STACK* stack, uint8_t* status) {
674 (*status) = pop_status;
686bool stack_push_i64(
STACK* stack, int64_t i64) {
695 stack->
head = next_pos;
706int64_t stack_pop_i64(
STACK* stack, uint8_t* status) {
723 (*status) = pop_status;
#define Malloc(__ptr, __struct, __size)
Malloc Handler to get errors and set to 0.
#define __n_assert(__ptr, __ret)
macro to assert things
#define Free(__ptr)
Free Handler to get errors.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
size_t tail
position of tail
bool is_empty
is item empty ?
size_t head
position of head
size_t nb_items
number of item inside stack
STACK_ITEM * stack_array
STACK_ITEM array.
uint16_t p_type
if v_type is STACK_ITEM_PTR, user defined pointer type
union STACK_DATA data
union of different types
size_t size
Size of array.
uint8_t v_type
type of the item
uint32_t ui32
unsigned int 32
uint8_t ui8
unsigned int 8
bool stack_push_f(STACK *stack, float f)
helper to push a float
#define STACK_ITEM_UINT64
v_type value for a uint64_t
double stack_pop_d(STACK *stack, uint8_t *status)
helper to pop a double
bool stack_pop_b(STACK *stack, uint8_t *status)
helper to pop a bool
bool stack_push_d(STACK *stack, double d)
helper to push a double
bool stack_push_ui8(STACK *stack, uint8_t ui8)
helper to push an uint8_t
#define STACK_ITEM_UINT32
v_type value for a uint32_t
STACK_ITEM * stack_peek(STACK *stack, size_t position)
peek in the stack without removing the stack item
bool stack_push_ui32(STACK *stack, uint32_t ui32)
helper to push an uint32_t
int8_t stack_pop_i8(STACK *stack, uint8_t *status)
helper to pop a int8_t
#define STACK_ITEM_INT8
v_type value for a int8_t
char stack_pop_c(STACK *stack, uint8_t *status)
helper to pop a char
bool stack_is_empty(const STACK *stack)
test if the stack is empty
float stack_pop_f(STACK *stack, uint8_t *status)
helper to pop a float
#define STACK_ITEM_PTR
v_type value for a void *pointer
uint8_t stack_pop_ui8(STACK *stack, uint8_t *status)
helper to pop a uint8_t
bool stack_push_c(STACK *stack, char c)
helper to push a char
bool stack_is_full(const STACK *stack)
test if the stack is full
#define STACK_IS_EMPTY
code for an empty stack state
#define STACK_ITEM_INT64
v_type value for a int64_t
#define STACK_ITEM_INT32
v_type value for a int32_t
#define STACK_IS_FULL
code for a full stack state
#define STACK_ITEM_CHAR
v_type value for a char
#define STACK_ITEM_OK
code for a successfully retrieved item
uint32_t stack_pop_ui32(STACK *stack, uint8_t *status)
helper to pop a uint32_t
bool stack_push_b(STACK *stack, bool b)
helper to push a bool
#define STACK_ITEM_BOOL
v_type value for a bool
#define STACK_IS_UNDEFINED
code for a NULL stack state
#define STACK_ITEM_UINT8
v_type value for a uint8_t
bool stack_push_i32(STACK *stack, int32_t i32)
helper to push an int32_t
int32_t stack_pop_i32(STACK *stack, uint8_t *status)
helper to pop a int32_t
#define STACK_ITEM_WRONG_TYPE
code for a bad item type
#define STACK_ITEM_DOUBLE
v_type value for a double
bool delete_stack(STACK **stack)
delete a STACK *stack
bool stack_push_i8(STACK *stack, int8_t i8)
helper to push an int8_t
#define STACK_ITEM_FLOAT
v_type value for a float
STACK * new_stack(size_t size)
allocate a new STACK
bool stack_push_p(STACK *stack, void *p, uint16_t p_type)
helper to push a pointer
void * stack_pop_p(STACK *stack, uint8_t *status)
helper to pop a pointer
bool stack_push_p_default(STACK *stack, void *p)
helper to push a pointer with a default p_type of 0
structure of a STACK item
size_t __stack_push(STACK *stack, uint8_t *status)
helper for stack_push.
size_t __stack_pop(STACK *stack, uint8_t *status)
helper for stack_pop.
Stack header definitions.