From a31fa55b44bcb342c00e9ab2f4a851d054897a39 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 22 Sep 2012 19:12:21 +0200 Subject: Fixed bug #63132 EG(arg_types_stack) is now also backed up when generators are used. This allows the use of yield in nested method calls. This commit adds two new functions to the zend_ptr_stack API: zend_ptr_stack_push_from_memory zend_ptr_stack_pop_into_memory both taking the following arguments: zend_ptr_stack *stack, int count, void **pointers --- Zend/zend_ptr_stack.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Zend/zend_ptr_stack.c') diff --git a/Zend/zend_ptr_stack.c b/Zend/zend_ptr_stack.c index aefa91f73d..d178cc0184 100644 --- a/Zend/zend_ptr_stack.c +++ b/Zend/zend_ptr_stack.c @@ -111,6 +111,22 @@ ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack) return stack->top; } +ZEND_API void zend_ptr_stack_push_from_memory(zend_ptr_stack *stack, int count, void **pointers) +{ + ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count); + + memcpy(stack->top_element, pointers, count * sizeof(void *)); + stack->top_element += count; + stack->top += count; +} + +ZEND_API void zend_ptr_stack_pop_into_memory(zend_ptr_stack *stack, int count, void **pointers) +{ + memcpy(pointers, stack->top_element - count, count * sizeof(void *)); + stack->top_element -= count; + stack->top -= count; +} + /* * Local variables: * tab-width: 4 -- cgit v1.2.1