Lines Matching refs:stack
23 #define ZEND_STACK_ELEMENT(stack, n) ((void *)((char *) (stack)->elements + (stack)->size * (n))) argument
25 ZEND_API void zend_stack_init(zend_stack *stack, int size) in zend_stack_init() argument
27 stack->size = size; in zend_stack_init()
28 stack->top = 0; in zend_stack_init()
29 stack->max = 0; in zend_stack_init()
30 stack->elements = NULL; in zend_stack_init()
33 ZEND_API int zend_stack_push(zend_stack *stack, const void *element) in zend_stack_push() argument
36 if (stack->top >= stack->max) { in zend_stack_push()
37 stack->max += STACK_BLOCK_SIZE; in zend_stack_push()
38 stack->elements = safe_erealloc(stack->elements, stack->size, stack->max, 0); in zend_stack_push()
40 memcpy(ZEND_STACK_ELEMENT(stack, stack->top), element, stack->size); in zend_stack_push()
41 return stack->top++; in zend_stack_push()
45 ZEND_API void *zend_stack_top(const zend_stack *stack) in zend_stack_top() argument
47 if (stack->top > 0) { in zend_stack_top()
48 return ZEND_STACK_ELEMENT(stack, stack->top - 1); in zend_stack_top()
55 ZEND_API void zend_stack_del_top(zend_stack *stack) in zend_stack_del_top() argument
57 --stack->top; in zend_stack_del_top()
61 ZEND_API int zend_stack_int_top(const zend_stack *stack) in zend_stack_int_top() argument
63 int *e = zend_stack_top(stack); in zend_stack_int_top()
72 ZEND_API bool zend_stack_is_empty(const zend_stack *stack) in zend_stack_is_empty() argument
74 return stack->top == 0; in zend_stack_is_empty()
78 ZEND_API void zend_stack_destroy(zend_stack *stack) in zend_stack_destroy() argument
80 if (stack->elements) { in zend_stack_destroy()
81 efree(stack->elements); in zend_stack_destroy()
82 stack->elements = NULL; in zend_stack_destroy()
87 ZEND_API void *zend_stack_base(const zend_stack *stack) in zend_stack_base() argument
89 return stack->elements; in zend_stack_base()
93 ZEND_API int zend_stack_count(const zend_stack *stack) in zend_stack_count() argument
95 return stack->top; in zend_stack_count()
99 ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element)) in zend_stack_apply() argument
105 for (i=stack->top-1; i>=0; i--) { in zend_stack_apply()
106 if (apply_function(ZEND_STACK_ELEMENT(stack, i))) { in zend_stack_apply()
112 for (i=0; i<stack->top; i++) { in zend_stack_apply()
113 if (apply_function(ZEND_STACK_ELEMENT(stack, i))) { in zend_stack_apply()
122 ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(voi… in zend_stack_apply_with_argument() argument
128 for (i=stack->top-1; i>=0; i--) { in zend_stack_apply_with_argument()
129 if (apply_function(ZEND_STACK_ELEMENT(stack, i), arg)) { in zend_stack_apply_with_argument()
135 for (i=0; i<stack->top; i++) { in zend_stack_apply_with_argument()
136 if (apply_function(ZEND_STACK_ELEMENT(stack, i), arg)) { in zend_stack_apply_with_argument()
144 ZEND_API void zend_stack_clean(zend_stack *stack, void (*func)(void *), zend_bool free_elements) in zend_stack_clean() argument
149 for (i = 0; i < stack->top; i++) { in zend_stack_clean()
150 func(ZEND_STACK_ELEMENT(stack, i)); in zend_stack_clean()
154 if (stack->elements) { in zend_stack_clean()
155 efree(stack->elements); in zend_stack_clean()
156 stack->elements = NULL; in zend_stack_clean()
158 stack->top = stack->max = 0; in zend_stack_clean()