Lines Matching full:stack
40 void cil_stack_init(struct cil_stack **stack) in cil_stack_init() argument
43 new_stack->stack = cil_malloc(sizeof(*(new_stack->stack)) * CIL_STACK_INIT_SIZE); in cil_stack_init()
46 *stack = new_stack; in cil_stack_init()
49 void cil_stack_destroy(struct cil_stack **stack) in cil_stack_destroy() argument
51 if (stack == NULL || *stack == NULL) { in cil_stack_destroy()
55 free((*stack)->stack); in cil_stack_destroy()
56 free(*stack); in cil_stack_destroy()
57 *stack = NULL; in cil_stack_destroy()
60 void cil_stack_empty(struct cil_stack *stack) in cil_stack_empty() argument
62 stack->pos = -1; in cil_stack_empty()
65 int cil_stack_is_empty(struct cil_stack *stack) in cil_stack_is_empty() argument
67 return (stack->pos == -1); in cil_stack_is_empty()
70 void cil_stack_push(struct cil_stack *stack, enum cil_flavor flavor, void *data) in cil_stack_push() argument
72 stack->pos++; in cil_stack_push()
74 if (stack->pos == stack->size) { in cil_stack_push()
75 stack->size *= 2; in cil_stack_push()
76 stack->stack = cil_realloc(stack->stack, sizeof(*stack->stack) * stack->size); in cil_stack_push()
79 stack->stack[stack->pos].flavor = flavor; in cil_stack_push()
80 stack->stack[stack->pos].data = data; in cil_stack_push()
83 struct cil_stack_item *cil_stack_pop(struct cil_stack *stack) in cil_stack_pop() argument
85 if (stack->pos == -1) { in cil_stack_pop()
89 stack->pos--; in cil_stack_pop()
90 return &stack->stack[stack->pos + 1]; in cil_stack_pop()
93 struct cil_stack_item *cil_stack_peek(struct cil_stack *stack) in cil_stack_peek() argument
95 if (stack->pos < 0) { in cil_stack_peek()
99 return &stack->stack[stack->pos]; in cil_stack_peek()
102 struct cil_stack_item *cil_stack_peek_at(struct cil_stack *stack, int pos) in cil_stack_peek_at() argument
104 int peekpos = stack->pos - pos; in cil_stack_peek_at()
106 if (peekpos < 0 || peekpos > stack->pos) { in cil_stack_peek_at()
110 return &stack->stack[peekpos]; in cil_stack_peek_at()