summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/curl/curl_file.c3
-rw-r--r--ext/phar/stream.c3
-rw-r--r--ext/spl/spl_array.c10
-rw-r--r--ext/spl/spl_directory.c27
-rw-r--r--ext/spl/spl_dllist.c17
-rw-r--r--ext/spl/spl_fixedarray.c12
-rw-r--r--ext/spl/spl_heap.c15
-rw-r--r--ext/spl/spl_iterators.c65
-rw-r--r--ext/spl/spl_observer.c5
9 files changed, 109 insertions, 48 deletions
diff --git a/ext/curl/curl_file.c b/ext/curl/curl_file.c
index f2937b4f0d..89b6cb22d2 100644
--- a/ext/curl/curl_file.c
+++ b/ext/curl/curl_file.c
@@ -78,7 +78,8 @@ static void curlfile_get_property(char *name, INTERNAL_FUNCTION_PARAMETERS)
return;
}
res = zend_read_property(curl_CURLFile_class, getThis(), name, strlen(name), 1, &rv);
- RETURN_ZVAL(res, 1, 0);
+ ZVAL_DEREF(res);
+ ZVAL_COPY(return_value, res);
}
static void curlfile_set_property(char *name, INTERNAL_FUNCTION_PARAMETERS)
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index 9aa3c03a5d..13177cb917 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -226,7 +226,8 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
}
metadata = pzoption;
- ZVAL_ZVAL(&idata->internal_file->metadata, metadata, 1, 0);
+ ZVAL_DEREF(metadata);
+ ZVAL_COPY(&idata->internal_file->metadata, metadata);
idata->phar->is_modified = 1;
}
}
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index ce8a37bf36..2835876e33 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -710,7 +710,8 @@ SPL_METHOD(Array, offsetGet)
}
value = spl_array_read_dimension_ex(0, getThis(), index, BP_VAR_R, return_value);
if (value != return_value) {
- RETURN_ZVAL(value, 1, 0);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
} /* }}} */
@@ -1513,7 +1514,8 @@ SPL_METHOD(Array, current)
return;
}
}
- RETVAL_ZVAL(entry, 1, 0);
+ ZVAL_DEREF(entry);
+ ZVAL_COPY(return_value, entry);
}
/* }}} */
@@ -1630,7 +1632,9 @@ SPL_METHOD(Array, getChildren)
return;
}
if (instanceof_function(Z_OBJCE_P(entry), Z_OBJCE_P(getThis()))) {
- RETURN_ZVAL(entry, 1, 0);
+ ZVAL_OBJ(return_value, Z_OBJ_P(entry));
+ Z_ADDREF_P(return_value);
+ return;
}
}
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 34baf63334..a7d8a32563 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -786,7 +786,8 @@ SPL_METHOD(DirectoryIterator, current)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- RETURN_ZVAL(getThis(), 1, 0);
+ ZVAL_OBJ(return_value, Z_OBJ_P(getThis()));
+ Z_ADDREF_P(return_value);
}
/* }}} */
@@ -1080,7 +1081,8 @@ SPL_METHOD(FilesystemIterator, current)
spl_filesystem_object_get_file_name(intern);
spl_filesystem_object_create_type(0, intern, SPL_FS_INFO, NULL, return_value);
} else {
- RETURN_ZVAL(getThis(), 1, 0);
+ ZVAL_OBJ(return_value, Z_OBJ_P(getThis()));
+ Z_ADDREF_P(return_value);
/*RETURN_STRING(intern->u.dir.entry.d_name, 1);*/
}
}
@@ -2123,6 +2125,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, char escape, zval *return_value) /* {{{ */
{
int ret = SUCCESS;
+ zval *value;
do {
ret = spl_filesystem_file_read(intern, 1);
@@ -2139,11 +2142,10 @@ static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char deli
php_fgetcsv(intern->u.file.stream, delimiter, enclosure, escape, buf_len, buf, &intern->u.file.current_zval);
if (return_value) {
- if (Z_TYPE_P(return_value) != IS_NULL) {
- zval_ptr_dtor(return_value);
- ZVAL_NULL(return_value);
- }
- ZVAL_ZVAL(return_value, &intern->u.file.current_zval, 1, 0);
+ zval_ptr_dtor(return_value);
+ value = &intern->u.file.current_zval;
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
}
return ret;
@@ -2177,7 +2179,10 @@ static int spl_filesystem_file_read_line_ex(zval * this_ptr, spl_filesystem_obje
intern->u.file.current_line = estrndup(Z_STRVAL(retval), Z_STRLEN(retval));
intern->u.file.current_line_len = Z_STRLEN(retval);
} else {
- ZVAL_ZVAL(&intern->u.file.current_zval, &retval, 1, 0);
+ zval *value = &retval;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(&intern->u.file.current_zval, value);
}
zval_ptr_dtor(&retval);
return SUCCESS;
@@ -2438,7 +2443,11 @@ SPL_METHOD(SplFileObject, current)
if (intern->u.file.current_line && (!SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_CSV) || Z_ISUNDEF(intern->u.file.current_zval))) {
RETURN_STRINGL(intern->u.file.current_line, intern->u.file.current_line_len);
} else if (!Z_ISUNDEF(intern->u.file.current_zval)) {
- RETURN_ZVAL(&intern->u.file.current_zval, 1, 0);
+ zval *value = &intern->u.file.current_zval;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
+ return;
}
RETURN_FALSE;
} /* }}} */
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index dfdbfdab03..a0d6bf887e 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -654,7 +654,8 @@ SPL_METHOD(SplDoublyLinkedList, top)
return;
}
- RETURN_ZVAL(value, 1, 0);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
/* }}} */
@@ -677,7 +678,8 @@ SPL_METHOD(SplDoublyLinkedList, bottom)
return;
}
- RETURN_ZVAL(value, 1, 0);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
/* }}} */
@@ -795,10 +797,12 @@ SPL_METHOD(SplDoublyLinkedList, offsetGet)
element = spl_ptr_llist_offset(intern->llist, index, intern->flags & SPL_DLLIST_IT_LIFO);
if (element != NULL) {
- RETURN_ZVAL(&element->data, 1, 0);
+ zval *value = &element->data;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
} else {
zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0);
- return;
}
} /* }}} */
@@ -1117,7 +1121,10 @@ SPL_METHOD(SplDoublyLinkedList, current)
if (element == NULL || Z_ISUNDEF(element->data)) {
RETURN_NULL();
} else {
- RETURN_ZVAL(&element->data, 1, 0);
+ zval *value = &element->data;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
}
/* }}} */
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index faac492b2a..255412d89c 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -805,9 +805,11 @@ SPL_METHOD(SplFixedArray, offsetGet)
value = spl_fixedarray_object_read_dimension_helper(intern, zindex);
if (value) {
- RETURN_ZVAL(value, 1, 0);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
+ } else {
+ RETURN_NULL();
}
- RETURN_NULL();
} /* }}} */
/* {{{ proto void SplFixedArray::offsetSet(mixed $index, mixed $newval)
@@ -1001,9 +1003,11 @@ SPL_METHOD(SplFixedArray, current)
zval_ptr_dtor(&zindex);
if (value) {
- RETURN_ZVAL(value, 1, 0);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
+ } else {
+ RETURN_NULL();
}
- RETURN_NULL();
}
/* }}} */
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index f790576b70..ad520f948a 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -694,7 +694,8 @@ SPL_METHOD(SplPriorityQueue, extract)
return;
}
- RETVAL_ZVAL(value_out, 1, 0);
+ ZVAL_DEREF(value_out);
+ ZVAL_COPY(return_value, value_out);
zval_ptr_dtor(&value);
}
/* }}} */
@@ -731,7 +732,8 @@ SPL_METHOD(SplPriorityQueue, top)
return;
}
- RETURN_ZVAL(value_out, 1, 0);
+ ZVAL_DEREF(value_out);
+ ZVAL_COPY(return_value, value_out);
}
/* }}} */
@@ -844,7 +846,8 @@ SPL_METHOD(SplHeap, top)
return;
}
- RETURN_ZVAL(value, 1, 0);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
/* }}} */
@@ -1032,7 +1035,8 @@ SPL_METHOD(SplHeap, current)
if (!intern->heap->count || Z_ISUNDEF_P(element)) {
RETURN_NULL();
} else {
- RETURN_ZVAL(element, 1, 0);
+ ZVAL_DEREF(element);
+ ZVAL_COPY(return_value, element);
}
}
/* }}} */
@@ -1058,7 +1062,8 @@ SPL_METHOD(SplPriorityQueue, current)
RETURN_NULL();
}
- RETURN_ZVAL(data, 1, 0);
+ ZVAL_DEREF(data);
+ ZVAL_COPY(return_value, data);
}
}
/* }}} */
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index c27d737b51..504065e7fd 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -663,7 +663,8 @@ SPL_METHOD(RecursiveIteratorIterator, current)
data = iterator->funcs->get_current_data(iterator);
if (data) {
- RETURN_ZVAL(data, 1, 0);
+ ZVAL_DEREF(data);
+ ZVAL_COPY(return_value, data);
}
} /* }}} */
@@ -699,6 +700,7 @@ SPL_METHOD(RecursiveIteratorIterator, getSubIterator)
{
spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
zend_long level = object->level;
+ zval *value;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &level) == FAILURE) {
return;
@@ -713,7 +715,9 @@ SPL_METHOD(RecursiveIteratorIterator, getSubIterator)
return;
}
- RETURN_ZVAL(&object->iterators[level].zobject, 1, 0);
+ value = &object->iterators[level].zobject;
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
} /* }}} */
/* {{{ proto RecursiveIterator RecursiveIteratorIterator::getInnerIterator()
@@ -729,7 +733,8 @@ SPL_METHOD(RecursiveIteratorIterator, getInnerIterator)
SPL_FETCH_SUB_ELEMENT_ADDR(zobject, object, zobject);
- RETURN_ZVAL(zobject, 1, 0);
+ ZVAL_DEREF(zobject);
+ ZVAL_COPY(return_value, zobject);
} /* }}} */
/* {{{ proto RecursiveIterator RecursiveIteratorIterator::beginIteration()
@@ -1210,7 +1215,9 @@ SPL_METHOD(RecursiveTreeIterator, current)
SPL_FETCH_SUB_ITERATOR(iterator, object);
data = iterator->funcs->get_current_data(iterator);
if (data) {
- RETURN_ZVAL(data, 1, 0);
+ ZVAL_DEREF(data);
+ ZVAL_COPY(return_value, data);
+ return;
} else {
RETURN_NULL();
}
@@ -1625,7 +1632,10 @@ SPL_METHOD(dual_it, getInnerIterator)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
if (!Z_ISUNDEF(intern->inner.zobject)) {
- RETVAL_ZVAL(&intern->inner.zobject, 1, 0);
+ zval *value = &intern->inner.zobject;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
} else {
RETURN_NULL();
}
@@ -1772,9 +1782,13 @@ SPL_METHOD(dual_it, key)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
if (Z_TYPE(intern->current.key) != IS_UNDEF) {
- RETURN_ZVAL(&intern->current.key, 1, 0);
+ zval *value = &intern->current.key;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
+ } else {
+ RETURN_NULL();
}
- RETURN_NULL();
} /* }}} */
/* {{{ proto mixed FilterIterator::current()
@@ -1796,7 +1810,10 @@ SPL_METHOD(dual_it, current)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
if (Z_TYPE(intern->current.data) != IS_UNDEF) {
- RETVAL_ZVAL(&intern->current.data, 1, 0);
+ zval *value = &intern->current.data;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
} else {
RETURN_NULL();
}
@@ -2629,14 +2646,13 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern)
intern->u.caching.flags |= CIT_VALID;
/* Full cache ? */
if (intern->u.caching.flags & CIT_FULL_CACHE) {
- zval zcacheval;
zval *key = &intern->current.key;
+ zval *data = &intern->current.data;
- ZVAL_ZVAL(&zcacheval, &intern->current.data, 1, 0);
-
- array_set_zval_key(HASH_OF(&intern->u.caching.zcache), key, &zcacheval);
-
- zval_ptr_dtor(&zcacheval);
+ ZVAL_DEREF(data);
+ Z_TRY_ADDREF_P(data);
+ array_set_zval_key(HASH_OF(&intern->u.caching.zcache), key, data);
+ zval_ptr_dtor(data);
}
/* Recursion ? */
if (intern->dit_type == DIT_RecursiveCachingIterator) {
@@ -2849,7 +2865,8 @@ SPL_METHOD(CachingIterator, offsetGet)
return;
}
- RETURN_ZVAL(value, 1, 0);
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
/* }}} */
@@ -2902,6 +2919,7 @@ SPL_METHOD(CachingIterator, offsetExists)
SPL_METHOD(CachingIterator, getCache)
{
spl_dual_it_object *intern;
+ zval *value;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2914,7 +2932,9 @@ SPL_METHOD(CachingIterator, getCache)
return;
}
- RETURN_ZVAL(&intern->u.caching.zcache, 1, 0);
+ value = &intern->u.caching.zcache;
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
/* }}} */
@@ -3062,7 +3082,10 @@ SPL_METHOD(RecursiveCachingIterator, getChildren)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
if (Z_TYPE(intern->u.caching.zchildren) != IS_UNDEF) {
- RETURN_ZVAL(&intern->u.caching.zchildren, 1, 0);
+ zval *value = &intern->u.caching.zchildren;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
} else {
RETURN_NULL();
}
@@ -3166,7 +3189,8 @@ SPL_METHOD(NoRewindIterator, current)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
data = intern->inner.iterator->funcs->get_current_data(intern->inner.iterator);
if (data) {
- RETURN_ZVAL(data, 1, 0);
+ ZVAL_DEREF(data);
+ ZVAL_COPY(return_value, data);
}
} /* }}} */
@@ -3439,6 +3463,7 @@ SPL_METHOD(AppendIterator, getIteratorIndex)
SPL_METHOD(AppendIterator, getArrayIterator)
{
spl_dual_it_object *intern;
+ zval *value;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -3446,7 +3471,9 @@ SPL_METHOD(AppendIterator, getArrayIterator)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
- RETURN_ZVAL(&intern->u.append.zarrayit, 1, 0);
+ value = &intern->u.append.zarrayit;
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
} /* }}} */
ZEND_BEGIN_ARG_INFO(arginfo_append_it_append, 0)
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 2f53946ffb..5ad1c5d12f 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -485,7 +485,10 @@ SPL_METHOD(SplObjectStorage, offsetGet)
if (!element) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Object not found");
} else {
- RETURN_ZVAL(&element->inf, 1, 0);
+ zval *value = &element->inf;
+
+ ZVAL_DEREF(value);
+ ZVAL_COPY(return_value, value);
}
} /* }}} */