summaryrefslogtreecommitdiff
path: root/Zend/zend_stack.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-07-24 11:43:21 +0000
committerZeev Suraski <zeev@php.net>1999-07-24 11:43:21 +0000
commit9c754da0fcec0ca1c466618e4605c69d24745350 (patch)
tree0d071b4fa656df2f91ea33a9667c982c7e3f1548 /Zend/zend_stack.c
parent1b6fae101a3903f57e9b990c15a890b24497b131 (diff)
downloadphp-git-9c754da0fcec0ca1c466618e4605c69d24745350.tar.gz
Fix RETURN & SWITCH memory leak issue
Diffstat (limited to 'Zend/zend_stack.c')
-rw-r--r--Zend/zend_stack.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/Zend/zend_stack.c b/Zend/zend_stack.c
index 1a4b062add..0f3b0f6aac 100644
--- a/Zend/zend_stack.c
+++ b/Zend/zend_stack.c
@@ -116,3 +116,41 @@ ZEND_API int zend_stack_count(zend_stack *stack)
{
return stack->top;
}
+
+
+ZEND_API void zend_stack_apply(zend_stack *stack, void (*apply_function)(void *element), int type)
+{
+ int i;
+
+ switch (type) {
+ case ZEND_STACK_APPLY_TOPDOWN:
+ for (i=stack->top-1; i>=0; i--) {
+ apply_function(stack->elements[i]);
+ }
+ break;
+ case ZEND_STACK_APPLY_BOTTOMUP:
+ for (i=0; i<stack->top; i++) {
+ apply_function(stack->elements[i]);
+ }
+ break;
+ }
+}
+
+
+ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, void (*apply_function)(void *element, void *arg), int type, void *arg)
+{
+ int i;
+
+ switch (type) {
+ case ZEND_STACK_APPLY_TOPDOWN:
+ for (i=stack->top-1; i>=0; i--) {
+ apply_function(stack->elements[i], arg);
+ }
+ break;
+ case ZEND_STACK_APPLY_BOTTOMUP:
+ for (i=0; i<stack->top; i++) {
+ apply_function(stack->elements[i], arg);
+ }
+ break;
+ }
+}