Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

zend_ptr_stack allocation is delayed before the actual usage

  • Loading branch information...
commit bc1f1d25fa30805a8f4208829cad241880a486ab 1 parent b458b1a
Dmitry Stogov authored
Showing with 6 additions and 6 deletions.
  1. +1 −1  NEWS
  2. +2 −3 Zend/zend_ptr_stack.c
  3. +3 −2 Zend/zend_ptr_stack.h
View
2  NEWS
@@ -18,7 +18,7 @@ PHP NEWS
A constant class name may be used as a direct operand of ZEND_FETCH_*
instruction without previous ZEND_FETCH_CLASS.
. eliminated unnecessary iterations during request startup/shutdown
- . zend_stack initialization is delayed before the actual usage
+ . zend_stack and zend_ptr_stack allocation is delayed before the actual usage
. $GLOBALS became a JIT autoglobal, so it's initialized only if used
(this may affect opcode caches)
- Added concept of interned strings. All strings constants known at compile
View
5 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;
}
View
5 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; \
}
Please sign in to comment.
Something went wrong with that request. Please try again.