summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-06-05 16:04:11 +0400
committerDmitry Stogov <dmitry@zend.com>2014-06-05 16:04:11 +0400
commitc1965f58d4dd3970912dcd6a63ccd5860bae1a97 (patch)
tree15b4a94e8e8405f791438c468ad4eb03f60c4079 /ext
parent3d87391cc06fe87344536e88ac74ded22b0195cf (diff)
downloadphp-git-c1965f58d4dd3970912dcd6a63ccd5860bae1a97.tar.gz
Use reference counting instead of zval duplication
Diffstat (limited to 'ext')
-rw-r--r--ext/curl/multi.c5
-rw-r--r--ext/ereg/ereg.c6
-rw-r--r--ext/ftp/php_ftp.c3
-rw-r--r--ext/json/json.c2
-rw-r--r--ext/ldap/ldap.c15
-rw-r--r--ext/mbstring/mbstring.c5
-rw-r--r--ext/mbstring/php_mbregex.c3
-rwxr-xr-xext/openssl/openssl.c45
-rw-r--r--ext/pcntl/pcntl.c14
-rw-r--r--ext/pcre/php_pcre.c8
-rw-r--r--ext/soap/php_encoding.c1
-rw-r--r--ext/soap/soap.c2
-rw-r--r--ext/sockets/sendrecvmsg.c2
-rw-r--r--ext/sockets/sockets.c25
-rw-r--r--ext/spl/spl_dllist.c5
-rw-r--r--ext/spl/spl_fixedarray.c12
-rw-r--r--ext/spl/spl_heap.c6
-rw-r--r--ext/standard/array.c136
-rw-r--r--ext/standard/basic_functions.c2
-rw-r--r--ext/standard/dns.c4
-rw-r--r--ext/standard/exec.c2
-rw-r--r--ext/standard/file.c12
-rw-r--r--ext/standard/formatted_print.c44
-rw-r--r--ext/standard/fsock.c4
-rw-r--r--ext/standard/head.c2
-rw-r--r--ext/standard/image.c3
-rw-r--r--ext/standard/proc_open.c3
-rw-r--r--ext/standard/scanf.c40
-rw-r--r--ext/standard/streamsfuncs.c12
-rw-r--r--ext/standard/string.c22
-rw-r--r--ext/standard/type.c4
-rw-r--r--ext/standard/var.c16
-rw-r--r--ext/sysvmsg/sysvmsg.c7
-rw-r--r--ext/xml/xml.c6
-rw-r--r--ext/xmlrpc/xmlrpc-epi-php.c8
-rw-r--r--ext/zip/php_zip.c8
36 files changed, 200 insertions, 294 deletions
diff --git a/ext/curl/multi.c b/ext/curl/multi.c
index 1a69a3a37c..5550972bba 100644
--- a/ext/curl/multi.c
+++ b/ext/curl/multi.c
@@ -199,12 +199,11 @@ PHP_FUNCTION(curl_multi_exec)
int still_running;
int result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz", &z_mh, &z_still_running) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/", &z_mh, &z_still_running) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(mh, php_curlm *, z_mh, -1, le_curl_multi_handle_name, le_curl_multi_handle);
- ZVAL_DEREF(z_still_running);
{
zend_llist_position pos;
@@ -260,7 +259,7 @@ PHP_FUNCTION(curl_multi_info_read)
int queued_msgs;
zval *zmsgs_in_queue = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|z", &z_mh, &zmsgs_in_queue) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|z/", &z_mh, &zmsgs_in_queue) == FAILURE) {
return;
}
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
index 668f955105..79bee9b79f 100644
--- a/ext/ereg/ereg.c
+++ b/ext/ereg/ereg.c
@@ -305,7 +305,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
char *string = NULL;
int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "zs|z", &regex, &findin, &findin_len, &array) == FAILURE) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "zs|z/", &regex, &findin, &findin_len, &array) == FAILURE) {
return;
}
@@ -351,10 +351,6 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
}
match_len = 1;
- if (array) {
- ZVAL_DEREF(array);
- }
-
if (array && err != REG_NOMATCH) {
match_len = (int) (subs[0].rm_eo - subs[0].rm_so);
string_len = findin_len + 1;
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c
index 46e336deb0..1bf485f4ed 100644
--- a/ext/ftp/php_ftp.c
+++ b/ext/ftp/php_ftp.c
@@ -632,7 +632,7 @@ PHP_FUNCTION(ftp_alloc)
long size, ret;
zend_string *response = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &z_ftp, &size, &zresponse) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &z_ftp, &size, &zresponse) == FAILURE) {
RETURN_FALSE;
}
@@ -640,7 +640,6 @@ PHP_FUNCTION(ftp_alloc)
ret = ftp_alloc(ftp, size, zresponse ? &response : NULL);
if (response) {
- ZVAL_DEREF(zresponse);
zval_dtor(zresponse);
ZVAL_STR(zresponse, response);
}
diff --git a/ext/json/json.c b/ext/json/json.c
index e7e07ce2c1..0bf8a645e6 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -276,7 +276,7 @@ static void json_encode_array(smart_str *buf, zval *val, int options TSRMLS_DC)
if (key) {
if (key->val[0] == '\0' && Z_TYPE_P(val) == IS_OBJECT) {
/* Skip protected and private members. */
- if (tmp_ht) {
+ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);
}
continue;
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index c5cb15f7c3..8f52f1f3fb 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -1910,13 +1910,12 @@ PHP_FUNCTION(ldap_get_option)
ldap_linkdata *ld;
long option;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &link, &option, &retval) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz/", &link, &option, &retval) != SUCCESS) {
return;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
- ZVAL_DEREF(retval);
switch (option) {
/* options with int value */
case LDAP_OPT_DEREF:
@@ -2186,7 +2185,7 @@ PHP_FUNCTION(ldap_parse_result)
char *lmatcheddn, *lerrmsg;
int rc, lerrcode, myargcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrz|zzz", &link, &result, &errcode, &matcheddn, &errmsg, &referrals) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrz/|z/z/z/", &link, &result, &errcode, &matcheddn, &errmsg, &referrals) != SUCCESS) {
return;
}
@@ -2204,14 +2203,12 @@ PHP_FUNCTION(ldap_parse_result)
RETURN_FALSE;
}
- ZVAL_DEREF(errcode);
zval_ptr_dtor(errcode);
ZVAL_LONG(errcode, lerrcode);
/* Reverse -> fall through */
switch (myargcount) {
case 6:
- ZVAL_DEREF(referrals);
zval_ptr_dtor(referrals);
array_init(referrals);
if (lreferrals != NULL) {
@@ -2223,7 +2220,6 @@ PHP_FUNCTION(ldap_parse_result)
ldap_value_free(lreferrals);
}
case 5:
- ZVAL_DEREF(errmsg);
zval_ptr_dtor(errmsg);
if (lerrmsg == NULL) {
ZVAL_EMPTY_STRING(errmsg);
@@ -2232,7 +2228,6 @@ PHP_FUNCTION(ldap_parse_result)
ldap_memfree(lerrmsg);
}
case 4:
- ZVAL_DEREF(matcheddn);
zval_ptr_dtor(matcheddn);
if (lmatcheddn == NULL) {
ZVAL_EMPTY_STRING(matcheddn);
@@ -2312,7 +2307,7 @@ PHP_FUNCTION(ldap_parse_reference)
ldap_resultentry *resultentry;
char **lreferrals, **refp;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrz", &link, &result_entry, &referrals) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrz/", &link, &result_entry, &referrals) != SUCCESS) {
return;
}
@@ -2323,7 +2318,6 @@ PHP_FUNCTION(ldap_parse_reference)
RETURN_FALSE;
}
- ZVAL_DEREF(referrals);
zval_ptr_dtor(referrals);
array_init(referrals);
if (lreferrals != NULL) {
@@ -2721,7 +2715,7 @@ PHP_FUNCTION(ldap_control_paged_result_response)
ber_tag_t tag;
int rc, lerrcode, myargcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|zz", &link, &result, &cookie, &estimated) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|z/z/", &link, &result, &cookie, &estimated) != SUCCESS) {
return;
}
@@ -2787,7 +2781,6 @@ PHP_FUNCTION(ldap_control_paged_result_response)
ZVAL_LONG(estimated, lestimated);
}
- ZVAL_DEREF(cookie);
zval_ptr_dtor(cookie);
if (lcookie.bv_len == 0) {
ZVAL_EMPTY_STRING(cookie);
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 54bd34fa7a..ebea66323c 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -2059,13 +2059,12 @@ PHP_FUNCTION(mb_parse_str)
const mbfl_encoding *detected;
track_vars_array = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &encstr, &encstr_len, &track_vars_array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/", &encstr, &encstr_len, &track_vars_array) == FAILURE) {
return;
}
if (track_vars_array != NULL) {
/* Clear out the array */
- ZVAL_DEREF(track_vars_array);
zval_dtor(track_vars_array);
array_init(track_vars_array);
}
@@ -3600,6 +3599,7 @@ PHP_FUNCTION(mb_convert_variables)
if (stack_level <= 0) {
var = &args[n++];
ZVAL_DEREF(var);
+ SEPARATE_ZVAL_NOREF(var);
if (Z_TYPE_P(var) == IS_ARRAY || Z_TYPE_P(var) == IS_OBJECT) {
target_hash = HASH_OF(var);
if (target_hash != NULL) {
@@ -3686,6 +3686,7 @@ detect_end:
if (stack_level <= 0) {
var = &args[n++];
ZVAL_DEREF(var);
+ SEPARATE_ZVAL_NOREF(var);
if (Z_TYPE_P(var) == IS_ARRAY || Z_TYPE_P(var) == IS_OBJECT) {
target_hash = HASH_OF(var);
if (target_hash != NULL) {
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 24c1ff9019..ab03306f14 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -698,7 +698,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
array = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|z", &arg_pattern, &string, &string_len, &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|z/", &arg_pattern, &string, &string_len, &array) == FAILURE) {
RETURN_FALSE;
}
@@ -740,7 +740,6 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
match_len = 1;
str = string;
if (array != NULL) {
- ZVAL_DEREF(array);
zval_dtor(array);
array_init(array);
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 94056ce04b..16c609ffb9 100755
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -1715,10 +1715,9 @@ PHP_FUNCTION(openssl_x509_export)
BIO * bio_out;
zend_resource *certresource;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|b", &zcert, &zout, &notext) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz/|b", &zcert, &zout, &notext) == FAILURE) {
return;
}
- ZVAL_DEREF(zout);
RETVAL_FALSE;
cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC);
@@ -2481,10 +2480,9 @@ PHP_FUNCTION(openssl_pkcs12_export)
zval * item;
STACK_OF(X509) *ca = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzzs|a", &zcert, &zout, &zpkey, &pass, &pass_len, &args) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz/zs|a", &zcert, &zout, &zpkey, &pass, &pass_len, &args) == FAILURE)
return;
- ZVAL_DEREF(zout);
RETVAL_FALSE;
cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC);
@@ -2552,9 +2550,9 @@ PHP_FUNCTION(openssl_pkcs12_read)
BIO * bio_in = NULL;
int i;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szs", &zp12, &zp12_len, &zout, &pass, &pass_len) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/s", &zp12, &zp12_len, &zout, &pass, &pass_len) == FAILURE)
return;
- ZVAL_DEREF(zout);
+
RETVAL_FALSE;
bio_in = BIO_new(BIO_s_mem());
@@ -2879,10 +2877,10 @@ PHP_FUNCTION(openssl_csr_export)
BIO * bio_out;
zend_resource *csr_resource;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|b", &zcsr, &zout, &notext) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/|b", &zcsr, &zout, &notext) == FAILURE) {
return;
}
- ZVAL_DEREF(zout);
+
RETVAL_FALSE;
csr = php_openssl_csr_from_zval(zcsr, 0, &csr_resource TSRMLS_CC);
@@ -3060,10 +3058,9 @@ PHP_FUNCTION(openssl_csr_new)
int we_made_the_key = 1;
zend_resource *key_resource;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "az|a!a!", &dn, &out_pkey, &args, &attribs) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "az/|a!a!", &dn, &out_pkey, &args, &attribs) == FAILURE) {
return;
}
- ZVAL_DEREF(out_pkey);
RETVAL_FALSE;
PHP_SSL_REQ_INIT(&req);
@@ -3694,10 +3691,9 @@ PHP_FUNCTION(openssl_pkey_export)
BIO * bio_out = NULL;
const EVP_CIPHER * cipher;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|s!a!", &zpkey, &out, &passphrase, &passphrase_len, &args) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz/|s!a!", &zpkey, &out, &passphrase, &passphrase_len, &args) == FAILURE) {
return;
}
- ZVAL_DEREF(out);
RETVAL_FALSE;
key = php_openssl_evp_from_zval(zpkey, 0, passphrase, 0, &key_resource TSRMLS_CC);
@@ -4380,10 +4376,9 @@ PHP_FUNCTION(openssl_private_encrypt)
int data_len;
long padding = RSA_PKCS1_PADDING;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
return;
}
- ZVAL_DEREF(crypted);
RETVAL_FALSE;
pkey = php_openssl_evp_from_zval(key, 0, "", 0, &keyresource TSRMLS_CC);
@@ -4442,10 +4437,9 @@ PHP_FUNCTION(openssl_private_decrypt)
char * data;
int data_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
return;
}
- ZVAL_DEREF(crypted);
RETVAL_FALSE;
pkey = php_openssl_evp_from_zval(key, 0, "", 0, &keyresource TSRMLS_CC);
@@ -4510,9 +4504,8 @@ PHP_FUNCTION(openssl_public_encrypt)
char * data;
int data_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz|l", &data, &data_len, &crypted, &key, &padding) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z|l", &data, &data_len, &crypted, &key, &padding) == FAILURE)
return;
- ZVAL_DEREF(crypted);
RETVAL_FALSE;
pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, &keyresource TSRMLS_CC);
@@ -4571,10 +4564,9 @@ PHP_FUNCTION(openssl_public_decrypt)
char * data;
int data_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
return;
}
- ZVAL_DEREF(crypted);
RETVAL_FALSE;
pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, &keyresource TSRMLS_CC);
@@ -4663,10 +4655,9 @@ PHP_FUNCTION(openssl_sign)
long signature_algo = OPENSSL_ALGO_SHA1;
const EVP_MD *mdtype;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz|z", &data, &data_len, &signature, &key, &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z|z", &data, &data_len, &signature, &key, &method) == FAILURE) {
return;
}
- ZVAL_DEREF(signature);
pkey = php_openssl_evp_from_zval(key, 0, "", 0, &keyresource TSRMLS_CC);
if (pkey == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "supplied key param cannot be coerced into a private key");
@@ -4781,11 +4772,9 @@ PHP_FUNCTION(openssl_seal)
const EVP_CIPHER *cipher;
EVP_CIPHER_CTX ctx;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szza/|s", &data, &data_len, &sealdata, &ekeys, &pubkeys, &method, &method_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z/a/|s", &data, &data_len, &sealdata, &ekeys, &pubkeys, &method, &method_len) == FAILURE) {
return;
}
- ZVAL_DEREF(sealdata);
- ZVAL_DEREF(ekeys);
pubkeysht = HASH_OF(pubkeys);
nkeys = pubkeysht ? zend_hash_num_elements(pubkeysht) : 0;
if (!nkeys) {
@@ -4909,10 +4898,9 @@ PHP_FUNCTION(openssl_open)
int method_len = 0;
const EVP_CIPHER *cipher;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szsz|s", &data, &data_len, &opendata, &ekey, &ekey_len, &privkey, &method, &method_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/sz|s", &data, &data_len, &opendata, &ekey, &ekey_len, &privkey, &method, &method_len) == FAILURE) {
return;
}
- ZVAL_DEREF(opendata);
pkey = php_openssl_evp_from_zval(privkey, 0, "", 0, &keyresource TSRMLS_CC);
if (pkey == NULL) {
@@ -5324,10 +5312,9 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
zval *zstrong_result_returned = NULL;
int strong_result = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|z", &buffer_length, &zstrong_result_returned) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|z/", &buffer_length, &zstrong_result_returned) == FAILURE) {
return;
}
- ZVAL_DEREF(zstrong_result_returned);
if (buffer_length <= 0) {
RETURN_FALSE;
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 5de4ae1cd4..448e34b5cc 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -574,10 +574,9 @@ PHP_FUNCTION(pcntl_waitpid)
int status;
pid_t child_id;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|l", &pid, &z_status, &options) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz/|l", &pid, &z_status, &options) == FAILURE)
return;
- ZVAL_DEREF(z_status);
convert_to_long_ex(z_status);
status = Z_LVAL_P(z_status);
@@ -603,10 +602,9 @@ PHP_FUNCTION(pcntl_wait)
int status;
pid_t child_id;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &z_status, &options) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|l", &z_status, &options) == FAILURE)
return;
- ZVAL_DEREF(z_status);
convert_to_long_ex(z_status);
status = Z_LVAL_P(z_status);
@@ -918,7 +916,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
zval *user_set, *user_oldset = NULL, *user_signo;
sigset_t set, oldset;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la|z", &how, &user_set, &user_oldset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "la|z/", &how, &user_set, &user_oldset) == FAILURE) {
return;
}
@@ -948,7 +946,6 @@ PHP_FUNCTION(pcntl_sigprocmask)
}
if (user_oldset != NULL) {
- ZVAL_DEREF(user_oldset);
if (Z_TYPE_P(user_oldset) != IS_ARRAY) {
zval_dtor(user_oldset);
array_init(user_oldset);
@@ -979,11 +976,11 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
struct timespec timeout;
if (timedwait) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|zll", &user_set, &user_siginfo, &tv_sec, &tv_nsec) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|z/ll", &user_set, &user_siginfo, &tv_sec, &tv_nsec) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|z", &user_set, &user_siginfo) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|z/", &user_set, &user_siginfo) == FAILURE) {
return;
}
}
@@ -1028,7 +1025,6 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
}
if (signo > 0 && user_siginfo) {
- ZVAL_DEREF(user_siginfo);
if (Z_TYPE_P(user_siginfo) != IS_ARRAY) {
zval_dtor(user_siginfo);
array_init(user_siginfo);
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 193234c131..0ce3600005 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -542,7 +542,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
long flags = 0; /* Match control flags */
long start_offset = 0; /* Where the new search starts */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|zll", &regex,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ss|z/ll", &regex,
&subject, &subject_len, &subpats, &flags, &start_offset) == FAILURE) {
RETURN_FALSE;
}
@@ -552,9 +552,6 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
RETURN_FALSE;
}
- if (subpats) {
- ZVAL_DEREF(subpats);
- }
php_pcre_match_impl(pce, subject, subject_len, return_value, subpats,
global, ZEND_NUM_ARGS() >= 4, flags, start_offset TSRMLS_CC);
}
@@ -1355,7 +1352,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
int replace_count=0, old_replace_count;
/* Get function parameters and do error-checking. */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|lz", &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|lz/", &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
return;
}
@@ -1419,7 +1416,6 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
}
}
if (ZEND_NUM_ARGS() > 4) {
- ZVAL_DEREF(zcount);
zval_dtor(zcount);
ZVAL_LONG(zcount, replace_count);
}
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index c35cae2d33..0ec71d7625 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -360,7 +360,6 @@ static zend_bool soap_check_xml_ref(zval *data, xmlNodePtr node TSRMLS_DC)
!Z_REFCOUNTED_P(data_ptr) ||
Z_COUNTED_P(data) != Z_COUNTED_P(data_ptr)) {
zval_ptr_dtor(data);
-//??? SEPARATE_ZVAL_TO_MAKE_IS_REF(data_ptr);
ZVAL_COPY(data, data_ptr);
return 1;
}
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 55da782e39..7150738051 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -2862,7 +2862,7 @@ PHP_METHOD(SoapClient, __call)
zend_bool free_soap_headers = 0;
zval *this_ptr;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|a!zz",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|a!zz/",
&function, &function_len, &args, &options, &headers, &output_headers) == FAILURE) {
return;
}
diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c
index 901972da36..4ddae3f6ff 100644
--- a/ext/sockets/sendrecvmsg.c
+++ b/ext/sockets/sendrecvmsg.c
@@ -217,7 +217,7 @@ PHP_FUNCTION(socket_recvmsg)
struct err_s err = {0};
//ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra|l",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra/|l",
&zsocket, &zmsg, &flags) == FAILURE) {
return;
}
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index b858a4733e..dd7f27260f 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -838,7 +838,7 @@ PHP_FUNCTION(socket_select)
int retval, sets = 0;
long usec = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!a/!a/!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE) {
return;
}
@@ -1179,7 +1179,7 @@ PHP_FUNCTION(socket_getsockname)
char *addr_string;
socklen_t salen = sizeof(php_sockaddr_storage);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|z", &arg1, &addr, &port) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/|z/", &arg1, &addr, &port) == FAILURE) {
return;
}
@@ -1192,7 +1192,6 @@ PHP_FUNCTION(socket_getsockname)
RETURN_FALSE;
}
- ZVAL_DEREF(addr);
if (port != NULL) {
ZVAL_DEREF(port);
}
@@ -1261,7 +1260,7 @@ PHP_FUNCTION(socket_getpeername)
char *addr_string;
socklen_t salen = sizeof(php_sockaddr_storage);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|z", &arg1, &arg2, &arg3) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/|z/", &arg1, &arg2, &arg3) == FAILURE) {
return;
}
@@ -1274,8 +1273,6 @@ PHP_FUNCTION(socket_getpeername)
RETURN_FALSE;
}
- ZVAL_DEREF(arg2);
- ZVAL_DEREF(arg3);
switch (sa->sa_family) {
#if HAVE_IPV6
case AF_INET6:
@@ -1563,7 +1560,7 @@ PHP_FUNCTION(socket_recv)
int retval;
long len, flags;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzll", &php_sock_res, &buf, &len, &flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/ll", &php_sock_res, &buf, &len, &flags) == FAILURE) {
return;
}
@@ -1576,7 +1573,6 @@ PHP_FUNCTION(socket_recv)
recv_buf = STR_ALLOC(len, 0);
- ZVAL_DEREF(buf);
if ((retval = recv(php_sock->bsd_socket, recv_buf->val, len, flags)) < 1) {
efree(recv_buf);
@@ -1645,7 +1641,7 @@ PHP_FUNCTION(socket_recvfrom)
char *address;
zend_string *recv_buf;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzllz|z", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/llz/|z/", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
return;
}
@@ -1672,8 +1668,6 @@ PHP_FUNCTION(socket_recvfrom)
recv_buf->len = retval;
recv_buf->val[recv_buf->len] = '\0';
- ZVAL_DEREF(arg2);
- ZVAL_DEREF(arg5);
zval_dtor(arg2);
zval_dtor(arg5);
@@ -1701,9 +1695,6 @@ PHP_FUNCTION(socket_recvfrom)
recv_buf->len = retval;
recv_buf->val[recv_buf->len] = '\0';
- ZVAL_DEREF(arg2);
- ZVAL_DEREF(arg5);
- ZVAL_DEREF(arg6);
zval_dtor(arg2);
zval_dtor(arg5);
zval_dtor(arg6);
@@ -1735,9 +1726,6 @@ PHP_FUNCTION(socket_recvfrom)
recv_buf->len = retval;
recv_buf->val[recv_buf->len] = '\0';
- ZVAL_DEREF(arg2);
- ZVAL_DEREF(arg5);
- ZVAL_DEREF(arg6);
zval_dtor(arg2);
zval_dtor(arg5);
zval_dtor(arg6);
@@ -2097,14 +2085,13 @@ PHP_FUNCTION(socket_create_pair)
PHP_SOCKET fds_array[2];
long domain, type, protocol;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllz", &domain, &type, &protocol, &fds_array_zval) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllz/", &domain, &type, &protocol, &fds_array_zval) == FAILURE) {
return;
}
php_sock[0] = php_create_socket();
php_sock[1] = php_create_socket();
- ZVAL_DEREF(fds_array_zval);
if (domain != AF_INET
#if HAVE_IPV6
&& domain != AF_INET6
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index cc357bc6be..70f2d84128 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -560,8 +560,6 @@ SPL_METHOD(SplDoublyLinkedList, push)
return;
}
- SEPARATE_ZVAL_IF_REF(value);
-
intern = Z_SPLDLLIST_P(getThis());
spl_ptr_llist_push(intern->llist, value TSRMLS_CC);
@@ -580,8 +578,6 @@ SPL_METHOD(SplDoublyLinkedList, unshift)
return;
}
- SEPARATE_ZVAL_IF_REF(value);
-
intern = Z_SPLDLLIST_P(getThis());
spl_ptr_llist_unshift(intern->llist, value TSRMLS_CC);
@@ -806,7 +802,6 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &zindex, &value) == FAILURE) {
return;
}
- SEPARATE_ZVAL_IF_REF(value);
intern = Z_SPLDLLIST_P(getThis());
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index f9f89dfd9c..62aaffbc3c 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -405,8 +405,8 @@ static inline void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_o
if (!Z_ISUNDEF(intern->array->elements[index])) {
zval_ptr_dtor(&(intern->array->elements[index]));
}
- SEPARATE_ARG_IF_REF(value);
- ZVAL_COPY_VALUE(&intern->array->elements[index], value);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(&intern->array->elements[index], value);
}
}
/* }}} */
@@ -708,8 +708,8 @@ SPL_METHOD(SplFixedArray, fromArray)
spl_fixedarray_init(array, tmp TSRMLS_CC);
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(data), num_index, str_index, element) {
- SEPARATE_ARG_IF_REF(element);
- ZVAL_COPY_VALUE(&array->elements[num_index], element);
+ ZVAL_DEREF(element);
+ ZVAL_COPY(&array->elements[num_index], element);
} ZEND_HASH_FOREACH_END();
} else if (num > 0 && !save_indexes) {
@@ -719,8 +719,8 @@ SPL_METHOD(SplFixedArray, fromArray)
spl_fixedarray_init(array, num TSRMLS_CC);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), element) {
- SEPARATE_ARG_IF_REF(element);
- ZVAL_COPY_VALUE(&array->elements[i], element);
+ ZVAL_DEREF(element);
+ ZVAL_COPY(&array->elements[i], element);
i++;
} ZEND_HASH_FOREACH_END();
} else {
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index 52b4371f57..90d78db6ee 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -616,7 +616,7 @@ SPL_METHOD(SplHeap, insert)
return;
}
- SEPARATE_ARG_IF_REF(value);
+ if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
spl_ptr_heap_insert(intern->heap, value, getThis() TSRMLS_CC);
RETURN_TRUE;
@@ -670,8 +670,8 @@ SPL_METHOD(SplPriorityQueue, insert)
return;
}
- SEPARATE_ARG_IF_REF(data);
- SEPARATE_ARG_IF_REF(priority);
+ if (Z_REFCOUNTED_P(data)) Z_ADDREF_P(data);
+ if (Z_REFCOUNTED_P(priority)) Z_ADDREF_P(priority);
array_init(&elem);
add_assoc_zval_ex(&elem, "data", sizeof("data") - 1, data);
diff --git a/ext/standard/array.c b/ext/standard/array.c
index b5caf090fe..30cea91434 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -219,7 +219,7 @@ PHP_FUNCTION(krsort)
zval *array;
long sort_type = PHP_SORT_REGULAR;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
}
@@ -239,7 +239,7 @@ PHP_FUNCTION(ksort)
zval *array;
long sort_type = PHP_SORT_REGULAR;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
}
@@ -265,16 +265,16 @@ PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */
cnt = zend_hash_num_elements(Z_ARRVAL_P(array));
if (mode == COUNT_RECURSIVE) {
+ if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(array))) {
+ Z_ARRVAL_P(array)->u.v.nApplyCount++;
+ }
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), element) {
- if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(array))) {
- Z_ARRVAL_P(array)->u.v.nApplyCount++;
- }
ZVAL_DEREF(element);
cnt += php_count_recursive(element, COUNT_RECURSIVE TSRMLS_CC);
- if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(array))) {
- Z_ARRVAL_P(array)->u.v.nApplyCount--;
- }
} ZEND_HASH_FOREACH_END();
+ if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(array))) {
+ Z_ARRVAL_P(array)->u.v.nApplyCount--;
+ }
}
}
@@ -288,6 +288,8 @@ PHP_FUNCTION(count)
{
zval *array;
long mode = COUNT_NORMAL;
+ long cnt;
+ zval *element;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array, &mode) == FAILURE) {
return;
@@ -298,7 +300,14 @@ PHP_FUNCTION(count)
RETURN_LONG(0);
break;
case IS_ARRAY:
- RETURN_LONG (php_count_recursive (array, mode TSRMLS_CC));
+ cnt = zend_hash_num_elements(Z_ARRVAL_P(array));
+ if (mode == COUNT_RECURSIVE) {
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), element) {
+ ZVAL_DEREF(element);
+ cnt += php_count_recursive(element, COUNT_RECURSIVE TSRMLS_CC);
+ } ZEND_HASH_FOREACH_END();
+ }
+ RETURN_LONG(cnt);
break;
case IS_OBJECT: {
#ifdef HAVE_SPL
@@ -409,7 +418,7 @@ static void php_natsort(INTERNAL_FUNCTION_PARAMETERS, int fold_case) /* {{{ */
{
zval *array;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &array) == FAILURE) {
return;
}
@@ -450,7 +459,7 @@ PHP_FUNCTION(asort)
zval *array;
long sort_type = PHP_SORT_REGULAR;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
}
@@ -470,7 +479,7 @@ PHP_FUNCTION(arsort)
zval *array;
long sort_type = PHP_SORT_REGULAR;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
}
@@ -490,7 +499,7 @@ PHP_FUNCTION(sort)
zval *array;
long sort_type = PHP_SORT_REGULAR;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
}
@@ -510,7 +519,7 @@ PHP_FUNCTION(rsort)
zval *array;
long sort_type = PHP_SORT_REGULAR;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
RETURN_FALSE;
}
@@ -593,7 +602,7 @@ PHP_FUNCTION(usort)
PHP_ARRAY_CMP_FUNC_BACKUP();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "af", &array, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/f", &array, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
PHP_ARRAY_CMP_FUNC_RESTORE();
return;
}
@@ -636,7 +645,7 @@ PHP_FUNCTION(uasort)
PHP_ARRAY_CMP_FUNC_BACKUP();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "af", &array, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/f", &array, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
PHP_ARRAY_CMP_FUNC_RESTORE();
return;
}
@@ -722,7 +731,7 @@ PHP_FUNCTION(uksort)
PHP_ARRAY_CMP_FUNC_BACKUP();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "af", &array, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/f", &array, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) {
PHP_ARRAY_CMP_FUNC_RESTORE();
return;
}
@@ -762,7 +771,7 @@ PHP_FUNCTION(end)
HashTable *array;
zval *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
@@ -789,7 +798,7 @@ PHP_FUNCTION(prev)
HashTable *array;
zval *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
@@ -816,7 +825,7 @@ PHP_FUNCTION(next)
HashTable *array;
zval *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
@@ -843,7 +852,7 @@ PHP_FUNCTION(reset)
HashTable *array;
zval *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
@@ -870,7 +879,7 @@ PHP_FUNCTION(current)
HashTable *array;
zval *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
@@ -892,7 +901,7 @@ PHP_FUNCTION(key)
{
HashTable *array;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/", &array) == FAILURE) {
return;
}
@@ -1111,7 +1120,7 @@ PHP_FUNCTION(array_walk)
orig_array_walk_fci = BG(array_walk_fci);
orig_array_walk_fci_cache = BG(array_walk_fci_cache);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Hf|z/", &array, &BG(array_walk_fci), &BG(array_walk_fci_cache), &userdata) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/f|z/", &array, &BG(array_walk_fci), &BG(array_walk_fci_cache), &userdata) == FAILURE) {
BG(array_walk_fci) = orig_array_walk_fci;
BG(array_walk_fci_cache) = orig_array_walk_fci_cache;
return;
@@ -1136,7 +1145,7 @@ PHP_FUNCTION(array_walk_recursive)
orig_array_walk_fci = BG(array_walk_fci);
orig_array_walk_fci_cache = BG(array_walk_fci_cache);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Hf|z/", &array, &BG(array_walk_fci), &BG(array_walk_fci_cache), &userdata) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H/f|z/", &array, &BG(array_walk_fci), &BG(array_walk_fci_cache), &userdata) == FAILURE) {
BG(array_walk_fci) = orig_array_walk_fci;
BG(array_walk_fci_cache) = orig_array_walk_fci_cache;
return;
@@ -1284,7 +1293,7 @@ PHP_FUNCTION(extract)
int var_exists, count = 0;
int extract_refs = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|lz/", &var_array, &extract_type, &prefix) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|lz/", &var_array, &extract_type, &prefix) == FAILURE) {
return;
}
@@ -1313,13 +1322,6 @@ PHP_FUNCTION(extract)
zend_rebuild_symbol_table(TSRMLS_C);
}
- /* var_array is passed by ref for the needs of EXTR_REFS (needs to
- * work on the original array to create refs to its members)
- * simulate pass_by_value if EXTR_REFS is not used */
- if (!extract_refs) {
- SEPARATE_ARG_IF_REF(var_array);
- }
-
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(var_array), num_key, var_name, entry) {
zval final_name;
@@ -1394,7 +1396,7 @@ PHP_FUNCTION(extract)
if (extract_refs) {
zval *orig_var;
- SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
+ ZVAL_MAKE_REF(entry);
Z_ADDREF_P(entry);
if ((orig_var = zend_hash_find(&EG(active_symbol_table)->ht, Z_STR(final_name))) != NULL) {
@@ -1407,18 +1409,14 @@ PHP_FUNCTION(extract)
zend_hash_update(&EG(active_symbol_table)->ht, Z_STR(final_name), entry);
}
} else {
- ZVAL_DUP(&data, entry);
- zend_set_local_var(Z_STR(final_name), &data, 1 TSRMLS_CC);
+ if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
+ zend_set_local_var(Z_STR(final_name), entry, 1 TSRMLS_CC);
}
count++;
}
zval_dtor(&final_name);
} ZEND_HASH_FOREACH_END();
- if (!extract_refs) {
- zval_ptr_dtor(var_array);
- }
-
RETURN_LONG(count);
}
/* }}} */
@@ -1776,7 +1774,7 @@ PHP_FUNCTION(shuffle)
{
zval *array;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &array) == FAILURE) {
RETURN_FALSE;
}
@@ -1902,7 +1900,7 @@ PHP_FUNCTION(array_push)
argc; /* Number of function arguments */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a+", &stack, &args, &argc) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/+", &stack, &args, &argc) == FAILURE) {
return;
}
@@ -1930,7 +1928,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
zend_string *key = NULL;
ulong index;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &stack) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &stack) == FAILURE) {
return;
}
@@ -2043,7 +2041,7 @@ PHP_FUNCTION(array_unshift)
HashTable old_hash;
int argc; /* Number of function arguments */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a+", &stack, &args, &argc) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/+", &stack, &args, &argc) == FAILURE) {
return;
}
@@ -2078,7 +2076,7 @@ PHP_FUNCTION(array_splice)
repl_num = 0; /* Number of replacement elements */
int num_in; /* Number of elements in the input array */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lz/", &array, &offset, &length, &repl_array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/l|lz/", &array, &offset, &length, &repl_array) == FAILURE) {
return;
}
@@ -2980,7 +2978,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
zval *args;
int (*intersect_data_compare_func)(zval *, zval * TSRMLS_DC) = NULL;
zend_bool ok;
- zval *data;
+ zval *val, *data;
int req_args;
char *param_spec;
@@ -3022,40 +3020,44 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
for (idx = 0; idx < Z_ARRVAL(args[0])->nNumUsed; idx++) {
p = Z_ARRVAL(args[0])->arData + idx;
- if (Z_TYPE(p->val) == IS_UNDEF) continue;
+ val = &p->val;
+ if (Z_TYPE_P(val) == IS_UNDEF) continue;
+ if (Z_ISREF_P(val) && Z_REFCOUNT_P(val) == 1) {
+ ZVAL_UNREF(val);
+ }
if (p->key == NULL) {
ok = 1;
for (i = 1; i < argc; i++) {
if ((data = zend_hash_index_find(Z_ARRVAL(args[i]), p->h)) == NULL ||
(intersect_data_compare_func &&
- intersect_data_compare_func(&p->val, data TSRMLS_CC) != 0)
+ intersect_data_compare_func(val, data TSRMLS_CC) != 0)
) {
ok = 0;
break;
}
}
if (ok) {
- if (Z_REFCOUNTED(p->val)) {
- Z_ADDREF(p->val);
+ if (Z_REFCOUNTED_P(val)) {
+ Z_ADDREF_P(val);
}
- zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, &p->val);
+ zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, val);
}
} else {
ok = 1;
for (i = 1; i < argc; i++) {
if ((data = zend_hash_find(Z_ARRVAL(args[i]), p->key)) == NULL ||
(intersect_data_compare_func &&
- intersect_data_compare_func(&p->val, data TSRMLS_CC) != 0)
+ intersect_data_compare_func(val, data TSRMLS_CC) != 0)
) {
ok = 0;
break;
}
}
if (ok) {
- if (Z_REFCOUNTED(p->val)) {
- Z_ADDREF(p->val);
+ if (Z_REFCOUNTED_P(val)) {
+ Z_ADDREF_P(val);
}
- zend_hash_update(Z_ARRVAL_P(return_value), p->key, &p->val);
+ zend_hash_update(Z_ARRVAL_P(return_value), p->key, val);
}
}
}
@@ -3405,7 +3407,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty
zval *args;
int (*diff_data_compare_func)(zval *, zval * TSRMLS_DC) = NULL;
zend_bool ok;
- zval *data;
+ zval *val, *data;
/* Get the argument count */
argc = ZEND_NUM_ARGS();
@@ -3442,40 +3444,44 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty
for (idx = 0; idx < Z_ARRVAL(args[0])->nNumUsed; idx++) {
p = Z_ARRVAL(args[0])->arData + idx;
- if (Z_TYPE(p->val) == IS_UNDEF) continue;
+ val = &p->val;
+ if (Z_TYPE_P(val) == IS_UNDEF) continue;
+ if (Z_ISREF_P(val) && Z_REFCOUNT_P(val) == 1) {
+ ZVAL_UNREF(val);
+ }
if (p->key == NULL) {
ok = 1;
for (i = 1; i < argc; i++) {
if ((data = zend_hash_index_find(Z_ARRVAL(args[i]), p->h)) != NULL &&
(!diff_data_compare_func ||
- diff_data_compare_func(&p->val, data TSRMLS_CC) == 0)
+ diff_data_compare_func(val, data TSRMLS_CC) == 0)
) {
ok = 0;
break;
}
}
if (ok) {
- if (Z_REFCOUNTED(p->val)) {
- Z_ADDREF(p->val);
+ if (Z_REFCOUNTED_P(val)) {
+ Z_ADDREF_P(val);
}
- zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, &p->val);
+ zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, val);
}
} else {
ok = 1;
for (i = 1; i < argc; i++) {
if ((data = zend_hash_find(Z_ARRVAL(args[i]), p->key)) != NULL &&
(!diff_data_compare_func ||
- diff_data_compare_func(&p->val, data TSRMLS_CC) == 0)
+ diff_data_compare_func(val, data TSRMLS_CC) == 0)
) {
ok = 0;
break;
}
}
if (ok) {
- if (Z_REFCOUNTED(p->val)) {
- Z_ADDREF(p->val);
+ if (Z_REFCOUNTED_P(val)) {
+ Z_ADDREF_P(val);
}
- zend_hash_update(Z_ARRVAL_P(return_value), p->key, &p->val);
+ zend_hash_update(Z_ARRVAL_P(return_value), p->key, val);
}
}
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 70c029ecca..0242f8aaba 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -395,7 +395,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_array_merge, 0, 0, 2)
ZEND_ARG_INFO(0, arr1) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_VARIADIC_INFO(0, arrays)
ZEND_END_ARG_INFO()
-
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_merge_recursive, 0, 0, 2)
ZEND_ARG_INFO(0, arr1) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_VARIADIC_INFO(0, arrays)
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index de0e24a2d7..fd0acd7e3c 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -943,16 +943,14 @@ PHP_FUNCTION(dns_get_mx)
struct __res_state *handle = &state;
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|z/", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
return;
}
- mx_list = Z_REFVAL_P(mx_list);
zval_dtor(mx_list);
array_init(mx_list);
if (weight_list) {
- weight_list = Z_REFVAL_P(weight_list);
zval_dtor(weight_list);
array_init(weight_list);
}
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 3b07e00443..6720231089 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -192,7 +192,6 @@ static void php_exec_ex(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
if (!ret_array) {
ret = php_exec(mode, cmd, NULL, return_value TSRMLS_CC);
} else {
- ret_array = Z_REFVAL_P(ret_array);
if (Z_TYPE_P(ret_array) != IS_ARRAY) {
zval_dtor(ret_array);
array_init(ret_array);
@@ -200,7 +199,6 @@ static void php_exec_ex(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
ret = php_exec(2, cmd, ret_array, return_value TSRMLS_CC);
}
if (ret_code) {
- ret_code = Z_REFVAL_P(ret_code);
zval_dtor(ret_code);
ZVAL_LONG(ret_code, ret);
}
diff --git a/ext/standard/file.c b/ext/standard/file.c
index f8c3e98108..897eaa7be8 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -344,7 +344,7 @@ PHP_FUNCTION(flock)
php_stream *stream;
long operation = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &arg1, &operation, &arg3) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &arg1, &operation, &arg3) == FAILURE) {
return;
}
@@ -356,16 +356,16 @@ PHP_FUNCTION(flock)
RETURN_FALSE;
}
- if (arg3 && Z_ISREF_P(arg3)) {
- convert_to_long_ex(Z_REFVAL_P(arg3));
- Z_LVAL_P(Z_REFVAL_P(arg3)) = 0;
+ if (arg3) {
+ zval_dtor(arg3);
+ ZVAL_LONG(arg3, 0);
}
/* flock_values contains all possible actions if (operation & 4) we won't block on the lock */
act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0);
if (php_stream_lock(stream, act)) {
- if (operation && errno == EWOULDBLOCK && arg3 && Z_ISREF_P(arg3)) {
- Z_LVAL_P(Z_REFVAL_P(arg3)) = 1;
+ if (operation && errno == EWOULDBLOCK && arg3) {
+ ZVAL_LONG(arg3, 1);
}
RETURN_FALSE;
}
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index aa83b30c45..edd704b068 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -398,8 +398,10 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
z_format = &args[format_offset];
array = &args[1 + format_offset];
- SEPARATE_ZVAL(array);
- convert_to_array_ex(array);
+ if (Z_TYPE_P(array) != IS_ARRAY) {
+ SEPARATE_ZVAL(array);
+ convert_to_array(array);
+ }
argc = 1 + zend_hash_num_elements(Z_ARRVAL_P(array));
newargs = (zval *)safe_emalloc(argc, sizeof(zval), 0);
@@ -421,7 +423,7 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
while (inpos < Z_STRLEN(args[format_offset])) {
int expprec = 0;
- zval tmp;
+ zval *tmp;
PRINTF_DEBUG(("sprintf: format[%d]='%c'\n", inpos, format[inpos]));
PRINTF_DEBUG(("sprintf: outpos=%d\n", outpos));
@@ -551,17 +553,10 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
}
PRINTF_DEBUG(("sprintf: format character='%c'\n", format[inpos]));
/* now we expect to find a type specifier */
- //???? We don't hold zval** in args anymore
- //if (multiuse) {
- ZVAL_DUP(&tmp, &args[argnum]);
- //} else {
- // SEPARATE_ZVAL(&args[argnum]);
- // ZVAL_COPY_VALUE(&tmp, &args[argnum]);
- //}
-
+ tmp = &args[argnum];
switch (format[inpos]) {
case 's': {
- zend_string *str = zval_get_string(&tmp);
+ zend_string *str = zval_get_string(tmp);
php_sprintf_appendstring(&result, &outpos,
str->val,
width, precision, padding,
@@ -573,17 +568,15 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
}
case 'd':
- convert_to_long(&tmp);
php_sprintf_appendint(&result, &outpos,
- Z_LVAL(tmp),
+ zval_get_long(tmp),
width, padding, alignment,
always_sign);
break;
case 'u':
- convert_to_long(&tmp);
php_sprintf_appenduint(&result, &outpos,
- Z_LVAL(tmp),
+ zval_get_long(tmp),
width, padding, alignment);
break;
@@ -593,9 +586,8 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
case 'E':
case 'f':
case 'F':
- convert_to_double(&tmp);
php_sprintf_appenddouble(&result, &outpos,
- Z_DVAL(tmp),
+ zval_get_double(tmp),
width, padding, alignment,
precision, adjusting,
format[inpos], always_sign
@@ -603,39 +595,34 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
break;
case 'c':
- convert_to_long(&tmp);
php_sprintf_appendchar(&result, &outpos,
- (char) Z_LVAL(tmp) TSRMLS_CC);
+ (char) zval_get_long(tmp) TSRMLS_CC);
break;
case 'o':
- convert_to_long(&tmp);
php_sprintf_append2n(&result, &outpos,
- Z_LVAL(tmp),
+ zval_get_long(tmp),
width, padding, alignment, 3,
hexchars, expprec);
break;
case 'x':
- convert_to_long(&tmp);
php_sprintf_append2n(&result, &outpos,
- Z_LVAL(tmp),
+ zval_get_long(tmp),
width, padding, alignment, 4,
hexchars, expprec);
break;
case 'X':
- convert_to_long(&tmp);
php_sprintf_append2n(&result, &outpos,
- Z_LVAL(tmp),
+ zval_get_long(tmp),
width, padding, alignment, 4,
HEXCHARS, expprec);
break;
case 'b':
- convert_to_long(&tmp);
php_sprintf_append2n(&result, &outpos,
- Z_LVAL(tmp),
+ zval_get_long(tmp),
width, padding, alignment, 1,
hexchars, expprec);
break;
@@ -647,7 +634,6 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
default:
break;
}
- zval_ptr_dtor(&tmp);
inpos++;
}
}
diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c
index 5eacc2fe46..e11bb84056 100644
--- a/ext/standard/fsock.c
+++ b/ext/standard/fsock.c
@@ -47,7 +47,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lzzd", &host, &host_len, &port, &zerrno, &zerrstr, &timeout) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/z/d", &host, &host_len, &port, &zerrno, &zerrstr, &timeout) == FAILURE) {
RETURN_FALSE;
}
@@ -68,12 +68,10 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
tv.tv_usec = conv % 1000000;
if (zerrno) {
- zerrno = Z_REFVAL_P(zerrno);
zval_dtor(zerrno);
ZVAL_LONG(zerrno, 0);
}
if (zerrstr) {
- zerrstr = Z_REFVAL_P(zerrstr);
zval_dtor(zerrstr);
ZVAL_EMPTY_STRING(zerrstr);
}
diff --git a/ext/standard/head.c b/ext/standard/head.c
index 30846215f8..7c4b963285 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -228,7 +228,7 @@ PHP_FUNCTION(headers_sent)
const char *file="";
int line=0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zz", &arg1, &arg2) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/z/", &arg1, &arg2) == FAILURE)
return;
if (SG(headers_sent)) {
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 4dcfe83e38..0ec4cd3885 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -1396,12 +1396,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
int input_len;
const int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc TSRMLS_CC, "s|z", &input, &input_len, &info) == FAILURE) {
+ if (zend_parse_parameters(argc TSRMLS_CC, "s|z/", &input, &input_len, &info) == FAILURE) {
return;
}
if (argc == 2) {
- info = Z_REFVAL_P(info);
zval_dtor(info);
array_init(info);
}
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 3fa4ad19a3..dea8c16c07 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -459,7 +459,7 @@ PHP_FUNCTION(proc_open)
php_file_descriptor_t slave_pty = -1;
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "saz|s!a!a!", &command,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "saz/|s!a!a!", &command,
&command_len, &descriptorspec, &pipes, &cwd, &cwd_len, &environment,
&other_options) == FAILURE) {
RETURN_FALSE;
@@ -877,7 +877,6 @@ PHP_FUNCTION(proc_open)
proc->env = env;
if (pipes != NULL) {
- ZVAL_DEREF(pipes);
zval_dtor(pipes);
}
diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c
index 3eb58e1837..ef3fe2969c 100644
--- a/ext/standard/scanf.c
+++ b/ext/standard/scanf.c
@@ -742,11 +742,9 @@ literal:
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = &args[objIndex++];
- zval_dtor(Z_REFVAL_P(current));
- ZVAL_LONG(Z_REFVAL_P(current), (long)(string - baseString) );
-// Z_SET_REFCOUNT_P(current, refcount);
-//??? Z_SET_ISREF_P(current);
+ current = Z_REFVAL(args[objIndex++]);
+ zval_ptr_dtor(current);
+ ZVAL_LONG(current, (long)(string - baseString) );
} else {
add_index_long(return_value, objIndex++, string - baseString);
}
@@ -863,11 +861,9 @@ literal:
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = &args[objIndex++];
- zval_dtor(Z_REFVAL_P(current));
- ZVAL_STRINGL(Z_REFVAL_P(current), string, end-string);
-//??? Z_SET_REFCOUNT_P(current, refcount);
-//??? Z_SET_ISREF_PP(current);
+ current = Z_REFVAL(args[objIndex++]);
+ zval_ptr_dtor(current);
+ ZVAL_STRINGL(current, string, end-string);
} else {
add_index_stringl(return_value, objIndex++, string, end-string);
}
@@ -906,9 +902,9 @@ literal:
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = &args[objIndex++];
- zval_dtor(Z_REFVAL_P(current));
- ZVAL_STRINGL(Z_REFVAL_P(current), string, end-string);
+ current = Z_REFVAL(args[objIndex++]);
+ zval_ptr_dtor(current);
+ ZVAL_STRINGL(current, string, end-string);
} else {
add_index_stringl(return_value, objIndex++, string, end-string);
}
@@ -1060,9 +1056,9 @@ addToInt:
break;
} else if (numVars) {
/* change passed value type to string */
- current = &args[objIndex++];
- zval_dtor(Z_REFVAL_P(current));
- ZVAL_STRING(Z_REFVAL_P(current), buf);
+ current = Z_REFVAL(args[objIndex++]);
+ zval_ptr_dtor(current);
+ ZVAL_STRING(current, buf);
} else {
add_index_string(return_value, objIndex++, buf);
}
@@ -1070,9 +1066,9 @@ addToInt:
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = &args[objIndex++];
- zval_dtor(Z_REFVAL_P(current));
- ZVAL_LONG(Z_REFVAL_P(current), value);
+ current = Z_REFVAL(args[objIndex++]);
+ zval_ptr_dtor(current);
+ ZVAL_LONG(current, value);
} else {
add_index_long(return_value, objIndex++, value);
}
@@ -1175,9 +1171,9 @@ addToFloat:
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = &args[objIndex++];
- zval_dtor(Z_REFVAL_P(current));
- ZVAL_DOUBLE(Z_REFVAL_P(current), dvalue);
+ current = Z_REFVAL(args[objIndex++]);
+ zval_ptr_dtor(current);
+ ZVAL_DOUBLE(current, dvalue);
} else {
add_index_double(return_value, objIndex++, dvalue );
}
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 1d59a97a94..bd0c0de31b 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -102,7 +102,7 @@ PHP_FUNCTION(stream_socket_client)
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zzdlr", &host, &host_len, &zerrno, &zerrstr, &timeout, &flags, &zcontext) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/z/dlr", &host, &host_len, &zerrno, &zerrstr, &timeout, &flags, &zcontext) == FAILURE) {
RETURN_FALSE;
}
@@ -122,12 +122,10 @@ PHP_FUNCTION(stream_socket_client)
tv.tv_usec = conv % 1000000;
#endif
if (zerrno) {
- zerrno = Z_REFVAL_P(zerrno);
zval_dtor(zerrno);
ZVAL_LONG(zerrno, 0);
}
if (zerrstr) {
- zerrstr = Z_REFVAL_P(zerrstr);
zval_dtor(zerrstr);
ZVAL_EMPTY_STRING(zerrstr);
}
@@ -191,7 +189,7 @@ PHP_FUNCTION(stream_socket_server)
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zzlr", &host, &host_len, &zerrno, &zerrstr, &flags, &zcontext) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/z/lr", &host, &host_len, &zerrno, &zerrstr, &flags, &zcontext) == FAILURE) {
RETURN_FALSE;
}
@@ -258,7 +256,7 @@ PHP_FUNCTION(stream_socket_accept)
char *errstr = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|dz", &zstream, &timeout, &zpeername) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|dz/", &zstream, &timeout, &zpeername) == FAILURE) {
RETURN_FALSE;
}
@@ -374,7 +372,7 @@ PHP_FUNCTION(stream_socket_recvfrom)
long flags = 0;
int recvd;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|lz", &zstream, &to_read, &flags, &zremote) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|lz/", &zstream, &to_read, &flags, &zremote) == FAILURE) {
RETURN_FALSE;
}
@@ -743,7 +741,7 @@ PHP_FUNCTION(stream_select)
long usec = 0;
int set_count, max_set_count = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!a/!a/!z!|l", &r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
return;
FD_ZERO(&rfds);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index a600fc800e..3250241bc6 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2264,25 +2264,21 @@ PHP_FUNCTION(substr_replace)
HashPosition pos_from, pos_repl, pos_len;
zval *tmp_str = NULL, *tmp_from = NULL, *tmp_repl = NULL, *tmp_len= NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|z", &str, &repl, &from, &len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|z/", &str, &repl, &from, &len) == FAILURE) {
return;
}
if (Z_TYPE_P(str) != IS_ARRAY) {
- SEPARATE_ZVAL_IF_REF(str);
convert_to_string_ex(str);
}
if (Z_TYPE_P(repl) != IS_ARRAY) {
- SEPARATE_ZVAL_IF_REF(repl);
convert_to_string_ex(repl);
}
if (Z_TYPE_P(from) != IS_ARRAY) {
- SEPARATE_ZVAL_IF_REF(from);
convert_to_long_ex(from);
}
if (argc > 3) {
- SEPARATE_ZVAL(len);
if (Z_TYPE_P(len) != IS_ARRAY) {
l = zval_get_long(len);
}
@@ -3014,12 +3010,11 @@ PHP_FUNCTION(similar_text)
int sim;
int t1_len, t2_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z", &t1, &t1_len, &t2, &t2_len, &percent) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z/", &t1, &t1_len, &t2, &t2_len, &percent) == FAILURE) {
return;
}
if (ac > 2) {
- percent = Z_REFVAL_P(percent);
convert_to_double_ex(percent);
}
@@ -3727,7 +3722,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
int count = 0;
int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|z", &search, &replace, &subject, &zcount) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz|z/", &search, &replace, &subject, &zcount) == FAILURE) {
return;
}
@@ -3767,8 +3762,8 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
php_str_replace_in_subject(search, replace, subject, return_value, case_sensitivity, (argc > 3) ? &count : NULL TSRMLS_CC);
}
if (argc > 3) {
- zval_dtor(Z_REFVAL_P(zcount));
- ZVAL_LONG(Z_REFVAL_P(zcount), count);
+ zval_dtor(zcount);
+ ZVAL_LONG(zcount, count);
}
}
/* }}} */
@@ -4218,7 +4213,7 @@ PHP_FUNCTION(parse_str)
char *res = NULL;
int arglen;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &arg, &arglen, &arrayArg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/", &arg, &arglen, &arrayArg) == FAILURE) {
return;
}
@@ -4235,11 +4230,10 @@ PHP_FUNCTION(parse_str)
} else {
zval ret;
- array_init(&ret);
- sapi_module.treat_data(PARSE_STRING, res, &ret TSRMLS_CC);
/* Clear out the array that was passed in. */
- ZVAL_DEREF(arrayArg);
zval_dtor(arrayArg);
+ array_init(&ret);
+ sapi_module.treat_data(PARSE_STRING, res, &ret TSRMLS_CC);
ZVAL_COPY_VALUE(arrayArg, &ret);
}
}
diff --git a/ext/standard/type.c b/ext/standard/type.c
index 5c7da45ae9..a42dd0bd0b 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -100,6 +100,7 @@ PHP_FUNCTION(settype)
}
ZVAL_DEREF(var);
+ SEPARATE_ZVAL_NOREF(var);
if (!strcasecmp(type, "integer")) {
convert_to_long(var);
} else if (!strcasecmp(type, "int")) {
@@ -378,7 +379,7 @@ PHP_FUNCTION(is_callable)
zend_bool syntax_only = 0;
int check_flags = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|bz", &var,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|bz/", &var,
&syntax_only, &callable_name) == FAILURE) {
return;
}
@@ -387,7 +388,6 @@ PHP_FUNCTION(is_callable)
check_flags |= IS_CALLABLE_CHECK_SYNTAX_ONLY;
}
if (ZEND_NUM_ARGS() > 2) {
- ZVAL_DEREF(callable_name);
retval = zend_is_callable_ex(var, NULL, check_flags, &name, NULL, &error TSRMLS_CC);
zval_dtor(callable_name);
//??? is it necessary to be consistent with old PHP ("\0" support)
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 6abb70c047..1a6a16508c 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -132,7 +132,7 @@ again:
break;
case IS_ARRAY:
myht = Z_ARRVAL_P(struc);
- if (ZEND_HASH_APPLY_PROTECTION(myht) && ++myht->u.v.nApplyCount > 1) {
+ if (level > 1 && ZEND_HASH_APPLY_PROTECTION(myht) && ++myht->u.v.nApplyCount > 1) {
PUTS("*RECURSION*\n");
--myht->u.v.nApplyCount;
return;
@@ -143,7 +143,7 @@ again:
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, num, key, val) {
php_array_element_dump(val, num, key, level TSRMLS_CC);
} ZEND_HASH_FOREACH_END();
- if (ZEND_HASH_APPLY_PROTECTION(myht)) {
+ if (level > 1 && ZEND_HASH_APPLY_PROTECTION(myht)) {
--myht->u.v.nApplyCount;
}
if (is_temp) {
@@ -303,7 +303,7 @@ again:
break;
case IS_ARRAY:
myht = Z_ARRVAL_P(struc);
- if (ZEND_HASH_APPLY_PROTECTION(myht) && myht->u.v.nApplyCount++ > 1) {
+ if (level > 1 && ZEND_HASH_APPLY_PROTECTION(myht) && myht->u.v.nApplyCount++ > 1) {
myht->u.v.nApplyCount--;
PUTS("*RECURSION*\n");
return;
@@ -312,7 +312,7 @@ again:
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) {
zval_array_element_dump(val, index, key, level TSRMLS_CC);
} ZEND_HASH_FOREACH_END();
- if (ZEND_HASH_APPLY_PROTECTION(myht)) {
+ if (level > 1 && ZEND_HASH_APPLY_PROTECTION(myht)) {
myht->u.v.nApplyCount--;
}
if (is_temp) {
@@ -1018,7 +1018,7 @@ PHP_FUNCTION(unserialize)
php_unserialize_data_t var_hash;
zval *consumed = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &buf, &buf_len, &consumed) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/", &buf, &buf_len, &consumed) == FAILURE) {
RETURN_FALSE;
}
@@ -1038,9 +1038,9 @@ PHP_FUNCTION(unserialize)
}
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
- if (consumed && Z_ISREF_P(consumed)) {
- zval_dtor(Z_REFVAL_P(consumed));
- ZVAL_LONG(Z_REFVAL_P(consumed), ((char*)p) - buf);
+ if (consumed) {
+ zval_dtor(consumed);
+ ZVAL_LONG(consumed, ((char*)p) - buf);
}
}
/* }}} */
diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c
index 83875ac9ee..b1cbedbbc1 100644
--- a/ext/sysvmsg/sysvmsg.c
+++ b/ext/sysvmsg/sysvmsg.c
@@ -308,7 +308,7 @@ PHP_FUNCTION(msg_receive)
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlzlz|blz",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz/lz/|blz/",
&queue, &desiredmsgtype, &out_msgtype, &maxsize,
&out_message, &do_unserialize, &flags, &zerrcode) == FAILURE) {
return;
@@ -342,8 +342,6 @@ PHP_FUNCTION(msg_receive)
result = msgrcv(mq->id, messagebuffer, maxsize, desiredmsgtype, realflags);
- ZVAL_DEREF(out_msgtype);
- ZVAL_DEREF(out_message);
zval_dtor(out_msgtype);
zval_dtor(out_message);
ZVAL_LONG(out_msgtype, 0);
@@ -397,7 +395,7 @@ PHP_FUNCTION(msg_send)
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz|bbz",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz|bbz/",
&queue, &msgtype, &message, &do_serialize, &blocking, &zerror) == FAILURE) {
return;
}
@@ -461,7 +459,6 @@ PHP_FUNCTION(msg_send)
if (result == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "msgsnd failed: %s", strerror(errno));
if (zerror) {
- ZVAL_DEREF(zerror);
ZVAL_LONG(zerror, errno);
}
} else {
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 0e9f19a199..bbceb6dcf2 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -1164,7 +1164,7 @@ PHP_FUNCTION(xml_set_object)
xml_parser *parser;
zval *pind, *mythis;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ro", &pind, &mythis) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ro/", &pind, &mythis) == FAILURE) {
return;
}
@@ -1389,19 +1389,17 @@ PHP_FUNCTION(xml_parse_into_struct)
char *data;
int data_len, ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz|z", &pind, &data, &data_len, &xdata, &info) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz/|z/", &pind, &data, &data_len, &xdata, &info) == FAILURE) {
return;
}
if (info) {
- ZVAL_DEREF(info);
zval_ptr_dtor(info);
array_init(info);
}
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
- ZVAL_DEREF(xdata);
zval_ptr_dtor(xdata);
array_init(xdata);
diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c
index 9378529013..e4be0f032c 100644
--- a/ext/xmlrpc/xmlrpc-epi-php.c
+++ b/ext/xmlrpc/xmlrpc-epi-php.c
@@ -775,12 +775,10 @@ PHP_FUNCTION(xmlrpc_decode_request)
zval *method;
int xml_len, encoding_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|s", &xml, &xml_len, &method, &encoding, &encoding_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|s", &xml, &xml_len, &method, &encoding, &encoding_len) == FAILURE) {
return;
}
- ZVAL_DEREF(method);
-
if (USED_RET()) {
decode_request_worker(xml, xml_len, encoding_len ? encoding : NULL, method, return_value);
}
@@ -1377,12 +1375,10 @@ PHP_FUNCTION(xmlrpc_set_type)
int type_len;
XMLRPC_VALUE_TYPE vtype;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &arg, &type, &type_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/s", &arg, &type, &type_len) == FAILURE) {
return;
}
- ZVAL_DEREF(arg);
-
vtype = xmlrpc_str_as_type(type);
if (vtype != xmlrpc_none) {
if (set_zval_xmlrpc_type(arg, vtype) == SUCCESS) {
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 053cc68058..e73d9c095c 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -2111,7 +2111,7 @@ static ZIPARCHIVE_METHOD(getExternalAttributesName)
ZIP_FROM_OBJECT(intern, self);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz|l",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/z/|l",
&name, &name_len, &z_opsys, &z_attr, &flags) == FAILURE) {
return;
}
@@ -2128,10 +2128,8 @@ static ZIPARCHIVE_METHOD(getExternalAttributesName)
(zip_flags_t)flags, &opsys, &attr) < 0) {
RETURN_FALSE;
}
- ZVAL_DEREF(z_opsys);
zval_ptr_dtor(z_opsys);
ZVAL_LONG(z_opsys, opsys);
- ZVAL_DEREF(z_attr);
zval_ptr_dtor(z_attr);
ZVAL_LONG(z_attr, attr);
RETURN_TRUE;
@@ -2155,7 +2153,7 @@ static ZIPARCHIVE_METHOD(getExternalAttributesIndex)
ZIP_FROM_OBJECT(intern, self);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzz|l",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz/z/|l",
&index, &z_opsys, &z_attr, &flags) == FAILURE) {
return;
}
@@ -2165,10 +2163,8 @@ static ZIPARCHIVE_METHOD(getExternalAttributesIndex)
(zip_flags_t)flags, &opsys, &attr) < 0) {
RETURN_FALSE;
}
- ZVAL_DEREF(z_opsys);
zval_dtor(z_opsys);
ZVAL_LONG(z_opsys, opsys);
- ZVAL_DEREF(z_attr);
zval_dtor(z_attr);
ZVAL_LONG(z_attr, attr);
RETURN_TRUE;