summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2014-02-25 15:47:24 +0800
committerXinchen Hui <laruence@gmail.com>2014-02-25 15:47:24 +0800
commit71dac3d54f8c3dd80d5669846601a6980a7c3067 (patch)
treef6ab7ec7d1a2d5a5a83eef9114a548413b3c79c3
parentbfcb3defdda99345e42cfa2988f6312fdfc5b7ed (diff)
downloadphp-git-71dac3d54f8c3dd80d5669846601a6980a7c3067.tar.gz
Don't add_ref in add_*_str functions
-rw-r--r--Zend/zend_API.c9
-rw-r--r--Zend/zend_builtin_functions.c22
-rw-r--r--ext/spl/php_spl.c10
-rw-r--r--ext/standard/array.c2
-rw-r--r--ext/standard/basic_functions.c2
-rw-r--r--ext/standard/string.c4
6 files changed, 23 insertions, 26 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 455fe5412f..77d80cc44e 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1339,7 +1339,6 @@ ZEND_API int add_assoc_str_ex(zval *arg, const char *key, uint key_len, zend_str
zval *ret, tmp;
ZVAL_STR(&tmp, str);
- STR_ADDREF(str);
ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
return ret ? SUCCESS : FAILURE;
}
@@ -1506,7 +1505,7 @@ ZEND_API int add_next_index_str(zval *arg, zend_string *str) /* {{{ */
{
zval tmp;
- ZVAL_STR(&tmp, STR_COPY(str));
+ ZVAL_STR(&tmp, str);
return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp) ? SUCCESS : FAILURE;
}
/* }}} */
@@ -1582,7 +1581,7 @@ ZEND_API zval *add_get_index_str(zval *arg, ulong index, zend_string *str) /* {{
zval tmp;
//??? ZVAL_STRING(tmp, str, duplicate);
- ZVAL_STR(&tmp, STR_COPY(str));
+ ZVAL_STR(&tmp, str);
return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
}
/* }}} */
@@ -3297,8 +3296,8 @@ ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRML
if (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) {
zval_dtor(callable);
array_init(callable);
- add_next_index_str(callable, fcc.calling_scope->name);
- add_next_index_str(callable, fcc.function_handler->common.function_name);
+ add_next_index_str(callable, STR_COPY(fcc.calling_scope->name));
+ add_next_index_str(callable, STR_COPY(fcc.function_handler->common.function_name));
}
if (fcc.function_handler &&
((fcc.function_handler->type == ZEND_INTERNAL_FUNCTION &&
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index d5df1174ed..ed8fddbfb2 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -613,7 +613,7 @@ ZEND_FUNCTION(each)
/* add the key elements */
switch (zend_hash_get_current_key_ex(target_hash, &key, &num_key, 0, NULL)) {
case HASH_KEY_IS_STRING:
- inserted_pointer = add_get_index_str(return_value, 0, key);
+ inserted_pointer = add_get_index_str(return_value, 0, STR_COPY(key));
break;
case HASH_KEY_IS_LONG:
inserted_pointer = add_get_index_long(return_value, 0, num_key);
@@ -1427,7 +1427,7 @@ ZEND_FUNCTION(get_included_files)
array_init(return_value);
zend_hash_internal_pointer_reset(&EG(included_files));
while (zend_hash_get_current_key_ex(&EG(included_files), &entry, NULL, 0, NULL) == HASH_KEY_IS_STRING) {
- add_next_index_str(return_value, entry);
+ add_next_index_str(return_value, STR_COPY(entry));
zend_hash_move_forward(&EG(included_files));
}
}
@@ -1601,9 +1601,9 @@ static int copy_class_or_interface_name(zend_class_entry **pce TSRMLS_DC, int nu
if (ce->refcount > 1 &&
(ce->name->len != hash_key->key->len - 1 ||
!same_name(hash_key->key->val, ce->name->val, ce->name->len))) {
- add_next_index_str(array, hash_key->key);
+ add_next_index_str(array, STR_COPY(hash_key->key));
} else {
- add_next_index_str(array, ce->name);
+ add_next_index_str(array, STR_COPY(ce->name));
}
}
return ZEND_HASH_APPLY_KEEP;
@@ -1669,9 +1669,9 @@ static int copy_function_name(zend_function *func TSRMLS_DC, int num_args, va_li
}
if (func->type == ZEND_INTERNAL_FUNCTION) {
- add_next_index_str(internal_ar, hash_key->key);
+ add_next_index_str(internal_ar, STR_COPY(hash_key->key));
} else if (func->type == ZEND_USER_FUNCTION) {
- add_next_index_str(user_ar, hash_key->key);
+ add_next_index_str(user_ar, STR_COPY(hash_key->key));
}
return 0;
@@ -2219,7 +2219,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
break;
}
if (prev->op_array) {
- add_assoc_str_ex(&stack_frame, "file", sizeof("file")-1, prev->op_array->filename);
+ add_assoc_str_ex(&stack_frame, "file", sizeof("file")-1, STR_COPY(prev->op_array->filename));
add_assoc_long_ex(&stack_frame, "line", sizeof("line")-1, prev->opline->lineno);
break;
}
@@ -2244,10 +2244,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
if (Z_TYPE(ptr->object) == IS_OBJECT) {
if (ptr->function_state.function->common.scope) {
- add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, ptr->function_state.function->common.scope->name);
+ add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(ptr->function_state.function->common.scope->name));
} else {
class_name = zend_get_object_classname(&ptr->object TSRMLS_CC);
- add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, class_name);
+ add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(class_name));
}
if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
@@ -2257,7 +2257,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
add_assoc_string_ex(&stack_frame, "type", sizeof("type")-1, "->", 1);
} else if (ptr->function_state.function->common.scope) {
- add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, ptr->function_state.function->common.scope->name);
+ add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(ptr->function_state.function->common.scope->name));
add_assoc_string_ex(&stack_frame, "type", sizeof("type")-1, "::", 1);
}
@@ -2408,7 +2408,7 @@ ZEND_FUNCTION(get_extension_funcs)
array_init(return_value);
array = 1;
}
- add_next_index_str(return_value, zif->common.function_name);
+ add_next_index_str(return_value, STR_COPY(zif->common.function_name));
}
zend_hash_move_forward_ex(CG(function_table), &iterator);
}
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 90d4e2f054..26f39eb513 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -744,18 +744,18 @@ PHP_FUNCTION(spl_autoload_functions)
Z_ADDREF_P(alfi->obj);
add_next_index_zval(&tmp, alfi->obj);
} else {
- add_next_index_str(&tmp, alfi->ce->name);
+ add_next_index_str(&tmp, STR_COPY(alfi->ce->name));
}
- add_next_index_str(&tmp, alfi->func_ptr->common.function_name);
+ add_next_index_str(&tmp, STR_COPY(alfi->func_ptr->common.function_name));
add_next_index_zval(return_value, &tmp);
} else {
if (strncmp(alfi->func_ptr->common.function_name->val, "__lambda_func", sizeof("__lambda_func") - 1)) {
- add_next_index_str(return_value, alfi->func_ptr->common.function_name);
+ add_next_index_str(return_value, STR_COPY(alfi->func_ptr->common.function_name));
} else {
zend_string *key;
ulong dummy;
zend_hash_get_current_key_ex(SPL_G(autoload_functions), &key, &dummy, 0, &function_pos);
- add_next_index_str(return_value, key);
+ add_next_index_str(return_value, STR_COPY(key));
}
}
@@ -765,7 +765,7 @@ PHP_FUNCTION(spl_autoload_functions)
}
array_init(return_value);
- add_next_index_str(return_value, EG(autoload_func)->common.function_name);
+ add_next_index_str(return_value, STR_COPY(EG(autoload_func)->common.function_name));
} /* }}} */
/* {{{ proto string spl_object_hash(object obj)
diff --git a/ext/standard/array.c b/ext/standard/array.c
index ed56b28cf9..69f2fe515b 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -4045,7 +4045,7 @@ PHP_FUNCTION(array_rand)
} else {
/* Append the result to the return value. */
if (key_type == HASH_KEY_IS_STRING) {
- add_next_index_str(return_value, string_key);
+ add_next_index_str(return_value, STR_COPY(string_key));
} else {
add_next_index_long(return_value, num_key);
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 388042bc79..3f5fb28897 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -4581,7 +4581,6 @@ static int add_config_entry_cb(zval *entry TSRMLS_DC, int num_args, va_list args
if (Z_TYPE_P(entry) == IS_STRING) {
if (hash_key->key) {
-//???
add_assoc_str_ex(retval, hash_key->key->val, hash_key->key->len, STR_COPY(Z_STR_P(entry)));
} else {
add_index_str(retval, hash_key->h, STR_COPY(Z_STR_P(entry)));
@@ -4589,7 +4588,6 @@ static int add_config_entry_cb(zval *entry TSRMLS_DC, int num_args, va_list args
} else if (Z_TYPE_P(entry) == IS_ARRAY) {
array_init(&tmp);
zend_hash_apply_with_arguments(Z_ARRVAL_P(entry) TSRMLS_CC, (apply_func_args_t) add_config_entry_cb, 1, tmp);
-//???
add_assoc_zval_ex(retval, hash_key->key->val, hash_key->key->len, &tmp);
}
return 0;
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 3c6532d5f4..d484eed022 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1542,7 +1542,7 @@ PHP_FUNCTION(pathinfo)
if (have_basename) {
ret = php_basename(path, path_len, NULL, 0 TSRMLS_CC);
- add_assoc_str(&tmp, "basename", ret);
+ add_assoc_str(&tmp, "basename", STR_COPY(ret));
}
if ((opt & PHP_PATHINFO_EXTENSION) == PHP_PATHINFO_EXTENSION) {
@@ -2537,7 +2537,7 @@ PHP_FUNCTION(substr_replace)
result->val[result->len] = '\0';
if (zend_hash_get_current_key_ex(Z_ARRVAL_P(str), &str_index, &num_index, 0, &pos_str) == HASH_KEY_IS_STRING) {
- add_assoc_str(return_value, str_index->val, result);
+ add_assoc_str_ex(return_value, str_index->val, str_index->len, result);
} else {
add_index_str(return_value, num_index, result);
}