62 Free((*stack)->stack_array);
73 if (!stack)
return false;
83 if (!stack)
return false;
102 if (position >= stack->
tail && position < stack->head && position < stack->size && stack->
stack_array[position].
is_set) {
105 }
else if (stack->
tail > stack->
head) {
106 if ((position >= stack->
tail || position < stack->head) && position < stack->size && stack->
stack_array[position].
is_set) {
127 size_t next_pos = (stack->
head + 1) % stack->
size;
130 if (next_pos == stack->
tail) {
167 next_pos = (stack->
tail + 1) % stack->
size;
172 prev_pos = stack->
tail;
174 stack->
tail = next_pos;
193 stack->
head = next_pos;
221 (*status) = pop_status;
242 stack->
head = next_pos;
270 (*status) = pop_status;
291 stack->
head = next_pos;
319 (*status) = pop_status;
340 stack->
head = next_pos;
368 (*status) = pop_status;
389 stack->
head = next_pos;
417 (*status) = pop_status;
438 stack->
head = next_pos;
466 (*status) = pop_status;
487 stack->
head = next_pos;
515 (*status) = pop_status;
536 stack->
head = next_pos;
564 (*status) = pop_status;
587 stack->
head = next_pos;
615 (*status) = pop_status;
638bool stack_push_ui64(
STACK* stack, uint64_t ui64) {
647 stack->
head = next_pos;
658uint64_t stack_pop_ui64(
STACK* stack, uint8_t* status) {
675 (*status) = pop_status;
687bool stack_push_i64(
STACK* stack, int64_t i64) {
696 stack->
head = next_pos;
707int64_t stack_pop_i64(
STACK* stack, uint8_t* status) {
724 (*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.