27 lines
421 B
C
27 lines
421 B
C
#include <stdlib.h>
|
|
#include "stack.h"
|
|
|
|
char bci_stack_t_push(bci_stack_t * stack, uint16_t value)
|
|
{
|
|
bci_stack_t node = malloc(sizeof(struct bci_stack_s));
|
|
if(!node)
|
|
{
|
|
return 1;
|
|
}
|
|
node->next = *stack;
|
|
node->value = value;
|
|
stack = &node;
|
|
return 0;
|
|
}
|
|
char bci_stack_t_pop(bci_stack_t * stack, uint16_t * result)
|
|
{
|
|
if(!*stack)
|
|
{
|
|
return 1;
|
|
}
|
|
*result = (*stack)->value;
|
|
*stack = (*stack)->next;
|
|
return 0;
|
|
}
|
|
|