Skip to content

Commit 560e4fa

Browse files
committed
Removed or simplified incorrect SEPARATE_*() macros usage.
1 parent 617bef5 commit 560e4fa

File tree

16 files changed

+13
-39
lines changed

16 files changed

+13
-39
lines changed

Zend/zend_API.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
506506
ZVAL_DEREF(arg);
507507
while (1) {
508508
if (*spec_walk == '/') {
509-
SEPARATE_ZVAL(arg);
509+
SEPARATE_ZVAL_NOREF(arg);
510510
real_arg = arg;
511511
} else if (*spec_walk == '!') {
512512
check_null = 1;

ext/hash/hash.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,7 @@ PHP_FUNCTION(mhash)
849849
return;
850850
}
851851

852-
SEPARATE_ZVAL(z_algorithm);
853-
convert_to_long_ex(z_algorithm);
854-
algorithm = Z_LVAL_P(z_algorithm);
852+
algorithm = zval_get_long(z_algorithm);
855853

856854
/* need to convert the first parameter from int constant to string algorithm name */
857855
if (algorithm >= 0 && algorithm < MHASH_NUM_ALGOS) {

ext/intl/formatter/formatter_format.c

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ PHP_FUNCTION( numfmt_format )
6868
}
6969

7070
if(Z_TYPE_P(number) != IS_DOUBLE && Z_TYPE_P(number) != IS_LONG) {
71-
SEPARATE_ZVAL_IF_NOT_REF(number);
7271
convert_scalar_to_number(number );
7372
}
7473

ext/intl/grapheme/grapheme_string.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ PHP_FUNCTION(grapheme_extract)
810810
} else {
811811
ZVAL_DEREF(next);
812812
/* initialize next */
813-
SEPARATE_ZVAL(next);
813+
SEPARATE_ZVAL_NOREF(next);
814814
zval_dtor(next);
815815
ZVAL_LONG(next, lstart);
816816
}

ext/intl/transliterator/transliterator_methods.c

-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ PHP_FUNCTION( transliterator_transliterate )
332332
int res;
333333
if(Z_TYPE_P( arg1 ) != IS_STRING )
334334
{
335-
SEPARATE_ZVAL( arg1 );
336335
convert_to_string( arg1 );
337336
}
338337
object = &tmp_object;

ext/ldap/ldap.c

-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
730730
goto cleanup;
731731
}
732732

733-
SEPARATE_ZVAL(attr);
734733
convert_to_string_ex(attr);
735734
ldap_attrs[i] = Z_STRVAL_P(attr);
736735
}

ext/libxml/libxml.c

-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
664664
}
665665
} else if (Z_TYPE(retval) != IS_NULL) {
666666
/* retval not string nor resource nor null; convert to string */
667-
SEPARATE_ZVAL(&retval);
668667
convert_to_string(&retval);
669668
goto is_string;
670669
} /* else is null; don't try anything */

ext/pcntl/pcntl.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -1040,11 +1040,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
10401040
}
10411041

10421042
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(user_set), user_signo) {
1043-
if (Z_TYPE_P(user_signo) != IS_LONG) {
1044-
SEPARATE_ZVAL(user_signo);
1045-
convert_to_long_ex(user_signo);
1046-
}
1047-
signo = Z_LVAL_P(user_signo);
1043+
signo = zval_get_long(user_signo);
10481044
if (sigaddset(&set, signo) != 0) {
10491045
PCNTL_G(last_error) = errno;
10501046
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
@@ -1105,11 +1101,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
11051101
}
11061102

11071103
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(user_set), user_signo) {
1108-
if (Z_TYPE_P(user_signo) != IS_LONG) {
1109-
SEPARATE_ZVAL(user_signo);
1110-
convert_to_long_ex(user_signo);
1111-
}
1112-
signo = Z_LVAL_P(user_signo);
1104+
signo = zval_get_long(user_signo);
11131105
if (sigaddset(&set, signo) != 0) {
11141106
PCNTL_G(last_error) = errno;
11151107
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));

ext/pcre/php_pcre.c

