diff options
author | Dmitry Stogov <dmitry@php.net> | 2010-07-09 07:31:18 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2010-07-09 07:31:18 +0000 |
commit | bc1f1d25fa30805a8f4208829cad241880a486ab (patch) | |
tree | 4528a8b65d4a1d6d59a176c555196bee85a6fb57 /Zend | |
parent | b458b1a4c1380cdc2891f2d9827fa770aab878d7 (diff) | |
download | php-git-bc1f1d25fa30805a8f4208829cad241880a486ab.tar.gz |
zend_ptr_stack allocation is delayed before the actual usage
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_ptr_stack.c | 5 | ||||
-rw-r--r-- | Zend/zend_ptr_stack.h | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Zend/zend_ptr_stack.c b/Zend/zend_ptr_stack.c index 0d4556d9ed..af345987f7 100644 --- a/Zend/zend_ptr_stack.c +++ b/Zend/zend_ptr_stack.c @@ -27,9 +27,8 @@ ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent) { - stack->top_element = stack->elements = (void **) pemalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE, persistent); - stack->max = PTR_STACK_BLOCK_SIZE; - stack->top = 0; + stack->top_element = stack->elements = NULL; + stack->top = stack->max = 0; stack->persistent = persistent; } diff --git a/Zend/zend_ptr_stack.h b/Zend/zend_ptr_stack.h index affe7d037b..8f2828d54a 100644 --- a/Zend/zend_ptr_stack.h +++ b/Zend/zend_ptr_stack.h @@ -46,8 +46,9 @@ END_EXTERN_C() #define ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count) \ if (stack->top+count > stack->max) { \ /* we need to allocate more memory */ \ - stack->max *= 2; \ - stack->max += count; \ + do { \ + stack->max += PTR_STACK_BLOCK_SIZE; \ + } while (stack->top+count > stack->max); \ stack->elements = (void **) perealloc(stack->elements, (sizeof(void *) * (stack->max)), stack->persistent); \ stack->top_element = stack->elements+stack->top; \ } |