summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorMatt Wilmas <mattwil@php.net>2008-05-27 10:29:33 +0000
committerMatt Wilmas <mattwil@php.net>2008-05-27 10:29:33 +0000
commit7da75d81e7993e8c0dd56edf2614be4ce69970a4 (patch)
treed840bb6eaa090116900c27b861eb265c474282aa /Zend/zend_builtin_functions.c
parenta2da2a91b1278c21b73f1ef5c9f6d4500d6b0c45 (diff)
downloadphp-git-7da75d81e7993e8c0dd56edf2614be4ce69970a4.tar.gz
MFH: Add array_init_size() and use it where array size is known at initialization
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 9006e15fde..11447bb6a1 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -285,7 +285,7 @@ ZEND_FUNCTION(func_get_args)
p = ex->function_state.arguments;
arg_count = (int)(zend_uintptr_t) *p; /* this is the amount of arguments passed to func_get_args(); */
- array_init(return_value);
+ array_init_size(return_value, arg_count);
for (i=0; i<arg_count; i++) {
zval *element;
@@ -1526,16 +1526,14 @@ ZEND_FUNCTION(get_defined_functions)
Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */
ZEND_FUNCTION(get_defined_vars)
{
- zval *tmp;
-
- array_init(return_value);
-
if (!EG(active_symbol_table)) {
zend_rebuild_symbol_table(TSRMLS_C);
}
+ array_init_size(return_value, zend_hash_num_elements(EG(active_symbol_table)));
+
zend_hash_copy(Z_ARRVAL_P(return_value), EG(active_symbol_table),
- (copy_ctor_func_t)zval_add_ref, &tmp, sizeof(zval *));
+ (copy_ctor_func_t)zval_add_ref, NULL, sizeof(zval *));
}
/* }}} */
@@ -1764,7 +1762,7 @@ static zval *debug_backtrace_get_args(void **curpos TSRMLS_DC)
int arg_count = (int)(zend_uintptr_t) *p;
MAKE_STD_ZVAL(arg_array);
- array_init(arg_array);
+ array_init_size(arg_array, arg_count);
p -= arg_count;
while (--arg_count >= 0) {