summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-09-19 15:41:01 +0400
committerDmitry Stogov <dmitry@zend.com>2014-09-19 15:41:01 +0400
commit3bc8a958c5ec647adbe409ee6411ae7ed6a3dc3b (patch)
treefb2c0e55eacad99b2dbd7e8fbe0137a861714ce7
parent3ec7c2808420ad58145d6c6b5aeb1293e81ae12b (diff)
downloadphp-git-3bc8a958c5ec647adbe409ee6411ae7ed6a3dc3b.tar.gz
Fixed useless or duplicated IS_INTERNED() checks
-rw-r--r--Zend/zend_API.c3
-rw-r--r--Zend/zend_closures.c2
-rw-r--r--Zend/zend_compile.c6
-rw-r--r--Zend/zend_execute.c11
-rw-r--r--Zend/zend_execute_API.c4
-rw-r--r--Zend/zend_operators.c4
-rw-r--r--Zend/zend_string.h14
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/dom/documenttype.c2
-rw-r--r--ext/fileinfo/libmagic/softmagic.c2
-rw-r--r--ext/filter/sanitizing_filters.c10
-rw-r--r--ext/gmp/gmp.c2
-rw-r--r--ext/intl/idn/idn.c2
-rw-r--r--ext/json/json.c2
-rw-r--r--ext/mysqli/mysqli_prop.c6
-rw-r--r--ext/mysqlnd/mysqlnd.c2
-rw-r--r--ext/opcache/Optimizer/block_pass.c8
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c6
-rw-r--r--ext/opcache/zend_persist_calc.c2
-rwxr-xr-xext/openssl/openssl.c14
-rw-r--r--ext/pgsql/pgsql.c6
-rwxr-xr-xext/phar/phar_object.c6
-rw-r--r--ext/phar/zip.c4
-rw-r--r--ext/soap/php_encoding.c2
-rw-r--r--ext/soap/php_sdl.c5
-rw-r--r--ext/sockets/conversions.c6
-rw-r--r--ext/sockets/sockets.c8
-rw-r--r--ext/spl/spl_directory.c2
-rw-r--r--ext/standard/array.c2
-rw-r--r--ext/standard/string.c4
-rw-r--r--ext/standard/var.c2
-rw-r--r--sapi/fpm/fpm/fastcgi.c2
32 files changed, 79 insertions, 76 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 5675c05d54..981e42e41f 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1144,9 +1144,8 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC)
if (key) {
zval member;
- ZVAL_STR(&member, zend_string_copy(key));
+ ZVAL_STR(&member, key);
obj_ht->write_property(obj, &member, value, NULL TSRMLS_CC);
- zval_ptr_dtor(&member);
}
} ZEND_HASH_FOREACH_END();
EG(scope) = old_scope;
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index c8497a4f2d..cab31ce1c0 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -376,7 +376,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_
arg_info->pass_by_reference ? "&" : "",
i + 1);
}
- ZVAL_STR(&info, zend_strpprintf(0, "%s", i >= required ? "<optional>" : "<required>"));
+ ZVAL_NEW_STR(&info, zend_strpprintf(0, "%s", i >= required ? "<optional>" : "<required>"));
zend_hash_update(Z_ARRVAL(val), name, &info);
zend_string_release(name);
arg_info++;
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index df44138d4f..659122b5a8 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -315,7 +315,7 @@ static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int li
if (Z_TYPE_P(zv) == IS_STRING || Z_TYPE_P(zv) == IS_CONSTANT) {
zend_string_hash_val(Z_STR_P(zv));
Z_STR_P(zv) = zend_new_interned_string(Z_STR_P(zv) TSRMLS_CC);
- if (IS_INTERNED(Z_STR_P(zv))) {
+ if (!Z_REFCOUNTED_P(zv)) {
Z_TYPE_FLAGS_P(zv) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
}
}
@@ -6559,7 +6559,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
case T_METHOD_C:
if (ce) {
if (op_array && op_array->function_name) {
- ZVAL_STR(zv, zend_concat3(ce->name->val, ce->name->len, "::", 2,
+ ZVAL_NEW_STR(zv, zend_concat3(ce->name->val, ce->name->len, "::", 2,
op_array->function_name->val, op_array->function_name->len));
} else {
ZVAL_STR(zv, zend_string_copy(ce->name));
@@ -7415,7 +7415,7 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr TSRMLS_DC) /* {{{ */
class_name->val, class_name->len, "::", 2, const_name->val, const_name->len);
Z_TYPE_INFO(result) = IS_CONSTANT_EX;
- if (IS_INTERNED(Z_STR(result))) {
+ if (!Z_REFCOUNTED(result)) {
Z_TYPE_FLAGS(result) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
}
Z_CONST_FLAGS(result) = fetch_type;
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 19ecb0bc04..8052f903ca 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -766,7 +766,7 @@ static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *valu
Z_TYPE_INFO_P(str) = IS_STRING_EX;
memset(Z_STRVAL_P(str) + old_len, ' ', offset - old_len);
Z_STRVAL_P(str)[offset+1] = 0;
- } else if (IS_INTERNED(Z_STR_P(str))) {
+ } else if (!Z_REFCOUNTED_P(str)) {
Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
}
@@ -1076,8 +1076,13 @@ convert_to_array:
}
if (allow_str_offset) {
- SEPARATE_STRING(container);
- if (!IS_INTERNED(Z_STR_P(container))) zend_string_addref(Z_STR_P(container));
+ if (Z_REFCOUNTED_P(container)) {
+ if (Z_REFCOUNT_P(container) > 1) {
+ Z_DELREF_P(container);
+ zval_copy_ctor_func(container);
+ }
+ Z_ADDREF_P(container);
+ }
ZVAL_LONG(result, offset);
return container; /* assignment to string offset */
} else {
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 85bd441efe..5b3d597112 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -580,8 +580,8 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
if (!inline_change) {
ZVAL_STRINGL(p, actual, actual_len);
} else {
- Z_TYPE_INFO_P(p) = IS_INTERNED(Z_STR_P(p)) ?
- IS_INTERNED_STRING_EX : IS_STRING_EX;
+ Z_TYPE_INFO_P(p) = Z_REFCOUNTED_P(p) ?
+ IS_STRING_EX : IS_INTERNED_STRING_EX;
if (save && save->val != actual) {
zend_string_release(save);
}
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index db3e8df8c3..a63b1757e2 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -1541,7 +1541,7 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
zend_error_noreturn(E_ERROR, "String size overflow");
}
- if (result == op1 && !IS_INTERNED(Z_STR_P(result))) {
+ if (result == op1 && Z_REFCOUNTED_P(result)) {
/* special case, perform operations on result */
result_str = zend_string_realloc(Z_STR_P(result), result_len, 0);
} else {
@@ -2019,7 +2019,7 @@ static void increment_string(zval *str) /* {{{ */
return;
}
- if (IS_INTERNED(Z_STR_P(str))) {
+ if (!Z_REFCOUNTED_P(str)) {
Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
} else if (Z_REFCOUNT_P(str) > 1) {
diff --git a/Zend/zend_string.h b/Zend/zend_string.h
index 25032fc6b3..d30e14b5b3 100644
--- a/Zend/zend_string.h
+++ b/Zend/zend_string.h
@@ -140,7 +140,7 @@ static zend_always_inline zend_string *zend_string_init(const char *str, size_t
static zend_always_inline zend_string *zend_string_copy(zend_string *s)
{
if (!IS_INTERNED(s)) {
- zend_string_addref(s);
+ GC_REFCOUNT(s)++;
}
return s;
}
@@ -161,14 +161,14 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_
if (IS_INTERNED(s)) {
ret = zend_string_alloc(len, persistent);
memcpy(ret->val, s->val, (len > s->len ? s->len : len) + 1);
- } else if (EXPECTED(zend_string_refcount(s) == 1)) {
+ } else if (EXPECTED(GC_REFCOUNT(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_STR_HEADER_SIZE + len + 1), persistent);
ret->len = len;
zend_string_forget_hash_val(ret);
} else {
ret = zend_string_alloc(len, persistent);
memcpy(ret->val, s->val, (len > s->len ? s->len : len) + 1);
- zend_string_delref(s);
+ GC_REFCOUNT(s)--;
}
return ret;
}
@@ -180,14 +180,14 @@ static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s,
if (IS_INTERNED(s)) {
ret = zend_string_safe_alloc(n, m, l, persistent);
memcpy(ret->val, s->val, ((n * m) + l > (size_t)s->len ? (size_t)s->len : ((n * m) + l)) + 1);
- } else if (zend_string_refcount(s) == 1) {
+ } else if (GC_REFCOUNT(s) == 1) {
ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_STR_HEADER_SIZE + l + 1), persistent);
ret->len = (n * m) + l;
zend_string_forget_hash_val(ret);
} else {
ret = zend_string_safe_alloc(n, m, l, persistent);
memcpy(ret->val, s->val, ((n * m) + l > (size_t)s->len ? (size_t)s->len : ((n * m) + l)) + 1);
- zend_string_delref(s);
+ GC_REFCOUNT(s)--;
}
return ret;
}
@@ -195,7 +195,7 @@ static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s,
static zend_always_inline void zend_string_free(zend_string *s)
{
if (!IS_INTERNED(s)) {
- ZEND_ASSERT(zend_string_refcount(s) <= 1);
+ ZEND_ASSERT(GC_REFCOUNT(s) <= 1);
pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
@@ -203,7 +203,7 @@ static zend_always_inline void zend_string_free(zend_string *s)
static zend_always_inline void zend_string_release(zend_string *s)
{
if (!IS_INTERNED(s)) {
- if (zend_string_delref(s) == 0) {
+ if (--GC_REFCOUNT(s) == 0) {
pefree(s, GC_FLAGS(s) & IS_STR_PERSISTENT);
}
}
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index cf3f6214a5..c23350384b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2220,7 +2220,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC) /* {{{ */
abs(utc_offset / 60),
abs((utc_offset % 60)));
- ZVAL_STR(&zv, tmpstr);
+ ZVAL_NEW_STR(&zv, tmpstr);
}
break;
case TIMELIB_ZONETYPE_ABBR:
@@ -2312,7 +2312,7 @@ static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC) /*
abs(tzobj->tzi.utc_offset / 60),
abs((tzobj->tzi.utc_offset % 60)));
- ZVAL_STR(&zv, tmpstr);
+ ZVAL_NEW_STR(&zv, tmpstr);
}
break;
case TIMELIB_ZONETYPE_ABBR:
diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c
index 1193ed44d5..b9b8db76f1 100644
--- a/ext/dom/documenttype.c
+++ b/ext/dom/documenttype.c
@@ -204,7 +204,7 @@ int dom_documenttype_internal_subset_read(dom_object *obj, zval *retval TSRMLS_D
if (ret_buf.s) {
smart_str_0(&ret_buf);
- ZVAL_STR(retval, ret_buf.s);
+ ZVAL_NEW_STR(retval, ret_buf.s);
return SUCCESS;
}
}
diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c
index 5fcc3a3c84..e626929c9e 100644
--- a/ext/fileinfo/libmagic/softmagic.c
+++ b/ext/fileinfo/libmagic/softmagic.c
@@ -1913,7 +1913,7 @@ convert_libmagic_pattern(zval *pattern, char *val, int len, int options)
t->val[j]='\0';
t->len = j;
- ZVAL_STR(pattern, t);
+ ZVAL_NEW_STR(pattern, t);
}
private int
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
index ca3059cd26..a53f51bc2c 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -52,7 +52,7 @@ static void php_filter_encode_html(zval *value, const unsigned char *chars)
smart_str_0(&str);
zval_ptr_dtor(value);
- ZVAL_STR(value, str.s);
+ ZVAL_NEW_STR(value, str.s);
}
static const unsigned char hexchars[] = "0123456789ABCDEF";
@@ -105,7 +105,7 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const
*p = '\0';
str->len = p - (unsigned char *)str->val;
zval_ptr_dtor(value);
- ZVAL_STR(value, str);
+ ZVAL_NEW_STR(value, str);
}
static void php_filter_strip(zval *value, zend_long flags)
@@ -135,7 +135,7 @@ static void php_filter_strip(zval *value, zend_long flags)
buf->val[c] = '\0';
buf->len = c;
zval_ptr_dtor(value);
- ZVAL_STR(value, buf);
+ ZVAL_NEW_STR(value, buf);
}
/* }}} */
@@ -174,7 +174,7 @@ static void filter_map_apply(zval *value, filter_map *map)
buf->val[c] = '\0';
buf->len = c;
zval_ptr_dtor(value);
- ZVAL_STR(value, buf);
+ ZVAL_NEW_STR(value, buf);
}
/* }}} */
@@ -184,7 +184,7 @@ void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL)
size_t new_len;
unsigned char enc[256] = {0};
- if (IS_INTERNED(Z_STR_P(value))) {
+ if (!Z_REFCOUNTED_P(value)) {
ZVAL_STRINGL(value, Z_STRVAL_P(value), Z_STRLEN_P(value));
}
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 2d4b5fc8c1..25c06398b7 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -790,7 +790,7 @@ static void gmp_strval(zval *result, mpz_t gmpnum, zend_long base) /* {{{ */
str->val[str->len] = '\0';
}
- ZVAL_STR(result, str);
+ ZVAL_NEW_STR(result, str);
}
/* }}} */
diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c
index 99e484c17e..7de9dacdd0 100644
--- a/ext/intl/idn/idn.c
+++ b/ext/intl/idn/idn.c
@@ -184,7 +184,7 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, return_value);
} else {
zval zv;
- ZVAL_STR(&zv, buffer);
+ ZVAL_NEW_STR(&zv, buffer);
buffer_used = 1;
add_assoc_zval_ex(idna_info, "result", sizeof("result")-1, &zv);
}
diff --git a/ext/json/json.c b/ext/json/json.c
index 24324bbe99..2b35c00041 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -789,7 +789,7 @@ static PHP_FUNCTION(json_encode)
ZVAL_FALSE(return_value);
} else {
smart_str_0(&buf); /* copy? */
- ZVAL_STR(return_value, buf.s);
+ ZVAL_NEW_STR(return_value, buf.s);
}
}
/* }}} */
diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c
index c1fa0a17d6..16a1cde175 100644
--- a/ext/mysqli/mysqli_prop.c
+++ b/ext/mysqli/mysqli_prop.c
@@ -84,7 +84,7 @@ static zval *__func(mysqli_object *obj, zval *retval TSRMLS_DC) \
if (l < ZEND_LONG_MAX) {\
ZVAL_LONG(retval, (zend_long) l);\
} else { \
- ZVAL_STR(retval, strpprintf(0, __ret_type_sprint_mod, l)); \
+ ZVAL_NEW_STR(retval, strpprintf(0, __ret_type_sprint_mod, l)); \
} \
}\
return retval;\
@@ -170,7 +170,7 @@ static zval *link_affected_rows_read(mysqli_object *obj, zval *retval TSRMLS_DC)
if (rc < ZEND_LONG_MAX) {
ZVAL_LONG(retval, (zend_long) rc);
} else {
- ZVAL_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
+ ZVAL_NEW_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
}
}
return retval;
@@ -357,7 +357,7 @@ static zval *stmt_affected_rows_read(mysqli_object *obj, zval *retval TSRMLS_DC)
if (rc < ZEND_LONG_MAX) {
ZVAL_LONG(retval, (zend_long) rc);
} else {
- ZVAL_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
+ ZVAL_NEW_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
}
}
return retval;
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index 20972f64be..a6b8326273 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -2496,7 +2496,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option_2d)(MYSQLND_CONN_DATA * cons
DBG_INF_FMT("Adding [%s][%s]", key, value);
{
zval attrz;
- ZVAL_STR(&attrz, zend_string_init(value, strlen(value), 1));
+ ZVAL_NEW_STR(&attrz, zend_string_init(value, strlen(value), 1));
zend_hash_str_update(conn->options->connect_attr, key, strlen(key), &attrz);
}
break;
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 42fc06853f..1f873912b4 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -911,7 +911,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
}
old_len = Z_STRLEN(ZEND_OP1_LITERAL(last_op));
l = old_len + Z_STRLEN(ZEND_OP1_LITERAL(opline));
- if (IS_INTERNED(Z_STR(ZEND_OP1_LITERAL(last_op)))) {
+ if (!Z_REFCOUNTED(ZEND_OP1_LITERAL(last_op))) {
zend_string *tmp = zend_string_alloc(l, 0);
memcpy(tmp->val, Z_STRVAL(ZEND_OP1_LITERAL(last_op)), old_len);
Z_STR(ZEND_OP1_LITERAL(last_op)) = tmp;
@@ -923,7 +923,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
Z_STRVAL(ZEND_OP1_LITERAL(last_op))[l] = '\0';
zval_dtor(&ZEND_OP1_LITERAL(opline));
Z_STR(ZEND_OP1_LITERAL(opline)) = zend_new_interned_string(Z_STR(ZEND_OP1_LITERAL(last_op)) TSRMLS_CC);
- if (IS_INTERNED(Z_STR(ZEND_OP1_LITERAL(opline)))) {
+ if (!Z_REFCOUNTED(ZEND_OP1_LITERAL(opline))) {
Z_TYPE_FLAGS(ZEND_OP1_LITERAL(opline)) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
}
ZVAL_NULL(&ZEND_OP1_LITERAL(last_op));
@@ -955,7 +955,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
COPY_NODE(opline->op1, src->op1);
old_len = Z_STRLEN(ZEND_OP2_LITERAL(src));
l = old_len + Z_STRLEN(ZEND_OP2_LITERAL(opline));
- if (IS_INTERNED(Z_STR(ZEND_OP2_LITERAL(src)))) {
+ if (!Z_REFCOUNTED(ZEND_OP2_LITERAL(src))) {
zend_string *tmp = zend_string_alloc(l, 0);
memcpy(tmp->val, Z_STRVAL(ZEND_OP2_LITERAL(src)), old_len);
Z_STR(ZEND_OP2_LITERAL(last_op)) = tmp;
@@ -967,7 +967,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
Z_STRVAL(ZEND_OP2_LITERAL(src))[l] = '\0';
zend_string_release(Z_STR(ZEND_OP2_LITERAL(opline)));
Z_STR(ZEND_OP2_LITERAL(opline)) = zend_new_interned_string(Z_STR(ZEND_OP2_LITERAL(src)) TSRMLS_CC);
- if (IS_INTERNED(Z_STR(ZEND_OP2_LITERAL(opline)))) {
+ if (!Z_REFCOUNTED(ZEND_OP2_LITERAL(opline))) {
Z_TYPE_FLAGS(ZEND_OP2_LITERAL(opline)) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
}
ZVAL_NULL(&ZEND_OP2_LITERAL(src));
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index e04b1ec7db..5dbb48237d 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -232,14 +232,14 @@ static inline zend_string *zend_clone_str(zend_string *str TSRMLS_DC)
if (IS_INTERNED(str)) {
ret = str;
- } else if (zend_string_refcount(str) <= 1 || (ret = accel_xlat_get(str)) == NULL) {
+ } else if (GC_REFCOUNT(str) <= 1 || (ret = accel_xlat_get(str)) == NULL) {
ret = zend_string_dup(str, 0);
GC_FLAGS(ret) = GC_FLAGS(str);
- if (zend_string_refcount(str) > 1) {
+ if (GC_REFCOUNT(str) > 1) {
accel_xlat_set(str, ret);
}
} else {
- zend_string_addref(ret);
+ GC_REFCOUNT(ret)++;
}
return ret;
}
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index 76d1b043b0..d2de94f05c 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -120,7 +120,7 @@ static uint zend_persist_zval_calc(zval *z TSRMLS_DC)
case IS_CONSTANT:
flags = Z_GC_FLAGS_P(z) & ~ (IS_STR_PERSISTENT | IS_STR_INTERNED | IS_STR_PERMANENT);
ADD_INTERNED_STRING(Z_STR_P(z), 0);
- if (IS_INTERNED(Z_STR_P(z))) {
+ if (!Z_REFCOUNTED_P(z)) {
Z_TYPE_FLAGS_P(z) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
}
Z_GC_FLAGS_P(z) |= flags;
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index f2219dcd1e..e6b1524c80 100755
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -4386,7 +4386,7 @@ PHP_FUNCTION(openssl_private_encrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0';
- ZVAL_STR(crypted, cryptedbuf);
+ ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
@@ -4451,7 +4451,7 @@ PHP_FUNCTION(openssl_private_decrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0';
- ZVAL_STR(crypted, cryptedbuf);
+ ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
@@ -4509,7 +4509,7 @@ PHP_FUNCTION(openssl_public_encrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0';
- ZVAL_STR(crypted, cryptedbuf);
+ ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
@@ -4576,7 +4576,7 @@ PHP_FUNCTION(openssl_public_decrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0';
- ZVAL_STR(crypted, cryptedbuf);
+ ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
@@ -4660,7 +4660,7 @@ PHP_FUNCTION(openssl_sign)
zval_dtor(signature);
sigbuf->val[siglen] = '\0';
sigbuf->len = siglen;
- ZVAL_STR(signature, sigbuf);
+ ZVAL_NEW_STR(signature, sigbuf);
RETVAL_TRUE;
} else {
efree(sigbuf);
@@ -4812,7 +4812,7 @@ PHP_FUNCTION(openssl_seal)
if (len1 + len2 > 0) {
zval_dtor(sealdata);
buf[len1 + len2] = '\0';
- ZVAL_STR(sealdata, zend_string_init((char*)buf, len1 + len2, 0));
+ ZVAL_NEW_STR(sealdata, zend_string_init((char*)buf, len1 + len2, 0));
efree(buf);
zval_dtor(ekeys);
@@ -4903,7 +4903,7 @@ PHP_FUNCTION(openssl_open)
} else {
zval_dtor(opendata);
buf[len1 + len2] = '\0';
- ZVAL_STR(opendata, zend_string_init((char*)buf, len1 + len2, 0));
+ ZVAL_NEW_STR(opendata, zend_string_init((char*)buf, len1 + len2, 0));
efree(buf);
RETVAL_TRUE;
}
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index e06ca1c313..37b5da6ec4 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -5701,7 +5701,7 @@ static int php_pgsql_add_quotes(zval *src, zend_bool should_free TSRMLS_DC)
if (should_free) {
zval_ptr_dtor(src);
}
- ZVAL_STR(src, str.s);
+ ZVAL_NEW_STR(src, str.s);
return SUCCESS;
}
@@ -5971,7 +5971,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
/* better to use PGSQLescapeLiteral since PGescapeStringConn does not handle special \ */
str->len = PQescapeStringConn(pg_link, str->val, Z_STRVAL_P(val), Z_STRLEN_P(val), NULL);
str = zend_string_realloc(str, str->len, 0);
- ZVAL_STR(&new_val, str);
+ ZVAL_NEW_STR(&new_val, str);
php_pgsql_add_quotes(&new_val, 1 TSRMLS_CC);
}
break;
@@ -6268,7 +6268,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
smart_str_appendl(&s, Z_STRVAL(new_val), Z_STRLEN(new_val));
smart_str_0(&s);
zval_ptr_dtor(&new_val);
- ZVAL_STR(&new_val, s.s);
+ ZVAL_NEW_STR(&new_val, s.s);
}
break;
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index c446dac7df..f82b825631 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -87,7 +87,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
ZVAL_STR(&temp, Z_STR_P(stuff));
- ZVAL_STR(stuff, str);
+ ZVAL_NEW_STR(stuff, str);
zend_hash_str_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED")-1, &temp);
}
@@ -134,7 +134,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
zend_string *str = strpprintf(4096, "phar://%s%s", fname, entry);
ZVAL_STR(&temp, Z_STR_P(stuff));
- ZVAL_STR(stuff, str);
+ ZVAL_NEW_STR(stuff, str);
zend_hash_str_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME")-1, &temp);
}
@@ -3551,7 +3551,7 @@ PHP_METHOD(Phar, offsetGet)
}
sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
- ZVAL_STR(&zfname, sfname);
+ ZVAL_NEW_STR(&zfname, sfname);
spl_instantiate_arg_ex1(phar_obj->spl.info_class, return_value, &zfname TSRMLS_CC);
zval_ptr_dtor(&zfname);
}
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index a314498813..4fe0bf05c8 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -241,7 +241,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
mydata->metadata_len = 0;
/* if not valid serialized data, it is a regular string */
- ZVAL_STR(&mydata->metadata, zend_string_init(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent));
+ ZVAL_NEW_STR(&mydata->metadata, zend_string_init(metadata, PHAR_GET_16(locator.comment_len), mydata->is_persistent));
}
} else {
ZVAL_UNDEF(&mydata->metadata);
@@ -529,7 +529,7 @@ foundit:
entry.metadata_len = 0;
/* if not valid serialized data, it is a regular string */
- ZVAL_STR(&entry.metadata, zend_string_init(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent));
+ ZVAL_NEW_STR(&entry.metadata, zend_string_init(buf, PHAR_GET_16(zipentry.comment_len), entry.is_persistent));
}
} else {
ZVAL_UNDEF(&entry.metadata);
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 8de045ae80..f116342bb8 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -813,7 +813,7 @@ static zval *to_zval_hexbin(zval *ret, encodeTypePtr type, xmlNodePtr data TSRML
}
}
str->val[str->len] = '\0';
- ZVAL_STR(ret, str);
+ ZVAL_NEW_STR(ret, str);
} else {
ZVAL_EMPTY_STRING(ret);
}
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c
index 587695b943..c7e52dfb8c 100644
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -292,7 +292,7 @@ void sdl_set_uri_credentials(sdlCtx *ctx, char *uri TSRMLS_DC)
zval new_header;
rest += 2;
- ZVAL_STR(&new_header, zend_string_alloc(Z_STRLEN_P(header) - (rest - s), 0));
+ ZVAL_NEW_STR(&new_header, zend_string_alloc(Z_STRLEN_P(header) - (rest - s), 0));
memcpy(Z_STRVAL(new_header), Z_STRVAL_P(header), s - Z_STRVAL_P(header));
memcpy(Z_STRVAL(new_header) + (s - Z_STRVAL_P(header)), rest, Z_STRLEN_P(header) - (rest - Z_STRVAL_P(header)) + 1);
ZVAL_COPY(&ctx->old_header, header);
@@ -3250,8 +3250,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl TSRMLS_DC)
smart_str_appends(&proxy,Z_STRVAL(str_port));
smart_str_0(&proxy);
zval_dtor(&str_port);
- ZVAL_STR(&str_proxy, zend_string_copy(proxy.s));
- smart_str_free(&proxy);
+ ZVAL_NEW_STR(&str_proxy, proxy.s);
if (!context) {
context = php_stream_context_alloc(TSRMLS_C);
diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c
index febfa9abd8..d9221e52f5 100644
--- a/ext/sockets/conversions.c
+++ b/ext/sockets/conversions.c
@@ -562,7 +562,7 @@ static void to_zval_read_sin_addr(const char *data, zval *zv, res_context *ctx)
zend_string *str = zend_string_alloc(size - 1, 0);
memset(str->val, '\0', size);
- ZVAL_STR(zv, str);
+ ZVAL_NEW_STR(zv, str);
if (inet_ntop(AF_INET, addr, Z_STRVAL_P(zv), size) == NULL) {
do_to_zval_err(ctx, "could not convert IPv4 address to string "
@@ -614,7 +614,7 @@ static void to_zval_read_sin6_addr(const char *data, zval *zv, res_context *ctx)
memset(str->val, '\0', size);
- ZVAL_STR(zv, str);
+ ZVAL_NEW_STR(zv, str);
if (inet_ntop(AF_INET6, addr, Z_STRVAL_P(zv), size) == NULL) {
do_to_zval_err(ctx, "could not convert IPv6 address to string "
@@ -1212,7 +1212,7 @@ static void to_zval_read_iov(const char *msghdr_c, zval *zv, res_context *ctx)
memcpy(buf->val, msghdr->msg_iov[i].iov_base, buf->len);
buf->val[buf->len] = '\0';
- ZVAL_STR(&elem, buf);
+ ZVAL_NEW_STR(&elem, buf);
add_next_index_zval(zv, &elem);
bytes_left -= len;
}
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 0da81e74f5..4271588823 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -1586,7 +1586,7 @@ PHP_FUNCTION(socket_recv)
/* Rebuild buffer zval */
zval_dtor(buf);
- ZVAL_STR(buf, recv_buf);
+ ZVAL_NEW_STR(buf, recv_buf);
}
if (retval == -1) {
@@ -1673,7 +1673,7 @@ PHP_FUNCTION(socket_recvfrom)
zval_dtor(arg2);
zval_dtor(arg5);
- ZVAL_STR(arg2, recv_buf);
+ ZVAL_NEW_STR(arg2, recv_buf);
ZVAL_STRING(arg5, s_un.sun_path);
break;
@@ -1703,7 +1703,7 @@ PHP_FUNCTION(socket_recvfrom)
address = inet_ntoa(sin.sin_addr);
- ZVAL_STR(arg2, recv_buf);
+ ZVAL_NEW_STR(arg2, recv_buf);
ZVAL_STRING(arg5, address ? address : "0.0.0.0");
ZVAL_LONG(arg6, ntohs(sin.sin_port));
break;
@@ -1735,7 +1735,7 @@ PHP_FUNCTION(socket_recvfrom)
memset(addr6, 0, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &sin6.sin6_addr, addr6, INET6_ADDRSTRLEN);
- ZVAL_STR(arg2, recv_buf);
+ ZVAL_NEW_STR(arg2, recv_buf);
ZVAL_STRING(arg5, addr6[0] ? addr6 : "::");
ZVAL_LONG(arg6, ntohs(sin6.sin6_port));
break;
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 293be0b0dd..2d92044be7 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -2916,7 +2916,7 @@ SPL_METHOD(SplFileObject, fread)
RETURN_FALSE;
}
- ZVAL_STR(return_value, zend_string_alloc(length, 0));
+ ZVAL_NEW_STR(return_value, zend_string_alloc(length, 0));
Z_STRLEN_P(return_value) = php_stream_read(intern->u.file.stream, Z_STRVAL_P(return_value), length);
/* needed because recv/read/gzread doesnt put a null at the end*/
diff --git a/ext/standard/array.c b/ext/standard/array.c
index a417925528..ecb8603d2c 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1826,7 +1826,7 @@ static void php_array_data_shuffle(zval *array TSRMLS_DC) /* {{{ */
for (j = 0; j < n_elems; j++) {
p = hash->arData + j;
- if (p->key && !IS_INTERNED(p->key)) {
+ if (p->key) {
zend_string_release(p->key);
}
p->h = j;
diff --git a/ext/standard/string.c b/ext/standard/string.c
index c01259b85e..fec8b70934 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -4159,7 +4159,7 @@ PHP_FUNCTION(strip_tags)
if (allow != NULL) {
convert_to_string_ex(allow);
// TODO: reimplement to avoid reallocation ???
- if (IS_INTERNED(Z_STR_P(allow))) {
+ if (!Z_REFCOUNTED_P(allow)) {
allowed_tags = estrndup(Z_STRVAL_P(allow), Z_STRLEN_P(allow));
allowed_tags_len = Z_STRLEN_P(allow);
} else {
@@ -4172,7 +4172,7 @@ PHP_FUNCTION(strip_tags)
buf->len = php_strip_tags_ex(buf->val, str->len, NULL, allowed_tags, allowed_tags_len, 0);
// TODO: reimplement to avoid reallocation ???
- if (allow && IS_INTERNED(Z_STR_P(allow))) {
+ if (allow && !Z_REFCOUNTED_P(allow)) {
efree(allowed_tags);
}
RETURN_STR(buf);
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 664198ad97..aa1e576354 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -299,7 +299,7 @@ again:
case IS_STRING:
php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_P(struc));
PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc));
- php_printf("\" refcount(%u)\n", IS_INTERNED(Z_STR_P(struc)) ? 1 : Z_REFCOUNT_P(struc));
+ php_printf("\" refcount(%u)\n", Z_REFCOUNTED_P(struc) ? Z_REFCOUNT_P(struc) : 1);
break;
case IS_ARRAY:
myht = Z_ARRVAL_P(struc);
diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c
index 39621b839c..9d2ff4d786 100644
--- a/sapi/fpm/fpm/fastcgi.c
+++ b/sapi/fpm/fpm/fastcgi.c
@@ -1064,7 +1064,7 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
{
zval zvalue;
- ZVAL_STR(&zvalue, zend_string_init(value, value_len, 1));
+ ZVAL_NEW_STR(&zvalue, zend_string_init(value, value_len, 1));
zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue);
}