37 Free((*stack)->stack_array);
75 if (position >= stack->
tail && position <= stack->head && position < stack->size && stack->
stack_array[position].
is_set) {
78 }
else if (stack->
tail > stack->
head) {
79 if (position >= stack->
head && position <= stack->tail && position < stack->size && stack->
stack_array[position].
is_set) {
100 size_t next_pos = (stack->
head + 1) % stack->
size;
103 if (next_pos == stack->
tail) {
140 next_pos = (stack->
tail + 1) % stack->
size;
145 prev_pos = stack->
tail;
147 stack->
tail = next_pos;
166 stack->
head = next_pos;
189 (*status) = pop_status;
210 stack->
head = next_pos;
233 (*status) = pop_status;
254 stack->
head = next_pos;
277 (*status) = pop_status;
298 stack->
head = next_pos;
321 (*status) = pop_status;
342 stack->
head = next_pos;
365 (*status) = pop_status;
386 stack->
head = next_pos;
409 (*status) = pop_status;
430 stack->
head = next_pos;
453 (*status) = pop_status;
474 stack->
head = next_pos;
497 (*status) = pop_status;
520 stack->
head = next_pos;
543 (*status) = pop_status;
556bool stack_push_ui64(
STACK* stack, uint64_t ui64) {
565 stack->
head = next_pos;
576uint64_t stack_pop_ui64(
STACK* stack, uint8_t* status) {
588 (*status) = pop_status;
600bool stack_push_i64(
STACK* stack, int64_t i64) {
609 stack->
head = next_pos;
620int64_t stack_pop_i64(
STACK* stack, uint8_t* status) {
632 (*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.
size_t tail
position of tail
bool is_empty
is item set ?
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
bool is_set
is item empty ?
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
bool stack_is_empty(STACK *stack)
test if the stack is empty
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 with un stacking the stack item
bool stack_is_full(STACK *stack)
test if the stack is full
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
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
#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
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.