cvs: ZendEngine2 / zend_ptr_stack.c zend_ptr_stack.h

From: Date: Fri, 09 Nov 2007 10:33:51 +0000
Subject: cvs: ZendEngine2 / zend_ptr_stack.c zend_ptr_stack.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6138@lists.php.net to get a copy of this message
johannes Fri Nov 9 10:33:51 2007 UTC Modified files: /ZendEngine2 zend_ptr_stack.c zend_ptr_stack.h Log: - Allow persistent zent_ptr_stacks (patch by Andrey Hristov) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ptr_stack.c?r1=1.27&r2=1.28&diff_format=u Index: ZendEngine2/zend_ptr_stack.c diff -u ZendEngine2/zend_ptr_stack.c:1.27 ZendEngine2/zend_ptr_stack.c:1.28 --- ZendEngine2/zend_ptr_stack.c:1.27 Wed Jul 11 11:19:58 2007 +++ ZendEngine2/zend_ptr_stack.c Fri Nov 9 10:33:51 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_ptr_stack.c,v 1.27 2007/07/11 11:19:58 tony2001 Exp $ */ +/* $Id: zend_ptr_stack.c,v 1.28 2007/11/09 10:33:51 johannes Exp $ */ #include "zend.h" #include "zend_ptr_stack.h" @@ -25,14 +25,20 @@ # include <stdarg.h> #endif -ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack) /* {{{ */ +ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent) /* {{{ */ { - stack->top_element = stack->elements = (void **) emalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE); + stack->top_element = stack->elements = (void **) pemalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE, persistent); stack->max = PTR_STACK_BLOCK_SIZE; stack->top = 0; } /* }}} */ +ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack) /* {{{ */ +{ + zend_ptr_stack_init_ex(stack, 0); +} +/* }}} */ + ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...) /* {{{ */ { va_list ptr; @@ -70,7 +76,7 @@ ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack) /* {{{ */ { if (stack->elements) { - efree(stack->elements); + pefree(stack->elements, stack->persistent); } } /* }}} */ @@ -92,7 +98,7 @@ int i = stack->top; while (--i >= 0) { - efree(stack->elements[i]); + pefree(stack->elements[i], stack->persistent); } } stack->top = 0; http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ptr_stack.h?r1=1.26&r2=1.27&diff_format=u Index: ZendEngine2/zend_ptr_stack.h diff -u ZendEngine2/zend_ptr_stack.h:1.26 ZendEngine2/zend_ptr_stack.h:1.27 --- ZendEngine2/zend_ptr_stack.h:1.26 Mon Jan 1 09:29:21 2007 +++ ZendEngine2/zend_ptr_stack.h Fri Nov 9 10:33:51 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_ptr_stack.h,v 1.26 2007/01/01 09:29:21 sebastian Exp $ */ +/* $Id: zend_ptr_stack.h,v 1.27 2007/11/09 10:33:51 johannes Exp $ */ #ifndef ZEND_PTR_STACK_H #define ZEND_PTR_STACK_H @@ -26,6 +26,7 @@ int top, max; void **elements; void **top_element; + zend_bool persistent; } zend_ptr_stack; @@ -33,6 +34,7 @@ BEGIN_EXTERN_C() ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack); +ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent); ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...); ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...); ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack); @@ -46,7 +48,7 @@ /* we need to allocate more memory */ \ stack->max *= 2; \ stack->max += count; \ - stack->elements = (void **) erealloc(stack->elements, (sizeof(void *) * (stack->max))); \ + stack->elements = (void **) perealloc(stack->elements, (sizeof(void *) * (stack->max)), stack->persistent); \ stack->top_element = stack->elements+stack->top; \ }

« previous php.zend-engine.cvs (#6138) next »