summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorYiduo (David) Wang <davidw@php.net>2007-10-07 05:22:07 +0000
committerYiduo (David) Wang <davidw@php.net>2007-10-07 05:22:07 +0000
commit4b4d634cb956de1efc13c8ed9b243fe1a85f783b (patch)
treeeaa8d691de244aff3ee68fd3c23f769f02fa4446 /ext
parentca4c55ad3a673257925bd9b458683c4f0e60e755 (diff)
downloadphp-git-4b4d634cb956de1efc13c8ed9b243fe1a85f783b.tar.gz
MFH: Added macros for managing zval refcounts and is_ref statuses
Diffstat (limited to 'ext')
-rw-r--r--ext/com_dotnet/com_handlers.c8
-rw-r--r--ext/com_dotnet/com_saproxy.c6
-rw-r--r--ext/com_dotnet/com_wrapper.c2
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/dom/attr.c2
-rw-r--r--ext/dom/characterdata.c2
-rw-r--r--ext/dom/document.c22
-rw-r--r--ext/dom/dom_iterators.c6
-rw-r--r--ext/dom/node.c4
-rw-r--r--ext/dom/php_dom.c12
-rw-r--r--ext/dom/processinginstruction.c2
-rw-r--r--ext/iconv/iconv.c2
-rw-r--r--ext/json/JSON_parser.c6
-rw-r--r--ext/libxml/libxml.c2
-rw-r--r--ext/mbstring/mbstring.c4
-rw-r--r--ext/mbstring/php_mbregex.c2
-rw-r--r--ext/mysql/php_mysql.c2
-rw-r--r--ext/mysqli/mysqli.c8
-rw-r--r--ext/mysqli/mysqli_api.c4
-rw-r--r--ext/oci8/oci8.c2
-rw-r--r--ext/pcre/php_pcre.c4
-rwxr-xr-xext/pdo/pdo_dbh.c8
-rwxr-xr-xext/pdo/pdo_stmt.c14
-rw-r--r--ext/reflection/php_reflection.c16
-rw-r--r--ext/session/session.c6
-rw-r--r--ext/simplexml/simplexml.c18
-rw-r--r--ext/soap/php_encoding.c10
-rw-r--r--ext/soap/php_http.c2
-rw-r--r--ext/soap/php_packet_soap.c4
-rw-r--r--ext/soap/soap.c12
-rwxr-xr-xext/spl/php_spl.c2
-rwxr-xr-xext/spl/spl_array.c32
-rwxr-xr-xext/spl/spl_directory.c6
-rwxr-xr-xext/spl/spl_engine.c4
-rwxr-xr-xext/spl/spl_iterators.c18
-rwxr-xr-xext/spl/spl_observer.c2
-rw-r--r--ext/sqlite/sqlite.c10
-rw-r--r--ext/standard/array.c36
-rw-r--r--ext/standard/basic_functions.c6
-rw-r--r--ext/standard/php_filestat.h2
-rw-r--r--ext/standard/scanf.c12
-rw-r--r--ext/standard/streamsfuncs.c2
-rw-r--r--ext/standard/string.c2
-rw-r--r--ext/standard/user_filters.c4
-rw-r--r--ext/standard/var.c10
-rw-r--r--ext/standard/var_unserializer.c10
-rw-r--r--ext/standard/var_unserializer.re10
-rw-r--r--ext/sybase/php_sybase_db.c6
-rw-r--r--ext/tidy/tidy.c4
-rw-r--r--ext/xmlreader/php_xmlreader.c2
-rw-r--r--ext/xsl/xsltprocessor.c2
-rw-r--r--ext/zip/php_zip.c6
52 files changed, 192 insertions, 192 deletions
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index dc15b4032d..113e8b02f4 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -38,8 +38,8 @@ static zval *com_property_read(zval *object, zval *member, int type TSRMLS_DC)
MAKE_STD_ZVAL(return_value);
ZVAL_NULL(return_value);
- return_value->refcount = 0;
- return_value->is_ref = 0;
+ Z_SET_REFCOUNT_P(return_value, 0);
+ Z_UNSET_ISREF_P(return_value);
obj = CDNO_FETCH(object);
@@ -92,8 +92,8 @@ static zval *com_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
MAKE_STD_ZVAL(return_value);
ZVAL_NULL(return_value);
- return_value->refcount = 0;
- return_value->is_ref = 0;
+ Z_SET_REFCOUNT_P(return_value, 0);
+ Z_UNSET_ISREF_P(return_value);
obj = CDNO_FETCH(object);
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index 98b6c43d29..624703de57 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -427,7 +427,7 @@ static void saproxy_clone(void *object, void **clone_ptr TSRMLS_DC)
cloneproxy = emalloc(sizeof(*cloneproxy));
memcpy(cloneproxy, proxy, sizeof(*cloneproxy));
- ZVAL_ADDREF(cloneproxy->zobj);
+ Z_ADDREF_P(cloneproxy->zobj);
cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval *), 0);
clone_indices(cloneproxy, proxy, proxy->dimensions);
@@ -451,7 +451,7 @@ int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index TSRMLS
proxy->zobj = com_object;
}
- ZVAL_ADDREF(proxy->zobj);
+ Z_ADDREF_P(proxy->zobj);
proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval *), 0);
if (rel) {
@@ -570,7 +570,7 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec
I->proxy = proxy;
I->proxy_obj = object;
- ZVAL_ADDREF(I->proxy_obj);
+ Z_ADDREF_P(I->proxy_obj);
I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);
for (i = 0; i < proxy->dimensions; i++) {
diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c
index 0dfc9247fa..132697ab57 100644
--- a/ext/com_dotnet/com_wrapper.c
+++ b/ext/com_dotnet/com_wrapper.c
@@ -551,7 +551,7 @@ static php_dispatchex *disp_constructor(zval *object TSRMLS_DC)
if (object)
- ZVAL_ADDREF(object);
+ Z_ADDREF_P(object);
disp->object = object;
disp->id = zend_list_insert(disp, le_dispatch);
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 0d054ceb9f..eb187b8a12 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1627,8 +1627,8 @@ static zval * date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, pce);
- object->refcount = 1;
- object->is_ref = 0;
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_UNSET_ISREF_P(object);
return object;
}
diff --git a/ext/dom/attr.c b/ext/dom/attr.c
index 8a8c8f9c0e..4808d7dd79 100644
--- a/ext/dom/attr.c
+++ b/ext/dom/attr.c
@@ -179,7 +179,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC)
}
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c
index 60a3fc3019..604a95c411 100644
--- a/ext/dom/characterdata.c
+++ b/ext/dom/characterdata.c
@@ -86,7 +86,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval TSRMLS_DC)
}
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
diff --git a/ext/dom/document.c b/ext/dom/document.c
index 894cdcf928..acfcc71f1d 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -216,7 +216,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval TSRMLS_DC)
}
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -284,7 +284,7 @@ int dom_document_standalone_write(dom_object *obj, zval *newval TSRMLS_DC)
return FAILURE;
}
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -359,7 +359,7 @@ int dom_document_version_write(dom_object *obj, zval *newval TSRMLS_DC)
}
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -402,7 +402,7 @@ int dom_document_strict_error_checking_write(dom_object *obj, zval *newval TSRML
zval value_copy;
dom_doc_propsptr doc_prop;
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -445,7 +445,7 @@ int dom_document_format_output_write(dom_object *obj, zval *newval TSRMLS_DC)
zval value_copy;
dom_doc_propsptr doc_prop;
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -487,7 +487,7 @@ int dom_document_validate_on_parse_write(dom_object *obj, zval *newval TSRMLS_DC
zval value_copy;
dom_doc_propsptr doc_prop;
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -530,7 +530,7 @@ int dom_document_resolve_externals_write(dom_object *obj, zval *newval TSRMLS_DC
zval value_copy;
dom_doc_propsptr doc_prop;
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -573,7 +573,7 @@ int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_
zval value_copy;
dom_doc_propsptr doc_prop;
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -615,7 +615,7 @@ int dom_document_recover_write(dom_object *obj, zval *newval TSRMLS_DC)
zval value_copy;
dom_doc_propsptr doc_prop;
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -658,7 +658,7 @@ int dom_document_substitue_entities_write(dom_object *obj, zval *newval TSRMLS_D
zval value_copy;
dom_doc_propsptr doc_prop;
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -724,7 +724,7 @@ int dom_document_document_uri_write(dom_object *obj, zval *newval TSRMLS_DC)
}
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c
index 88d78e6a5c..53fb0853d1 100644
--- a/ext/dom/dom_iterators.c
+++ b/ext/dom/dom_iterators.c
@@ -209,7 +209,7 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
zend_hash_move_forward(nodeht);
if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {
curattr = *entry;
- curattr->refcount++;
+ Z_ADDREF_P(curattr);
}
} else {
curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node;
@@ -273,7 +273,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
}
iterator = emalloc(sizeof(php_dom_iterator));
- object->refcount++;
+ Z_ADDREF_P(object);
iterator->intern.data = (void*)object;
iterator->intern.funcs = &php_dom_iterator_funcs;
@@ -287,7 +287,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
zend_hash_internal_pointer_reset(nodeht);
if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {
curattr = *entry;
- curattr->refcount++;
+ Z_ADDREF_P(curattr);
}
} else {
nodep = (xmlNode *)dom_object_get_node(objmap->baseobj);
diff --git a/ext/dom/node.c b/ext/dom/node.c
index cd5ce8cf3b..5a0878fd42 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -240,7 +240,7 @@ int dom_node_node_value_write(dom_object *obj, zval *newval TSRMLS_DC)
case XML_CDATA_SECTION_NODE:
case XML_PI_NODE:
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
@@ -700,7 +700,7 @@ int dom_node_prefix_write(dom_object *obj, zval *newval TSRMLS_DC)
}
}
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 31e494b585..4c23938910 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -336,8 +336,8 @@ zval *dom_read_property(zval *object, zval *member, int type TSRMLS_DC)
ret = hnd->read_func(obj, &retval TSRMLS_CC);
if (ret == SUCCESS) {
/* ensure we're creating a temporary variable */
- retval->refcount = 0;
- retval->is_ref = 0;
+ Z_SET_REFCOUNT_P(retval, 0);
+ Z_UNSET_ISREF_P(retval);
} else {
retval = EG(uninitialized_zval_ptr);
}
@@ -416,8 +416,8 @@ static int dom_property_exists(zval *object, zval *member, int check_empty TSRML
if (check_empty == 2) {
retval = 1;
} else if (hnd->read_func(obj, &tmp TSRMLS_CC) == SUCCESS) {
- tmp->refcount = 1;
- tmp->is_ref = 0;
+ Z_SET_REFCOUNT_P(tmp, 1);
+ Z_UNSET_ISREF_P(tmp);
if (check_empty == 1) {
retval = zend_is_true(tmp);
} else if (check_empty == 0) {
@@ -1006,7 +1006,7 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml
if (basenode) {
MAKE_STD_ZVAL(baseobj);
baseobj->type = IS_OBJECT;
- baseobj->is_ref = 1;
+ Z_SET_ISREF_P(baseobj);
baseobj->value.obj.handle = basenode->handle;
baseobj->value.obj.handlers = dom_get_obj_handlers(TSRMLS_C);
zval_copy_ctor(baseobj);
@@ -1201,7 +1201,7 @@ PHP_DOM_EXPORT zval *php_dom_create_object(xmlNodePtr obj, int *found, zval *wra
if ((intern = (dom_object *) php_dom_object_get_data((void *) obj))) {
return_value->type = IS_OBJECT;
- return_value->is_ref = 1;
+ Z_SET_ISREF_P(return_value);
return_value->value.obj.handle = intern->handle;
return_value->value.obj.handlers = dom_get_obj_handlers(TSRMLS_C);
zval_copy_ctor(return_value);
diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c
index a30fae82ea..2f9c1bccc2 100644
--- a/ext/dom/processinginstruction.c
+++ b/ext/dom/processinginstruction.c
@@ -151,7 +151,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval TSRMLS_DC
}
if (newval->type != IS_STRING) {
- if(newval->refcount > 1) {
+ if(Z_REFCOUNT_P(newval) > 1) {
value_copy = *newval;
zval_copy_ctor(&value_copy);
newval = &value_copy;
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 4c92385c18..2a4d6d7235 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -2278,7 +2278,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
MAKE_STD_ZVAL(new_elem);
array_init(new_elem);
- ZVAL_ADDREF(*elem);
+ Z_ADDREF_PP(elem);
add_next_index_zval(new_elem, *elem);
zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL);
diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c
index c054d5038e..6a359ce206 100644
--- a/ext/json/JSON_parser.c
+++ b/ext/json/JSON_parser.c
@@ -364,7 +364,7 @@ static void attach_zval(json_parser *json, int up, int cur, smart_str *key, int
{
add_property_zval_ex(root, (key->len ? key->c : "_empty_"), (key->len ? (key->len + 1) : sizeof("_empty_")), child TSRMLS_CC);
#if PHP_MAJOR_VERSION >= 5
- ZVAL_DELREF(child);
+ Z_DELREF_P(child);
#endif
}
else
@@ -507,7 +507,7 @@ JSON_parser(zval *z, unsigned short p[], int length, int assoc TSRMLS_DC)
{
add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : "_empty_"), (key.len ? (key.len + 1) : sizeof("_empty_")), mval TSRMLS_CC);
#if PHP_MAJOR_VERSION >= 5
- ZVAL_DELREF(mval);
+ Z_DELREF_P(mval);
#endif
}
else
@@ -638,7 +638,7 @@ JSON_parser(zval *z, unsigned short p[], int length, int assoc TSRMLS_DC)
{
add_property_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : "_empty_"), (key.len ? (key.len + 1) : sizeof("_empty_")), mval TSRMLS_CC);
#if PHP_MAJOR_VERSION >= 5
- ZVAL_DELREF(mval);
+ Z_DELREF_P(mval);
#endif
}
else
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index d572ae4e73..b81b65bea1 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -710,7 +710,7 @@ static PHP_FUNCTION(libxml_set_streams_context)
zval_ptr_dtor(&LIBXML(stream_context));
LIBXML(stream_context) = NULL;
}
- ZVAL_ADDREF(arg);
+ Z_ADDREF_P(arg);
LIBXML(stream_context) = arg;
}
/* }}} */
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 723b145f33..c4e9ce8e39 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -3172,8 +3172,8 @@ detect_end:
string.len = Z_STRLEN_PP(hash_entry);
ret = mbfl_buffer_converter_feed_result(convd, &string, &result);
if (ret != NULL) {
- if ((*hash_entry)->refcount > 1) {
- ZVAL_DELREF(*hash_entry);
+ if (Z_REFCOUNT_PP(hash_entry) > 1) {
+ Z_DELREF_PP(hash_entry);
MAKE_STD_ZVAL(*hash_entry);
} else {
zval_dtor(*hash_entry);
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 81b39b1bd8..79ff22a503 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -1112,7 +1112,7 @@ PHP_FUNCTION(mb_ereg_search_init)
}
MBSTRG(search_str) = *arg_str;
- ZVAL_ADDREF(MBSTRG(search_str));
+ Z_ADDREF_P(MBSTRG(search_str));
SEPARATE_ZVAL_IF_NOT_REF(&MBSTRG(search_str));
MBSTRG(search_pos) = 0;
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 41a90c622d..deb769c817 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -2065,7 +2065,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
}
if (result_type & MYSQL_ASSOC) {
if (result_type & MYSQL_NUM) {
- ZVAL_ADDREF(data);
+ Z_ADDREF_P(data);
}
add_assoc_zval(return_value, mysql_field->name, data);
}
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 8de80f5e05..fcf946372d 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -352,7 +352,7 @@ zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC)
ret = hnd->read_func(obj, &retval TSRMLS_CC);
if (ret == SUCCESS) {
/* ensure we're creating a temporary variable */
- retval->refcount = 0;
+ Z_SET_REFCOUNT_P(retval, 0);
} else {
retval = EG(uninitialized_zval_ptr);
}
@@ -392,8 +392,8 @@ void mysqli_write_property(zval *object, zval *member, zval *value TSRMLS_DC)
}
if (ret == SUCCESS) {
hnd->write_func(obj, value TSRMLS_CC);
- if (! PZVAL_IS_REF(value) && value->refcount == 0) {
- value->refcount++;
+ if (! PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) == 0) {
+ Z_ADDREF_P(value);
zval_ptr_dtor(&value);
}
} else {
@@ -1092,7 +1092,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
}
if (fetchtype & MYSQLI_ASSOC) {
if (fetchtype & MYSQLI_NUM) {
- ZVAL_ADDREF(res);
+ Z_ADDREF_P(res);
}
add_assoc_zval(return_value, fields[i].name, res);
}
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 5e55be7d51..e14c59268f 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -138,7 +138,7 @@ end_1:
stmt->param.vars = (zval **)safe_emalloc(num_vars, sizeof(zval), 0);
for (i = 0; i < num_vars; i++) {
if (bind[i].buffer_type != MYSQL_TYPE_LONG_BLOB) {
- ZVAL_ADDREF(*args[i+start]);
+ Z_ADDREF_PP(*args[i+start]);
stmt->param.vars[i] = *args[i+start];
} else {
stmt->param.vars[i] = NULL;
@@ -426,7 +426,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
stmt->result.vars = (zval **)safe_emalloc((var_cnt), sizeof(zval), 0);
for (i = start; i < var_cnt+start; i++) {
ofs = i-start;
- ZVAL_ADDREF(*args[i]);
+ Z_ADDREF_PP(args[i]);
stmt->result.vars[ofs] = *args[i];
}
}
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index d6427fb297..3481015d69 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -1754,7 +1754,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
}
if (fetch_mode & PHP_OCI_ASSOC) {
if (fetch_mode & PHP_OCI_NUM) {
- ZVAL_ADDREF(element);
+ Z_ADDREF_P(element);
}
add_assoc_zval(return_value, column->name, element);
}
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 41b390806c..28b6b21b15 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -723,7 +723,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
if (subpat_names[i]) {
zend_hash_update(Z_ARRVAL_P(subpats), subpat_names[i],
strlen(subpat_names[i])+1, &match_sets[i], sizeof(zval *), NULL);
- ZVAL_ADDREF(match_sets[i]);
+ Z_ADDREF_P(match_sets[i]);
}
zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &match_sets[i], sizeof(zval *), NULL);
}
@@ -1723,7 +1723,7 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return
/* If the entry fits our requirements */
if ((count > 0 && !invert) ||
(count == PCRE_ERROR_NOMATCH && invert)) {
- (*entry)->refcount++;
+ Z_ADDREF_PP(entry);
/* Add to return array */
switch (zend_hash_get_current_key(Z_ARRVAL_P(input), &string_key, &num_key, 0))
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index d1d83c0dc8..85a53bf93d 100755
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -429,8 +429,8 @@ static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry
Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, dbstmt_ce);
- object->refcount = 1;
- object->is_ref = 1;
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_SET_ISREF_P(object);
return object;
} /* }}} */
@@ -778,7 +778,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
PDO_HANDLE_DBH_ERR();
return FAILURE;
}
- (*item)->refcount++;
+ Z_ADDREF_PP(item);
dbh->def_stmt_ctor_args = *item;
}
return SUCCESS;
@@ -865,7 +865,7 @@ static PHP_METHOD(PDO, getAttribute)
array_init(return_value);
add_next_index_string(return_value, dbh->def_stmt_ce->name, 1);
if (dbh->def_stmt_ctor_args) {
- dbh->def_stmt_ctor_args->refcount++;
+ Z_ADDREF_P(dbh->def_stmt_ctor_args);
add_next_index_zval(return_value, dbh->def_stmt_ctor_args);
}
return;
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 693d03d690..1c8881ec5a 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -321,7 +321,7 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
param->is_param = is_param;
if (param->driver_params) {
- ZVAL_ADDREF(param->driver_params);
+ Z_ADDREF_P(param->driver_params);
}
if (!is_param && param->name && stmt->columns) {
@@ -1088,7 +1088,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
case PDO_FETCH_USE_DEFAULT:
case PDO_FETCH_BOTH:
add_assoc_zval(return_value, stmt->columns[i].name, val);
- ZVAL_ADDREF(val);
+ Z_ADDREF_P(val);
add_next_index_zval(return_value, val);
break;
@@ -1621,7 +1621,7 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt,
return 0;
}
- ZVAL_ADDREF(param.parameter);
+ Z_ADDREF_P(param.parameter);
if (!really_register_bound_param(&param, stmt, is_param TSRMLS_CC)) {
if (param.parameter) {
zval_ptr_dtor(&(param.parameter));
@@ -1657,7 +1657,7 @@ static PHP_METHOD(PDOStatement, bindValue)
RETURN_FALSE;
}
- ZVAL_ADDREF(param.parameter);
+ Z_ADDREF_P(param.parameter);
if (!really_register_bound_param(&param, stmt, TRUE TSRMLS_CC)) {
if (param.parameter) {
zval_ptr_dtor(&(param.parameter));
@@ -1877,7 +1877,7 @@ int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, in
switch (stmt->default_fetch_type) {
case PDO_FETCH_INTO:
if (stmt->fetch.into) {
- ZVAL_DELREF(stmt->fetch.into);
+ Z_DELREF_P(stmt->fetch.into);
stmt->fetch.into = NULL;
}
break;
@@ -2548,8 +2548,8 @@ static zval *row_prop_or_dim_read(zval *object, zval *member, int type TSRMLS_DC
}
}
- return_value->refcount = 0;
- return_value->is_ref = 0;
+ Z_SET_REFCOUNT_P(return_value, 0);
+ Z_UNSET_ISREF_P(return_value);
return return_value;
}
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 7319926844..139e60b9d4 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -278,8 +278,8 @@ static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_
}
Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, pce);
- object->refcount = 1;
- object->is_ref = 1;
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_SET_ISREF_P(object);
return object;
}
@@ -2788,13 +2788,13 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
"Class %s does not have a property named %s", ce->name, name);
return;
}
- refcount = (*variable_ptr)->refcount;
- is_ref = (*variable_ptr)->is_ref;
+ refcount = Z_REFCOUNT_PP(variable_ptr);
+ is_ref = Z_ISREF_PP(variable_ptr);
zval_dtor(*variable_ptr);
**variable_ptr = *value;
zval_copy_ctor(*variable_ptr);
- (*variable_ptr)->refcount = refcount;
- (*variable_ptr)->is_ref = is_ref;
+ Z_SET_REFCOUNT_PP(variable_ptr, refcount);
+ Z_SET_ISREF_TO_PP(variable_ptr, is_ref);
}
/* }}} */
@@ -4031,7 +4031,7 @@ ZEND_METHOD(reflection_property, setValue)
zval_dtor(*variable_ptr);
(*variable_ptr)->type = value->type;
(*variable_ptr)->value = value->value;
- if (value->refcount > 0) {
+ if (Z_REFCOUNT_P(value) > 0) {
zval_copy_ctor(*variable_ptr);
}
setter_done = 1;
@@ -4040,7 +4040,7 @@ ZEND_METHOD(reflection_property, setValue)
if (!setter_done) {
zval **foo;
- value->refcount++;
+ Z_ADDREF_P(value);
if (PZVAL_IS_REF(value)) {
SEPARATE_ZVAL(&value);
}
diff --git a/ext/session/session.c b/ext/session/session.c
index dbc9902532..ec3dd2e807 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -339,7 +339,7 @@ PHPAPI void php_add_session_var(char *name, size_t namelen TSRMLS_DC)
zval *empty_var;
ALLOC_INIT_ZVAL(empty_var); /* this sets refcount to 1 */
- empty_var->refcount = 0; /* our module does not maintain a ref */
+ Z_SET_REFCOUNT_P(empty_var, 0); /* our module does not maintain a ref */
/* The next call will increase refcount by NR_OF_SYM_TABLES==2 */
zend_set_hash_symbol(empty_var, name, namelen, 1, 2, Z_ARRVAL_P(PS(http_session_vars)), &EG(symbol_table));
} else if (sym_global == NULL) {
@@ -869,7 +869,7 @@ static int migrate_global(HashTable *ht, HashPosition *pos TSRMLS_DC)
(void **) &val) == SUCCESS
&& val && Z_TYPE_PP(val) != IS_NULL) {
ZEND_SET_SYMBOL_WITH_LENGTH(ht, str, str_len, *val,
- (*val)->refcount + 1 , 1);
+ Z_REFCOUNT_PP(val) + 1 , 1);
ret = 1;
}
break;
@@ -1512,7 +1512,7 @@ PHP_FUNCTION(session_set_save_handler)
mdata = emalloc(sizeof(*mdata));
for (i = 0; i < 6; i++) {
- ZVAL_ADDREF(*args[i]);
+ Z_ADDREF_PP(args[i]);
mdata->names[i] = *args[i];
}
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 220ff06307..c847df27b3 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -365,8 +365,8 @@ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements,
}
}
- return_value->refcount = 0;
- return_value->is_ref = 0;
+ Z_SET_REFCOUNT_P(return_value, 0);
+ Z_UNSET_ISREF_P(return_value);
if (member == &tmp_zv) {
zval_dtor(&tmp_zv);
@@ -414,7 +414,7 @@ static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC)
case IS_BOOL:
case IS_DOUBLE:
case IS_NULL:
- if (value->refcount > 1) {
+ if (Z_REFCOUNT_P(value) > 1) {
value_copy = *value;
zval_copy_ctor(&value_copy);
value = &value_copy;
@@ -534,7 +534,7 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo
case IS_BOOL:
case IS_DOUBLE:
case IS_NULL:
- if (value->refcount > 1) {
+ if (Z_REFCOUNT_P(value) > 1) {
value_copy = *value;
zval_copy_ctor(&value_copy);
value = &value_copy;
@@ -712,7 +712,7 @@ static zval** sxe_property_get_adr(zval *object, zval *member TSRMLS_DC) /* {{{
sxe = php_sxe_fetch_object(return_value TSRMLS_CC);
sxe->tmp = return_value;
- return_value->is_ref = 1;
+ Z_SET_ISREF_P(return_value);
return &sxe->tmp;
}
@@ -1673,8 +1673,8 @@ static int cast_object(zval *object, int type, char *contents TSRMLS_DC)
} else {
ZVAL_NULL(object);
}
- object->refcount = 1;
- object->is_ref = 0;
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_UNSET_ISREF_P(object);
switch (type) {
case IS_STRING:
@@ -1782,7 +1782,7 @@ static zval *sxe_get_value(zval *z TSRMLS_DC)
/* FIXME: Should not be fatal */
}
- retval->refcount = 0;
+ Z_SET_REFCOUNT_P(retval, 0);
return retval;
}
@@ -2195,7 +2195,7 @@ zend_object_iterator *php_sxe_get_iterator(zend_class_entry *ce, zval *object, i
}
iterator = emalloc(sizeof(php_sxe_iterator));
- object->refcount++;
+ Z_ADDREF_P(object);
iterator->intern.data = (void*)object;
iterator->intern.funcs = &php_sxe_iterator_funcs;
iterator->sxe = php_sxe_fetch_object(object TSRMLS_CC);
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 2f7008b5b2..b48f61591b 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -346,8 +346,8 @@ static zend_bool soap_check_xml_ref(zval **data, xmlNodePtr node TSRMLS_DC)
if (*data != *data_ptr) {
zval_ptr_dtor(data);
*data = *data_ptr;
- (*data)->is_ref = 1;
- (*data)->refcount++;
+ Z_SET_ISREF_PP(data);
+ Z_ADDREF_PP(data);
return 1;
}
} else {
@@ -1195,7 +1195,7 @@ static void set_zval_property(zval* object, char* name, zval* val TSRMLS_DC)
old_scope = EG(scope);
EG(scope) = Z_OBJCE_P(object);
#ifdef ZEND_ENGINE_2
- val->refcount--;
+ Z_DELREF_P(val);
#endif
add_property_zval(object, name, val);
EG(scope) = old_scope;
@@ -1621,7 +1621,7 @@ static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, zend_class_e
MAKE_STD_ZVAL(arr);
array_init(arr);
- prop->refcount++;
+ Z_ADDREF_P(prop);
add_next_index_zval(arr, prop);
set_zval_property(ret, (char*)trav->name, arr TSRMLS_CC);
prop = arr;
@@ -2843,7 +2843,7 @@ static zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data)
object_init_ex(soapvar, soap_var_class_entry);
add_property_long(soapvar, "enc_type", enc->details.type);
#ifdef ZEND_ENGINE_2
- ret->refcount--;
+ Z_DELREF_P(ret);
#endif
add_property_zval(soapvar, "enc_value", ret);
parse_namespace(type_name, &cptype, &ns);
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index 40bba74d61..a868a41efe 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -994,7 +994,7 @@ try_again:
if (digest != NULL) {
php_url *new_url = emalloc(sizeof(php_url));
- digest->refcount--;
+ Z_DELREF_P(digest);
add_property_zval_ex(this_ptr, "_digest", sizeof("_digest"), digest TSRMLS_CC);
*new_url = *phpurl;
diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c
index f2ab47c60a..c7b8c3260c 100644
--- a/ext/soap/php_packet_soap.c
+++ b/ext/soap/php_packet_soap.c
@@ -241,7 +241,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
}
#ifdef ZEND_ENGINE_2
if (details) {
- details->refcount--;
+ Z_DELREF_P(details);
}
#endif
xmlFreeDoc(response);
@@ -387,7 +387,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
zend_hash_internal_pointer_reset(Z_ARRVAL_P(return_value));
zend_hash_get_current_data(Z_ARRVAL_P(return_value), (void**)&tmp);
tmp = *(zval**)tmp;
- tmp->refcount++;
+ Z_ADDREF_P(tmp);
zval_dtor(return_value);
*return_value = *tmp;
FREE_ZVAL(tmp);
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 0024b03743..69e7226ab1 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -2379,7 +2379,7 @@ PHP_METHOD(SoapClient, SoapClient)
INIT_PZVAL(class_map);
zval_copy_ctor(class_map);
#ifdef ZEND_ENGINE_2
- class_map->refcount--;
+ Z_DELREF_P(class_map);
#endif
add_property_zval(this_ptr, "_classmap", class_map);
}
@@ -2795,7 +2795,7 @@ PHP_METHOD(SoapClient, __call)
soap_headers = emalloc(sizeof(HashTable));
zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_next_index_insert(soap_headers, &headers, sizeof(zval*), NULL);
- ZVAL_ADDREF(headers);
+ Z_ADDREF_P(headers);
free_soap_headers = 1;
} else{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid SOAP header");
@@ -2814,7 +2814,7 @@ PHP_METHOD(SoapClient, __call)
}
zend_hash_internal_pointer_reset(default_headers);
while (zend_hash_get_current_data(default_headers, (void**)&tmp) == SUCCESS) {
- ZVAL_ADDREF(*tmp);
+ Z_ADDREF_PP(tmp);
zend_hash_next_index_insert(soap_headers, tmp, sizeof(zval *), NULL);
zend_hash_move_forward(default_headers);
}
@@ -3060,9 +3060,9 @@ PHP_METHOD(SoapClient, __setSoapHeaders)
zval *default_headers;
ALLOC_INIT_ZVAL(default_headers);
array_init(default_headers);
- headers->refcount++;
+ Z_ADDREF_P(headers);
add_next_index_zval(default_headers, headers);
- default_headers->refcount--;
+ Z_DELREF_P(default_headers);
add_property_zval(this_ptr, "__default_headers", default_headers);
} else{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid SOAP header");
@@ -3152,7 +3152,7 @@ zval* add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *faul
ALLOC_INIT_ZVAL(fault);
set_soap_fault(fault, NULL, fault_code, fault_string, fault_actor, fault_detail, NULL TSRMLS_CC);
#ifdef ZEND_ENGINE_2
- fault->refcount--;
+ Z_DELREF_P(fault);
#endif
add_property_zval(obj, "__soap_fault", fault);
return fault;
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index c4c3948344..cc88d91906 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -468,7 +468,7 @@ PHP_FUNCTION(spl_autoload_register)
func_name_len += sizeof(zend_object_handle);
lc_name[func_name_len] = '\0';
alfi.obj = *obj_ptr;
- alfi.obj->refcount++;
+ Z_ADDREF_P(alfi.obj);
} else {
alfi.obj = NULL;
}
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 7fa11bd882..cc6ee0e658 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -152,11 +152,11 @@ static zend_object_value spl_array_object_new_ex(zend_class_entry *class_type, s
zend_hash_copy(HASH_OF(intern->array), HASH_OF(other->array), (copy_ctor_func_t) zval_add_ref, &tmp, sizeof(zval*));
}
if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayIterator) {
- ZVAL_ADDREF(other->array);
+ Z_ADDREF_P(other->array);
}
} else {
intern->array = orig;
- ZVAL_ADDREF(intern->array);
+ Z_ADDREF_P(intern->array);
intern->ar_flags |= SPL_ARRAY_IS_REF | SPL_ARRAY_USE_OTHER;
}
} else {
@@ -320,22 +320,22 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval
/* When in a write context,
* ZE has to be fooled into thinking this is in a reference set
* by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */
- if ((type == BP_VAR_W || type == BP_VAR_RW) && !(*ret)->is_ref) {
- if ((*ret)->refcount > 1) {
+ if ((type == BP_VAR_W || type == BP_VAR_RW) && !Z_ISREF_PP(ret)) {
+ if (Z_REFCOUNT_PP(ret) > 1) {
zval *newval;
/* Separate */
MAKE_STD_ZVAL(newval);
*newval = **ret;
zval_copy_ctor(newval);
- newval->refcount = 1;
+ Z_SET_REFCOUNT_P(newval, 1);
/* Replace */
- (*ret)->refcount--;
+ Z_DELREF_PP(ret);
*ret = newval;
}
- (*ret)->is_ref = 1;
+ Z_SET_ISREF_PP(ret);
}
return *ret;
@@ -363,7 +363,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
}
if (!offset) {
- value->refcount++;
+ Z_ADDREF_P(value);
zend_hash_next_index_insert(spl_array_get_hash_table(intern, 0 TSRMLS_CC), (void**)&value, sizeof(void*), NULL);
return;
}
@@ -373,7 +373,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
zend_throw_exception(spl_ce_InvalidArgumentException, "An offset must not begin with \\0 or be empty", 0 TSRMLS_CC);
return;
}
- value->refcount++;
+ Z_ADDREF_P(value);
zend_symtable_update(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);
return;
case IS_DOUBLE:
@@ -385,11 +385,11 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
} else {
index = Z_LVAL_P(offset);
}
- value->refcount++;
+ Z_ADDREF_P(value);
zend_hash_index_update(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index, (void**)&value, sizeof(void*), NULL);
return;
case IS_NULL:
- value->refcount++;
+ Z_ADDREF_P(value);
zend_hash_next_index_insert(spl_array_get_hash_table(intern, 0 TSRMLS_CC), (void**)&value, sizeof(void*), NULL);
return;
default:
@@ -873,7 +873,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
iterator = emalloc(sizeof(spl_array_it));
- object->refcount++;
+ Z_ADDREF_P(object);
iterator->intern.it.data = (void*)object;
iterator->intern.it.funcs = &spl_array_it_funcs;
iterator->intern.ce = ce;
@@ -949,7 +949,7 @@ SPL_METHOD(Array, __construct)
intern->ar_flags &= ~SPL_ARRAY_IS_SELF;
}
intern->ar_flags |= ar_flags;
- ZVAL_ADDREF(intern->array);
+ Z_ADDREF_P(intern->array);
if (Z_TYPE_PP(array) == IS_OBJECT) {
zend_object_get_properties_t handler = Z_OBJ_HANDLER_PP(array, get_properties);
if ((handler != std_object_handlers.get_properties && handler != spl_array_get_properties)
@@ -1063,7 +1063,7 @@ SPL_METHOD(Array, exchangeArray)
} else {
intern->ar_flags &= ~SPL_ARRAY_IS_SELF;
}
- ZVAL_ADDREF(intern->array);
+ Z_ADDREF_P(intern->array);
spl_array_rewind(intern TSRMLS_CC);
}
@@ -1085,8 +1085,8 @@ SPL_METHOD(Array, getIterator)
return_value->type = IS_OBJECT;
return_value->value.obj = spl_array_object_new_ex(intern->ce_get_iterator, &iterator, object, 0 TSRMLS_CC);
- return_value->refcount = 1;
- return_value->is_ref = 1;
+ Z_SET_REFCOUNT_P(return_value, 1);
+ Z_SET_ISREF_P(return_value);
}
/* }}} */
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 1b122af5f4..bf3eb83f5a 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -231,7 +231,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
/* avoid reference counting in debug mode, thus do it manually */
ZVAL_RESOURCE(&intern->u.file.zresource, php_stream_get_resource_id(intern->u.file.stream));
- intern->u.file.zresource.refcount = 1;
+ Z_SET_REFCOUNT(intern->u.file.zresource, 1);
intern->u.file.delimiter = ',';
intern->u.file.enclosure = '"';
@@ -1140,7 +1140,7 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval
iterator = emalloc(sizeof(spl_filesystem_dir_it));
dir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);
- object->refcount += 2;;
+ Z_SET_REFCOUNT_P(object, Z_REFCOUNT_P(object) + 2);
iterator->intern.data = (void*)object;
iterator->intern.funcs = &spl_filesystem_dir_it_funcs;
iterator->current = object;
@@ -1351,7 +1351,7 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva
iterator = emalloc(sizeof(spl_filesystem_dir_it));
dir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);
- object->refcount++;
+ Z_ADDREF_P(object);
iterator->intern.data = (void*)object;
iterator->intern.funcs = &spl_filesystem_tree_it_funcs;
iterator->current = NULL;
diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c
index 9404e8e24c..27814ee543 100755
--- a/ext/spl/spl_engine.c
+++ b/ext/spl/spl_engine.c
@@ -38,8 +38,8 @@ PHPAPI void spl_instantiate(zend_class_entry *pce, zval **object, int alloc TSRM
ALLOC_ZVAL(*object);
}
object_init_ex(*object, pce);
- (*object)->refcount = 1;
- (*object)->is_ref = 1; /* check if this can be hold always */
+ Z_SET_REFCOUNT_PP(object, 1);
+ Z_SET_ISREF_PP(object); /* check if this can be hold always */
}
/* }}} */
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 5c1fe4d722..a1bb2f008c 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -392,7 +392,7 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce,
iterator = emalloc(sizeof(spl_recursive_it_iterator));
object = (spl_recursive_it_object*)zend_object_store_get_object(zobject TSRMLS_CC);
- zobject->refcount++;
+ Z_ADDREF_P(zobject);
iterator->intern.data = (void*)object;
iterator->intern.funcs = ce->iterator_funcs.funcs;
iterator->zobject = zobject;
@@ -479,7 +479,7 @@ SPL_METHOD(RecursiveIteratorIterator, __construct)
ce_iterator = Z_OBJCE_P(iterator); /* respect inheritance, don't use spl_ce_RecursiveIterator */
intern->iterators[0].iterator = ce_iterator->get_iterator(ce_iterator, iterator, 0 TSRMLS_CC);
if (inc_refcount) {
- iterator->refcount++;
+ Z_ADDREF_P(iterator);
}
intern->iterators[0].zobject = iterator;
intern->iterators[0].ce = ce_iterator;
@@ -1034,7 +1034,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) TSRMLS_CC);
if (inc_refcount) {
- zobject->refcount++;
+ Z_ADDREF_P(zobject);
}
intern->inner.zobject = zobject;
intern->inner.ce = dit_type == DIT_IteratorIterator ? ce : Z_OBJCE_P(zobject);
@@ -1125,7 +1125,7 @@ static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more T
if (!check_more || spl_dual_it_valid(intern TSRMLS_CC) == SUCCESS) {
intern->inner.iterator->funcs->get_current_data(intern->inner.iterator, &data TSRMLS_CC);
intern->current.data = *data;
- intern->current.data->refcount++;
+ Z_ADDREF_P(intern->current.data);
if (intern->inner.iterator->funcs->get_current_key) {
intern->current.key_type = intern->inner.iterator->funcs->get_current_key(intern->inner.iterator, &intern->current.str_key, &intern->current.str_key_len, &intern->current.int_key TSRMLS_CC);
} else {
@@ -2058,7 +2058,7 @@ SPL_METHOD(CachingIterator, offsetSet)
return;
}
- value->refcount++;
+ Z_ADDREF_P(value);
zend_symtable_update(HASH_OF(intern->u.caching.zcache), arKey, nKeyLength+1, &value, sizeof(value), NULL);
}
/* }}} */
@@ -2502,7 +2502,7 @@ int spl_append_it_next_iterator(spl_dual_it_object *intern TSRMLS_DC) /* {{{*/
zval **it;
intern->u.append.iterator->funcs->get_current_data(intern->u.append.iterator, &it TSRMLS_CC);
- (*it)->refcount++;
+ Z_ADDREF_PP(it);
intern->inner.zobject = *it;
intern->inner.ce = Z_OBJCE_PP(it);
intern->inner.object = zend_object_store_get_object(*it TSRMLS_CC);
@@ -2700,7 +2700,7 @@ static int spl_iterator_to_array_apply(zend_object_iterator *iter, void *puser T
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
- (*data)->refcount++;
+ Z_ADDREF_PP(data);
switch(key_type) {
case HASH_KEY_IS_STRING:
add_assoc_zval_ex(return_value, str_key, str_key_len, *data);
@@ -2711,7 +2711,7 @@ static int spl_iterator_to_array_apply(zend_object_iterator *iter, void *puser T
break;
}
} else {
- (*data)->refcount++;
+ Z_ADDREF_PP(data);
add_next_index_zval(return_value, *data);
}
return ZEND_HASH_APPLY_KEEP;
@@ -2726,7 +2726,7 @@ static int spl_iterator_to_values_apply(zend_object_iterator *iter, void *puser
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
- (*data)->refcount++;
+ Z_ADDREF_PP(data);
add_next_index_zval(return_value, *data);
return ZEND_HASH_APPLY_KEEP;
}
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 1dd4c5c859..eeaac42bb8 100755
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -138,7 +138,7 @@ void spl_object_storage_attach(spl_SplObjectStorage *intern, zval *obj TSRMLS_DC
}
#endif
- obj->refcount++;
+ Z_ADDREF_P(obj);
} /* }}} */
/* {{{ proto void SplObjectStorage::attach($obj)
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c
index 6ead6c0302..eefab54cac 100644
--- a/ext/sqlite/sqlite.c
+++ b/ext/sqlite/sqlite.c
@@ -628,7 +628,7 @@ static void php_sqlite_agg_step_function_callback(sqlite_func *func, int argc, c
if (*context_p == NULL) {
MAKE_STD_ZVAL(*context_p);
- (*context_p)->is_ref = 1;
+ Z_SET_ISREF_PP(context_p);
Z_TYPE_PP(context_p) = IS_NULL;
}
@@ -899,8 +899,8 @@ static zval * sqlite_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
}
Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, pce);
- object->refcount = 1;
- object->is_ref = 1;
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_SET_ISREF_P(object);
return object;
}
@@ -1016,7 +1016,7 @@ zend_object_iterator *sqlite_get_iterator(zend_class_entry *ce, zval *object, in
if (by_ref) {
zend_error(E_RECOVERABLE_ERROR, "An iterator cannot be used with foreach by reference");
}
- object->refcount++;
+ Z_ADDREF_P(object);
iterator->it.data = (void*)object;
iterator->it.funcs = ce->iterator_funcs.funcs;
iterator->res = obj->u.res;
@@ -1858,7 +1858,7 @@ static void php_sqlite_fetch_array(struct php_sqlite_result *res, int mode, zend
if (mode & PHPSQLITE_NUM) {
if (mode & PHPSQLITE_ASSOC) {
add_index_zval(return_value, j, decoded);
- ZVAL_ADDREF(decoded);
+ Z_ADDREF_P(decoded);
add_assoc_zval(return_value, (char*)colnames[j], decoded);
} else {
add_next_index_zval(return_value, decoded);
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 96cd0c991d..09852f23c3 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1465,10 +1465,10 @@ PHP_FUNCTION(extract)
*orig_var = *entry;
} else {
- if (var_array->refcount > 1 || *entry == EG(uninitialized_zval_ptr)) {
+ if (Z_REFCOUNT_P(var_array) > 1 || *entry == EG(uninitialized_zval_ptr)) {
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
} else {
- (*entry)->is_ref = 1;
+ Z_SET_ISREF_PP(entry);
}
zval_add_ref(entry);
zend_hash_update(EG(active_symbol_table), Z_STRVAL(final_name), Z_STRLEN(final_name) + 1, (void **) entry, sizeof(zval *), NULL);
@@ -1889,7 +1889,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,
for (pos=0, p=in_hash->pListHead; pos<offset && p ; pos++, p=p->pListNext) {
/* Get entry and increase reference count */
entry = *((zval **)p->pData);
- entry->refcount++;
+ Z_ADDREF_P(entry);
/* Update output hash depending on key type */
if (p->nKeyLength)
@@ -1902,7 +1902,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,
if (removed != NULL) {
for ( ; pos<offset+length && p; pos++, p=p->pListNext) {
entry = *((zval **)p->pData);
- entry->refcount++;
+ Z_ADDREF_P(entry);
if (p->nKeyLength)
zend_hash_quick_update(*removed, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL);
else
@@ -1916,7 +1916,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,
/* ..for each one, create a new zval, copy entry into it and copy it into the output hash */
for (i=0; i<list_count; i++) {
entry = *list[i];
- entry->refcount++;
+ Z_ADDREF_P(entry);
zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
}
}
@@ -1924,7 +1924,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,
/* Copy the remaining input hash entries to the output hash */
for ( ; p ; p=p->pListNext) {
entry = *((zval **)p->pData);
- entry->refcount++;
+ Z_ADDREF_P(entry);
if (p->nKeyLength)
zend_hash_quick_update(out_hash, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL);
else
@@ -1970,7 +1970,7 @@ PHP_FUNCTION(array_push)
/* For each subsequent argument, make it a reference, increase refcount, and add it to the end of the array */
for (i=1; i<argc; i++) {
new_var = *args[i];
- new_var->refcount++;
+ Z_ADDREF_P(new_var);
if (zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var, sizeof(zval *), NULL) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element to the array as the next element is already occupied");
@@ -2277,7 +2277,7 @@ PHP_FUNCTION(array_slice)
/* Copy elements from input array to the one that's returned */
while (pos < offset_val+length_val && zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)&entry, &hpos) == SUCCESS) {
- (*entry)->refcount++;
+ Z_ADDREF_PP(entry);
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(input), &string_key, &string_key_len, &num_key, 0, &hpos)) {
case HASH_KEY_IS_STRING:
@@ -2314,7 +2314,7 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
case HASH_KEY_IS_STRING:
if (recursive &&
zend_hash_find(dest, string_key, string_key_len, (void **)&dest_entry) == SUCCESS) {
- if (*src_entry == *dest_entry && ((*dest_entry)->refcount % 2)) {
+ if (*src_entry == *dest_entry && (Z_REFCOUNT_PP(dest_entry) % 2)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
return 0;
}
@@ -2327,7 +2327,7 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
Z_ARRVAL_PP(src_entry), recursive TSRMLS_CC))
return 0;
} else {
- (*src_entry)->refcount++;
+ Z_ADDREF_PP(src_entry);
zend_hash_update(dest, string_key, string_key_len,
src_entry, sizeof(zval *), NULL);
@@ -2335,7 +2335,7 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
break;
case HASH_KEY_IS_LONG:
- (*src_entry)->refcount++;
+ Z_ADDREF_PP(src_entry);
zend_hash_next_index_insert(dest, src_entry, sizeof(zval *), NULL);
break;
}
@@ -2504,7 +2504,7 @@ PHP_FUNCTION(array_values)
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)&entry, &pos) == SUCCESS) {
- (*entry)->refcount++;
+ Z_ADDREF_PP(entry);
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), entry,
sizeof(zval *), NULL);
@@ -2602,7 +2602,7 @@ PHP_FUNCTION(array_reverse)
zend_hash_internal_pointer_end_ex(Z_ARRVAL_PP(input), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)&entry, &pos) == SUCCESS) {
- (*entry)->refcount++;
+ Z_ADDREF_PP(entry);
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(input), &string_key, &string_key_len, &num_key, 0, &pos)) {
case HASH_KEY_IS_STRING:
@@ -2779,7 +2779,7 @@ PHP_FUNCTION(array_change_key_case)
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(array), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(array), (void **)&entry, &pos) == SUCCESS) {
- (*entry)->refcount++;
+ Z_ADDREF_PP(entry);
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(array), &string_key, &str_key_len, &num_key, 0, &pos)) {
case HASH_KEY_IS_LONG:
@@ -2991,7 +2991,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
}
}
if (ok) {
- (*((zval**)p->pData))->refcount++;
+ Z_ADDREF_PP((zval**)p->pData);
zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, p->pData, sizeof(zval*), NULL);
}
} else {
@@ -3005,7 +3005,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
}
}
if (ok) {
- (*((zval**)p->pData))->refcount++;
+ Z_ADDREF_PP((zval**)p->pData);
zend_hash_quick_update(Z_ARRVAL_P(return_value), p->arKey, p->nKeyLength, p->h, p->pData, sizeof(zval*), NULL);
}
}
@@ -3452,7 +3452,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty
}
}
if (ok) {
- (*((zval**)p->pData))->refcount++;
+ Z_ADDREF_PP((zval**)p->pData);
zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, p->pData, sizeof(zval*), NULL);
}
} else {
@@ -3466,7 +3466,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty
}
}
if (ok) {
- (*((zval**)p->pData))->refcount++;
+ Z_ADDREF_PP((zval**)p->pData);
zend_hash_quick_update(Z_ARRVAL_P(return_value), p->arKey, p->nKeyLength, p->h, p->pData, sizeof(zval*), NULL);
}
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 6119e74fb8..cf10e21cea 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -5418,7 +5418,7 @@ PHP_FUNCTION(register_shutdown_function)
}
for (i = 0; i < shutdown_function_entry.arg_count; i++) {
- shutdown_function_entry.arguments[i]->refcount++;
+ Z_ADDREF_P(shutdown_function_entry.arguments[i]);
}
zend_hash_next_index_insert(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL);
}
@@ -5994,7 +5994,7 @@ PHP_FUNCTION(register_tick_function)
}
for (i = 0; i < tick_fe.arg_count; i++) {
- tick_fe.arguments[i]->refcount++;
+ Z_ADDREF_P(tick_fe.arguments[i]);
}
zend_llist_add_element(BG(user_tick_functions), &tick_fe);
@@ -6285,7 +6285,7 @@ static int copy_request_variable(void *pDest, int num_args, va_list args, zend_h
}
zend_delete_global_variable(Z_STRVAL(new_key), Z_STRLEN(new_key) TSRMLS_CC);
- ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), Z_STRVAL(new_key), Z_STRLEN(new_key) + 1, *var, (*var)->refcount + 1, 0);
+ ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), Z_STRVAL(new_key), Z_STRLEN(new_key) + 1, *var, Z_REFCOUNT_PP(var) + 1, 0);
zval_dtor(&new_key);
return 0;
diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h
index b0aae0a76c..c8a8200d54 100644
--- a/ext/standard/php_filestat.h
+++ b/ext/standard/php_filestat.h
@@ -62,7 +62,7 @@ PHP_FUNCTION(clearstatcache);
#define MAKE_LONG_ZVAL_INCREF(name, val)\
MAKE_STD_ZVAL(name); \
ZVAL_LONG(name, val); \
- name->refcount++;
+ Z_ADDREF_P(name);
#ifdef PHP_WIN32
#define S_IRUSR S_IREAD
diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c
index b711522e4c..7f1de30189 100644
--- a/ext/standard/scanf.c
+++ b/ext/standard/scanf.c
@@ -745,11 +745,11 @@ literal:
zend_uint refcount;
current = args[objIndex++];
- refcount = (*current)->refcount;
+ refcount = Z_REFCOUNT_PP(current);
zval_dtor( *current );
ZVAL_LONG( *current, (long)(string - baseString) );
- (*current)->refcount = refcount;
- (*current)->is_ref = 1;
+ Z_SET_REFCOUNT_PP(current, refcount);
+ Z_SET_ISREF_PP(current);
} else {
add_index_long(*return_value, objIndex++, string - baseString);
}
@@ -869,11 +869,11 @@ literal:
zend_uint refcount;
current = args[objIndex++];
- refcount = (*current)->refcount;
+ refcount = Z_REFCOUNT_PP(current);
zval_dtor( *current );
ZVAL_STRINGL( *current, string, end-string, 1);
- (*current)->refcount = refcount;
- (*current)->is_ref = 1;
+ Z_SET_REFCOUNT_PP(current, refcount);
+ Z_SET_ISREF_PP(current);
} else {
add_index_stringl( *return_value, objIndex++, string, end-string, 1);
}
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 963cecc0fb..0d40a2a0cd 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -894,7 +894,7 @@ static int parse_context_params(php_stream_context *context, zval *params)
context->notifier = php_stream_notification_alloc();
context->notifier->func = user_space_stream_notifier;
context->notifier->ptr = *tmp;
- ZVAL_ADDREF(*tmp);
+ Z_ADDREF_P(*tmp);
context->notifier->dtor = user_space_stream_notifier_dtor;
}
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) {
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 45c36d5c0c..dea0753947 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -3569,7 +3569,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
php_str_replace_in_subject(*search, *replace, subject_entry, result, case_sensitivity, (argc > 3) ? &count : NULL);
} else {
ALLOC_ZVAL(result);
- ZVAL_ADDREF(*subject_entry);
+ Z_ADDREF_P(*subject_entry);
COPY_PZVAL_TO_ZVAL(*result, *subject_entry);
}
/* Add to return array */
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index ea6ed4c938..d900368550 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -335,8 +335,8 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
/* create the object */
ALLOC_ZVAL(obj);
object_init_ex(obj, fdat->ce);
- ZVAL_REFCOUNT(obj) = 1;
- PZVAL_IS_REF(obj) = 1;
+ Z_SET_REFCOUNT_P(obj, 1);
+ Z_SET_ISREF_P(obj);
/* filtername */
add_property_string(obj, "filtername", (char*)filtername, 1);
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 820c3077f1..63e57b38b0 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -35,8 +35,7 @@
#include "basic_functions.h"
#include "php_incomplete_class.h"
-#define COMMON ((*struc)->is_ref ? "&" : "")
-#define Z_REFCOUNT_PP(a) ((*a)->refcount)
+#define COMMON (Z_ISREF_PP(struc) ? "&" : "")
/* }}} */
@@ -269,7 +268,8 @@ PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC)
php_printf("%slong(%ld) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), Z_REFCOUNT_PP(struc));
break;
case IS_DOUBLE:
- php_printf("%sdouble(%.*G) refcount(%u)\n", COMMON, (int) EG(precision), Z_DVAL_PP(struc), Z_REFCOUNT_PP(struc));
+ php_printf("%sdouble(%.*G) refcount(%u)\n", COMMON, (int) EG(precision), Z_DVAL_PP(struc),
+Z_REFCOUNT_PP(struc));
break;
case IS_STRING:
php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_PP(struc));
@@ -500,7 +500,7 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old
}
if (var_old && zend_hash_find(var_hash, p, len, var_old) == SUCCESS) {
- if (!var->is_ref) {
+ if (!Z_ISREF_P(var)) {
/* we still need to bump up the counter, since non-refs will
be counted separately by unserializer */
var_no = -1;
@@ -648,7 +648,7 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
if (var_hash
&& php_add_var_hash(var_hash, struc, (void *) &var_already TSRMLS_CC) == FAILURE) {
- if(struc->is_ref) {
+ if(Z_ISREF_P(struc)) {
smart_str_appendl(buf, "R:", 2);
smart_str_append_long(buf, *var_already);
smart_str_appendc(buf, ';');
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 4802fd5a8e..11bf3a5004 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -76,7 +76,7 @@ static inline void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
prev->next = var_hash;
}
- (*rval)->refcount++;
+ Z_ADDREF_PP(rval);
var_hash->data[var_hash->used_slots++] = *rval;
}
@@ -1096,8 +1096,8 @@ yy91:
zval_ptr_dtor(rval);
}
*rval = *rval_ref;
- (*rval)->refcount++;
- (*rval)->is_ref = 0;
+ Z_ADDREF_PP(rval);
+ Z_UNSET_ISREF_PP(rval);
return 1;
}
@@ -1140,8 +1140,8 @@ yy97:
zval_ptr_dtor(rval);
}
*rval = *rval_ref;
- (*rval)->refcount++;
- (*rval)->is_ref = 1;
+ Z_ADDREF_PP(rval);
+ Z_SET_ISREF_PP(rval);
return 1;
}
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index bb8eefea01..3800c67f2f 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -74,7 +74,7 @@ static inline void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
prev->next = var_hash;
}
- (*rval)->refcount++;
+ Z_ADDREF_PP(rval);
var_hash->data[var_hash->used_slots++] = *rval;
}
@@ -418,8 +418,8 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
zval_ptr_dtor(rval);
}
*rval = *rval_ref;
- (*rval)->refcount++;
- (*rval)->is_ref = 1;
+ Z_ADDREF_PP(rval);
+ Z_SET_ISREF_PP(rval);
return 1;
}
@@ -441,8 +441,8 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
zval_ptr_dtor(rval);
}
*rval = *rval_ref;
- (*rval)->refcount++;
- (*rval)->is_ref = 0;
+ Z_ADDREF_PP(rval);
+ Z_UNSET_ISREF_PP(rval);
return 1;
}
diff --git a/ext/sybase/php_sybase_db.c b/ext/sybase/php_sybase_db.c
index 1e35a2a34a..73a1ad045c 100644
--- a/ext/sybase/php_sybase_db.c
+++ b/ext/sybase/php_sybase_db.c
@@ -1053,7 +1053,7 @@ PHP_FUNCTION(sybase_fetch_row)
array_init(return_value);
for (i=0; i<result->num_fields; i++) {
- ZVAL_ADDREF(result->data[result->cur_row][i]);
+ Z_ADDREF_P(result->data[result->cur_row][i]);
zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &result->data[result->cur_row][i], sizeof(zval *), NULL);
}
result->cur_row++;
@@ -1087,9 +1087,9 @@ static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS)
array_init(return_value);
for (i=0; i<result->num_fields; i++) {
- ZVAL_ADDREF(result->data[result->cur_row][i]);
+ Z_ADDREF_P(result->data[result->cur_row][i]);
zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &result->data[result->cur_row][i], sizeof(zval *), NULL);
- ZVAL_ADDREF(result->data[result->cur_row][i]);
+ Z_ADDREF_P(result->data[result->cur_row][i]);
zend_hash_update(Z_ARRVAL_P(return_value), result->fields[i].name, strlen(result->fields[i].name)+1, (void *) &result->data[result->cur_row][i], sizeof(zval *), NULL);
}
result->cur_row++;
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 60928a7ce0..9774638f88 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -658,8 +658,8 @@ static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, pce);
- object->refcount = 1;
- object->is_ref = 1;
+ Z_SET_REFCOUNT_P(object, 1);
+ Z_SET_ISREF_P(object);
return object;
}
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index fa5910573e..0e9270f76d 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -173,7 +173,7 @@ zval *xmlreader_read_property(zval *object, zval *member, int type TSRMLS_DC)
ret = xmlreader_property_reader(obj, hnd, &retval TSRMLS_CC);
if (ret == SUCCESS) {
/* ensure we're creating a temporary variable */
- retval->refcount = 0;
+ Z_SET_REFCOUNT_P(retval, 0);
} else {
retval = EG(uninitialized_zval_ptr);
}
diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c
index 7938fad9a1..5963044115 100644
--- a/ext/xsl/xsltprocessor.c
+++ b/ext/xsl/xsltprocessor.c
@@ -669,7 +669,7 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter)
}
ALLOC_ZVAL(new_string);
- ZVAL_ADDREF(*entry);
+ Z_ADDREF_PP(entry);
COPY_PZVAL_TO_ZVAL(*new_string, *entry);
zend_hash_update(intern->parameter, string_key, string_key_len, &new_string, sizeof(zval*), NULL);
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 69f507d379..52fdccac89 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -433,7 +433,7 @@ static zval* php_zip_read_property(zval *object, zval *member, int type TSRMLS_D
ret = php_zip_property_reader(obj, hnd, &retval, 1 TSRMLS_CC);
if (ret == SUCCESS) {
/* ensure we're creating a temporary variable */
- retval->refcount = 0;
+ Z_SET_REFCOUNT_P(retval, 0);
} else {
retval = EG(uninitialized_zval_ptr);
}
@@ -477,8 +477,8 @@ static int php_zip_has_property(zval *object, zval *member, int type TSRMLS_DC)
if (type == 2) {
retval = 1;
} else if (php_zip_property_reader(obj, hnd, &tmp, 1 TSRMLS_CC) == SUCCESS) {
- tmp->refcount = 1;
- tmp->is_ref = 0;
+ Z_SET_REFCOUNT_P(tmp, 1);
+ Z_UNSET_ISREF_P(tmp);
if (type == 1) {
retval = zend_is_true(tmp);
} else if (type == 0) {