-2
Original file line numberDiff line numberDiff line change
@@ -1446,12 +1446,10 @@ static int preg_replace_impl(zval *return_value, zval *regex, zval *replace, zva
14461446
int replace_count = 0, old_replace_count;
14471447

14481448
if (Z_TYPE_P(replace) != IS_ARRAY && (Z_TYPE_P(replace) != IS_OBJECT || !is_callable_replace)) {
1449-
SEPARATE_ZVAL(replace);
14501449
convert_to_string_ex(replace);
14511450
}
14521451

14531452
if (Z_TYPE_P(regex) != IS_ARRAY) {
1454-
SEPARATE_ZVAL(regex);
14551453
convert_to_string_ex(regex);
14561454
}
14571455

ext/pdo_pgsql/pgsql_statement.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
376376
/* We need to manually convert to a pg native boolean value */
377377
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL &&
378378
((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {
379-
SEPARATE_ZVAL(&param->parameter);
379+
const char *s = zend_is_true(&param->parameter) ? "t" : "f";
380380
param->param_type = PDO_PARAM_STR;
381-
convert_to_boolean(&param->parameter);
382-
ZVAL_STRINGL(&param->parameter, Z_TYPE_P(&param->parameter) == IS_TRUE ? "t" : "f", 1);
381+
zval_ptr_dtor(&param->parameter);
382+
ZVAL_STRINGL(&param->parameter, s, 1);
383383
}
384384
}
385385
return 1;

ext/standard/array.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -1455,12 +1455,9 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive)
14551455
zend_fcall_info orig_array_walk_fci;
14561456
zend_fcall_info_cache orig_array_walk_fci_cache;
14571457

1458-
if (Z_ISREF_P(zv)) {
1459-
thash = Z_ARRVAL_P(Z_REFVAL_P(zv));
1460-
} else {
1461-
SEPARATE_ZVAL(zv);
1462-
thash = Z_ARRVAL_P(zv);
1463-
}
1458+
ZVAL_DEREF(zv);
1459+
SEPARATE_ARRAY(zv);
1460+
thash = Z_ARRVAL_P(zv);
14641461
if (thash->u.v.nApplyCount > 1) {
14651462
php_error_docref(NULL, E_WARNING, "recursion detected");
14661463
if (userdata) {

ext/standard/formatted_print.c

-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ php_formatted_print(zend_execute_data *execute_data, int use_array, int format_o
420420
z_format = &args[format_offset];
421421
array = &args[1 + format_offset];
422422
if (Z_TYPE_P(array) != IS_ARRAY) {
423-
SEPARATE_ZVAL(array);
424423
convert_to_array(array);
425424
}
426425

ext/standard/string.c

-1
Original file line numberDiff line numberDiff line change
@@ -3973,7 +3973,6 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
39733973
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(search), search_entry) {
39743974
/* Make sure we're dealing with strings. */
39753975
ZVAL_DEREF(search_entry);
3976-
SEPARATE_ZVAL_NOREF(search_entry);
39773976
convert_to_string(search_entry);
39783977
if (Z_STRLEN_P(search_entry) == 0) {
39793978
if (Z_TYPE_P(replace) == IS_ARRAY) {

ext/xsl/xsltprocessor.c

-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params)
153153
return NULL;
154154
} else {
155155
if (Z_TYPE_P(value) != IS_STRING) {
156-
SEPARATE_ZVAL(value);
157156
convert_to_string(value);
158157
}
159158

@@ -762,7 +761,6 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter)
762761
php_error_docref(NULL, E_WARNING, "Invalid parameter array");
763762
RETURN_FALSE;
764763
}
765-
SEPARATE_ZVAL(entry);
766764
convert_to_string_ex(entry);
767765
if (Z_REFCOUNTED_P(entry)) {
768766
Z_ADDREF_P(entry);
@@ -850,7 +848,6 @@ PHP_FUNCTION(xsl_xsltprocessor_register_php_functions)
850848
intern = Z_XSL_P(id);
851849

852850
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) {
853-
SEPARATE_ZVAL(entry);
854851
convert_to_string_ex(entry);
855852
ZVAL_LONG(&new_string ,1);
856853
zend_hash_update(intern->registered_phpfunctions, Z_STR_P(entry), &new_string);

main/php_variables.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src)
649649
zend_hash_index_update(dest, num_key, src_entry);
650650
}
651651
} else {
652-
SEPARATE_ZVAL(dest_entry);
652+
SEPARATE_ARRAY(dest_entry);
653653
php_autoglobal_merge(Z_ARRVAL_P(dest_entry), Z_ARRVAL_P(src_entry));
654654
}
655655
} ZEND_HASH_FOREACH_END();

main/streams/userspace.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,7 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb)
840840

841841
#define STAT_PROP_ENTRY_EX(name, name2) \
842842
if (NULL != (elem = zend_hash_str_find(Z_ARRVAL_P(array), #name, sizeof(#name)-1))) { \
843-
SEPARATE_ZVAL(elem); \
844-
convert_to_long(elem); \
845-
ssb->sb.st_##name2 = Z_LVAL_P(elem); \
843+
ssb->sb.st_##name2 = zval_get_long(elem); \
846844
}
847845

848846
#define STAT_PROP_ENTRY(name) STAT_PROP_ENTRY_EX(name,name)

0 commit comments

Comments
 (0)