]> granicus.if.org Git - php/commitdiff
Avoid zval duplication in ZVAL_ZVAL() macro (it was necessary only in few places).
authorDmitry Stogov <dmitry@zend.com>
Fri, 12 Jun 2015 09:33:23 +0000 (12:33 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 12 Jun 2015 09:33:23 +0000 (12:33 +0300)
Switch from ZVAL_ZVAL() to simpler macros where possible (it makes sense to review remaining places)

18 files changed:
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_ast.c
Zend/zend_builtin_functions.c
Zend/zend_generators.c
ext/date/php_date.c
ext/intl/timezone/timezone_methods.cpp
ext/phar/phar_object.c
ext/reflection/php_reflection.c
ext/simplexml/simplexml.c
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/spl/spl_observer.c
ext/standard/array.c
ext/standard/streamsfuncs.c
ext/standard/string.c
ext/standard/type.c
ext/tokenizer/tokenizer.c

index 3a83f5f7f3a246f4a73c6b9df102ca090c1689b8..f49957a7ff836eef7baa9bc8237df7a1ed2a3962 100644 (file)
@@ -476,7 +476,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest
                                zval_dtor(arg);
                                ZVAL_NULL(arg);
                                if (!zend_make_printable_zval(z, arg)) {
-                                       ZVAL_ZVAL(arg, z, 1, 1);
+                                       ZVAL_COPY_VALUE(arg, z);
                                }
                                *dest = Z_STR_P(arg);
                                return 1;
index 7de97ff3364bf6db001f78aa1fd186298e2dd42d..b01b041859f7146d747765ef0bda593a25369887 100644 (file)
@@ -593,20 +593,17 @@ END_EXTERN_C()
                zval *__z = (z);                                                \
                zval *__zv = (zv);                                              \
                if (EXPECTED(!Z_ISREF_P(__zv))) {               \
-                       ZVAL_COPY_VALUE(__z, __zv);                     \
-               } else {                                \
-                       ZVAL_COPY_VALUE(__z,                \
-                               Z_REFVAL_P(__zv));                              \
-               }                                                                               \
-               if (copy) {                                                             \
-                       zval_opt_copy_ctor(__z);                        \
-           }                                                                           \
-               if (dtor) {                                                             \
-                       if (!copy) {                                            \
-                               ZVAL_NULL(__zv);                                \
+                       if (copy && !dtor) {                            \
+                               ZVAL_COPY(__z, __zv);                   \
+                       } else {                                                        \
+                               ZVAL_COPY_VALUE(__z, __zv);             \
+                       }                                                                       \
+               } else {                                                                \
+                       ZVAL_COPY(__z, Z_REFVAL_P(__zv));       \
+                       if (dtor || !copy) {                            \
+                               zval_ptr_dtor(__zv);                    \
                        }                                                                       \
-                       zval_ptr_dtor(__zv);                            \
-           }                                                                           \
+               }                                                                               \
        } while (0)
 
 #define RETVAL_BOOL(b)                                 ZVAL_BOOL(return_value, b)
@@ -645,18 +642,6 @@ END_EXTERN_C()
 #define RETURN_FALSE                                   { RETVAL_FALSE; return; }
 #define RETURN_TRUE                                    { RETVAL_TRUE; return; }
 
-#define RETVAL_ZVAL_FAST(z) do {      \
-       zval *_z = (z);                   \
-       if (Z_ISREF_P(_z)) {              \
-               RETVAL_ZVAL(_z, 1, 0);        \
-       } else {                          \
-               zval_ptr_dtor(return_value);  \
-               ZVAL_COPY(return_value, _z);  \
-       }                                 \
-} while (0)
-
-#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
-
 #define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL)))
 #define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL)
 
index aad9b64ffc83f4e751b8a492700fc1a3e67e9c55..fe78bfd31ba537b34f4024acac74491d09d96fc5 100644 (file)
@@ -394,7 +394,12 @@ ZEND_API int zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *sc
                                zval tmp;
 
                                zend_fetch_dimension_by_zval(&tmp, &op1, &op2);
-                               ZVAL_ZVAL(result, &tmp, 1, 1);
+                               if (UNEXPECTED(Z_ISREF(tmp))) {
+                                       ZVAL_DUP(result, Z_REFVAL(tmp));
+                               } else {
+                                       ZVAL_DUP(result, &tmp);
+                               }
+                               zval_ptr_dtor(&tmp);
                                zval_dtor(&op1);
                                zval_dtor(&op2);
                        }
index 6b65bdd33034339fb22035c058c0caa735ba9302..ac6e8f14fa0aa02c42876b387f0bf09811240f92 100644 (file)
@@ -459,7 +459,7 @@ ZEND_FUNCTION(func_get_arg)
        } else {
                arg = ZEND_CALL_ARG(ex, requested_offset + 1);
        }
-       RETURN_ZVAL_FAST(arg);
+       RETURN_ZVAL(arg, 1, 0);
 }
 /* }}} */
 
@@ -1686,7 +1686,7 @@ ZEND_FUNCTION(set_error_handler)
        }
 
        if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
-               RETVAL_ZVAL(&EG(user_error_handler), 1, 0);
+               ZVAL_COPY(return_value, &EG(user_error_handler));
 
                zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting));
                zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler));
@@ -1697,7 +1697,7 @@ ZEND_FUNCTION(set_error_handler)
                return;
        }
 
-       ZVAL_DUP(&EG(user_error_handler), error_handler);
+       ZVAL_COPY(&EG(user_error_handler), error_handler);
        EG(user_error_handler_error_reporting) = (int)error_type;
 }
 /* }}} */
@@ -1754,7 +1754,7 @@ ZEND_FUNCTION(set_exception_handler)
        }
 
        if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
-               RETVAL_ZVAL(&EG(user_exception_handler), 1, 0);
+               ZVAL_COPY(return_value, &EG(user_exception_handler));
 
                zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler));
        }
@@ -1764,7 +1764,7 @@ ZEND_FUNCTION(set_exception_handler)
                return;
        }
 
-       ZVAL_DUP(&EG(user_exception_handler), exception_handler);
+       ZVAL_COPY(&EG(user_exception_handler), exception_handler);
 }
 /* }}} */
 
index 13304e9fddbce5a5cf09d11812bf74b526f8ad2d..49ad715147eaba1618fef6ee73ff021bf30f0d99 100644 (file)
@@ -819,7 +819,7 @@ ZEND_METHOD(Generator, current)
 
        root = zend_generator_get_current(generator);
        if (Z_TYPE(root->value) != IS_UNDEF) {
-               RETURN_ZVAL_FAST(&root->value);
+               RETURN_ZVAL(&root->value, 1, 0);
        }
 }
 /* }}} */
@@ -840,7 +840,7 @@ ZEND_METHOD(Generator, key)
 
        root = zend_generator_get_current(generator);
        if (Z_TYPE(root->key) != IS_UNDEF) {
-               RETURN_ZVAL_FAST(&root->key);
+               RETURN_ZVAL(&root->key, 1, 0);
        }
 }
 /* }}} */
@@ -894,7 +894,7 @@ ZEND_METHOD(Generator, send)
 
        root = zend_generator_get_current(generator);
        if (Z_TYPE(root->value) != IS_UNDEF) {
-               RETURN_ZVAL_FAST(&root->value);
+               RETURN_ZVAL(&root->value, 1, 0);
        }
 }
 /* }}} */
@@ -925,7 +925,7 @@ ZEND_METHOD(Generator, throw)
 
                root = zend_generator_get_current(generator);
                if (Z_TYPE(root->value) != IS_UNDEF) {
-                       RETURN_ZVAL_FAST(&root->value);
+                       RETURN_ZVAL(&root->value, 1, 0);
                }
        } else {
                /* If the generator is already closed throw the exception in the
index d8d6d32862c5bc572b11d5549a25937e541e9016..441e39c4ed103085f041a84ee9027a0c45428972 100644 (file)
@@ -2573,18 +2573,16 @@ PHP_FUNCTION(date_create)
        zval           *timezone_object = NULL;
        char           *time_str = NULL;
        size_t          time_str_len = 0;
-       zval            datetime_object;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
                RETURN_FALSE;
        }
 
-       php_date_instantiate(date_ce_date, &datetime_object);
-       if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, NULL, timezone_object, 0)) {
-               zval_dtor(&datetime_object);
+       php_date_instantiate(date_ce_date, return_value);
+       if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) {
+               zval_ptr_dtor(return_value);
                RETURN_FALSE;
        }
-       RETVAL_ZVAL(&datetime_object, 0, 0);
 }
 /* }}} */
 
@@ -2596,18 +2594,16 @@ PHP_FUNCTION(date_create_immutable)
        zval           *timezone_object = NULL;
        char           *time_str = NULL;
        size_t          time_str_len = 0;
-       zval            datetime_object;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
                RETURN_FALSE;
        }
 
-       php_date_instantiate(date_ce_immutable, &datetime_object);
-       if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, NULL, timezone_object, 0)) {
-               zval_dtor(&datetime_object);
+       php_date_instantiate(date_ce_immutable, return_value);
+       if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) {
+               zval_ptr_dtor(return_value);
                RETURN_FALSE;
        }
-       RETVAL_ZVAL(&datetime_object, 0, 0);
 }
 /* }}} */
 
@@ -2619,18 +2615,16 @@ PHP_FUNCTION(date_create_from_format)
        zval           *timezone_object = NULL;
        char           *time_str = NULL, *format_str = NULL;
        size_t             time_str_len = 0, format_str_len = 0;
-       zval            datetime_object;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|O!", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
                RETURN_FALSE;
        }
 
-       php_date_instantiate(date_ce_date, &datetime_object);
-       if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, format_str, timezone_object, 0)) {
-               zval_dtor(&datetime_object);
+       php_date_instantiate(date_ce_date, return_value);
+       if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0)) {
+               zval_ptr_dtor(return_value);
                RETURN_FALSE;
        }
-       RETVAL_ZVAL(&datetime_object, 0, 0);
 }
 /* }}} */
 
@@ -2642,18 +2636,16 @@ PHP_FUNCTION(date_create_immutable_from_format)
        zval           *timezone_object = NULL;
        char           *time_str = NULL, *format_str = NULL;
        size_t          time_str_len = 0, format_str_len = 0;
-       zval            datetime_object;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|O!", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
                RETURN_FALSE;
        }
 
-       php_date_instantiate(date_ce_immutable, &datetime_object);
-       if (!php_date_initialize(Z_PHPDATE_P(&datetime_object), time_str, time_str_len, format_str, timezone_object, 0)) {
-               zval_dtor(&datetime_object);
+       php_date_instantiate(date_ce_immutable, return_value);
+       if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0)) {
+               zval_ptr_dtor(return_value);
                RETURN_FALSE;
        }
-       RETVAL_ZVAL(&datetime_object, 0, 0);
 }
 /* }}} */
 
@@ -3079,11 +3071,11 @@ PHP_FUNCTION(date_modify)
                RETURN_FALSE;
        }
 
-       if (php_date_modify(object, modify, modify_len)) {
-               RETURN_ZVAL(object, 1, 0);
+       if (!php_date_modify(object, modify, modify_len)) {
+               RETURN_FALSE;
        }
 
-       RETURN_FALSE;
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3100,11 +3092,11 @@ PHP_METHOD(DateTimeImmutable, modify)
        }
 
        date_clone_immutable(object, &new_object);
-       if (php_date_modify(&new_object, modify, modify_len)) {
-               RETURN_ZVAL(&new_object, 0, 1);
+       if (!php_date_modify(&new_object, modify, modify_len)) {
+               RETURN_FALSE;
        }
 
-       RETURN_FALSE;
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
@@ -3137,7 +3129,7 @@ PHP_FUNCTION(date_add)
 
        php_date_add(object, interval, return_value);
 
-       RETURN_ZVAL(object, 1, 0);
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3154,7 +3146,7 @@ PHP_METHOD(DateTimeImmutable, add)
        date_clone_immutable(object, &new_object);
        php_date_add(&new_object, interval, return_value);
 
-       RETURN_ZVAL(&new_object, 0, 1);
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
@@ -3192,7 +3184,7 @@ PHP_FUNCTION(date_sub)
 
        php_date_sub(object, interval, return_value);
 
-       RETURN_ZVAL(object, 1, 0);
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3209,7 +3201,7 @@ PHP_METHOD(DateTimeImmutable, sub)
        date_clone_immutable(object, &new_object);
        php_date_sub(&new_object, interval, return_value);
 
-       RETURN_ZVAL(&new_object, 0, 1);
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
@@ -3294,7 +3286,7 @@ PHP_FUNCTION(date_timezone_set)
 
        php_date_timezone_set(object, timezone_object, return_value);
 
-       RETURN_ZVAL(object, 1, 0);
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3312,7 +3304,7 @@ PHP_METHOD(DateTimeImmutable, setTimezone)
        date_clone_immutable(object, &new_object);
        php_date_timezone_set(&new_object, timezone_object, return_value);
 
-       RETURN_ZVAL(&new_object, 0, 1);
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
@@ -3377,7 +3369,7 @@ PHP_FUNCTION(date_time_set)
 
        php_date_time_set(object, h, i, s, return_value);
 
-       RETURN_ZVAL(object, 1, 0);
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3395,7 +3387,7 @@ PHP_METHOD(DateTimeImmutable, setTime)
        date_clone_immutable(object, &new_object);
        php_date_time_set(&new_object, h, i, s, return_value);
 
-       RETURN_ZVAL(&new_object, 0, 1);
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
@@ -3425,7 +3417,7 @@ PHP_FUNCTION(date_date_set)
 
        php_date_date_set(object, y, m, d, return_value);
 
-       RETURN_ZVAL(object, 1, 0);
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3443,7 +3435,7 @@ PHP_METHOD(DateTimeImmutable, setDate)
        date_clone_immutable(object, &new_object);
        php_date_date_set(&new_object, y, m, d, return_value);
 
-       RETURN_ZVAL(&new_object, 0, 1);
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
@@ -3477,7 +3469,7 @@ PHP_FUNCTION(date_isodate_set)
 
        php_date_isodate_set(object, y, w, d, return_value);
 
-       RETURN_ZVAL(object, 1, 0);
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3495,7 +3487,7 @@ PHP_METHOD(DateTimeImmutable, setISODate)
        date_clone_immutable(object, &new_object);
        php_date_isodate_set(&new_object, y, w, d, return_value);
 
-       RETURN_ZVAL(&new_object, 0, 1);
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
@@ -3523,7 +3515,7 @@ PHP_FUNCTION(date_timestamp_set)
 
        php_date_timestamp_set(object, timestamp, return_value);
 
-       RETURN_ZVAL(object, 1, 0);
+       ZVAL_COPY(return_value, object);
 }
 /* }}} */
 
@@ -3541,7 +3533,7 @@ PHP_METHOD(DateTimeImmutable, setTimestamp)
        date_clone_immutable(object, &new_object);
        php_date_timestamp_set(&new_object, timestamp, return_value);
 
-       RETURN_ZVAL(&new_object, 0, 1);
+       ZVAL_COPY_VALUE(return_value, &new_object);
 }
 /* }}} */
 
index 641727d7ed0602e40b26d85c5e281113fd948eb3..728f9bde8b81abbc1d73dfbaad9762d6fa9a4f10 100644 (file)
@@ -614,7 +614,7 @@ U_CFUNC PHP_FUNCTION(intltz_to_date_time_zone)
                &TIMEZONE_ERROR(to), "intltz_to_date_time_zone", &tmp);
 
        if (ret) {
-               RETURN_ZVAL(ret, 1, 1);
+               ZVAL_COPY_VALUE(return_value, ret);
        } else {
                RETURN_FALSE;
        }
index 8ef5b0f7ed1a2a043d15ff133e05fe33bd6159e6..acb9702872ba031314c306b326860033f83b7d1a 100644 (file)
@@ -4005,7 +4005,7 @@ PHP_METHOD(Phar, setMetadata)
                ZVAL_UNDEF(&phar_obj->archive->metadata);
        }
 
-       ZVAL_ZVAL(&phar_obj->archive->metadata, metadata, 1, 0);
+       ZVAL_COPY(&phar_obj->archive->metadata, metadata);
        phar_obj->archive->is_modified = 1;
        phar_flush(phar_obj->archive, 0, 0, 0, &error);
 
@@ -4674,7 +4674,7 @@ PHP_METHOD(PharFileInfo, setMetadata)
                ZVAL_UNDEF(&entry_obj->entry->metadata);
        }
 
-       ZVAL_ZVAL(&entry_obj->entry->metadata, metadata, 1, 0);
+       ZVAL_COPY(&entry_obj->entry->metadata, metadata);
 
        entry_obj->entry->is_modified = 1;
        entry_obj->entry->phar->is_modified = 1;
index d2ccfe4442e841c8cc2a238185b26033e6b1a630..bdb388c5708a07504cebd0149643f5e648c8e030 100644 (file)
@@ -1720,7 +1720,7 @@ ZEND_METHOD(reflection_function, getClosureThis)
        if (!Z_ISUNDEF(intern->obj)) {
                closure_this = zend_get_closure_this_ptr(&intern->obj);
                if (!Z_ISUNDEF_P(closure_this)) {
-                       RETURN_ZVAL(closure_this, 1, 0);
+                       ZVAL_COPY(return_value, closure_this);
                }
        }
 }
@@ -3153,7 +3153,7 @@ ZEND_METHOD(reflection_method, getClosure)
                if (Z_OBJCE_P(obj) == zend_ce_closure &&
                        (mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))
                {
-                       RETURN_ZVAL(obj, 1, 0);
+                       ZVAL_COPY(return_value, obj);
                } else {
                        zend_create_closure(return_value, mptr, mptr->common.scope, Z_OBJCE_P(obj), obj);
                }
index 2d9e6fd3398aa34fca490fd6918849bdaa33bfe5..9beb946aea1a5c14c3e504be672ac178095bd595 100644 (file)
@@ -1930,12 +1930,8 @@ static int sxe_object_cast(zval *readobj, zval *writeobj, int type)
    Returns the string content */
 SXE_METHOD(__toString)
 {
-       zval           result;
-
-       if (sxe_object_cast_ex(getThis(), &result, IS_STRING) == SUCCESS) {
-               RETURN_ZVAL(&result, 0, 0);
-       } else {
-               zval_ptr_dtor(&result);
+       if (sxe_object_cast_ex(getThis(), return_value, IS_STRING) != SUCCESS) {
+               zval_ptr_dtor(return_value);
                RETURN_EMPTY_STRING();
        }
 }
@@ -1979,9 +1975,9 @@ static int sxe_count_elements(zval *object, zend_long *count) /* {{{ */
                        if (!Z_ISUNDEF(intern->tmp)) {
                                zval_ptr_dtor(&intern->tmp);
                        }
-                       ZVAL_ZVAL(&intern->tmp, &rv, 0, 0);
-                       convert_to_long(&intern->tmp);
-                       *count = (zend_long)Z_LVAL(intern->tmp);
+                       ZVAL_LONG(&intern->tmp, zval_get_long(&rv));
+                       zval_ptr_dtor(&rv);
+                       *count = Z_LVAL(intern->tmp);
                        return SUCCESS;
                }
                return FAILURE;
index dbf34f1939ce4f357571d750726e52061531b307..3fed81949a4aedc68debdf3f139cac627e529b3a 100644 (file)
@@ -1854,8 +1854,8 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type)
                                zval *retval_ptr = &retval;
 
                                ZVAL_STRINGL(retval_ptr, intern->file_name, intern->file_name_len);
-                               zval_dtor(readobj);
-                               ZVAL_ZVAL(writeobj, retval_ptr, 0, 0);
+                               zval_ptr_dtor(readobj);
+                               ZVAL_COPY_VALUE(writeobj, retval_ptr);
                        } else {
                                ZVAL_STRINGL(writeobj, intern->file_name, intern->file_name_len);
                        }
@@ -1866,8 +1866,8 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type)
                                zval *retval_ptr = &retval;
 
                                ZVAL_STRING(retval_ptr, intern->u.dir.entry.d_name);
-                               zval_dtor(readobj);
-                               ZVAL_ZVAL(writeobj, retval_ptr, 0, 0);
+                               zval_ptr_dtor(readobj);
+                               ZVAL_COPY_VALUE(writeobj, retval_ptr);
                        } else {
                                ZVAL_STRING(writeobj, intern->u.dir.entry.d_name);
                        }
@@ -1878,7 +1878,7 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type)
                return SUCCESS;
        }
        if (readobj == writeobj) {
-               zval_dtor(readobj);
+               zval_ptr_dtor(readobj);
        }
        ZVAL_NULL(writeobj);
        return FAILURE;
@@ -2140,7 +2140,7 @@ 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_dtor(return_value);
+                               zval_ptr_dtor(return_value);
                                ZVAL_NULL(return_value);
                        }
                        ZVAL_ZVAL(return_value, &intern->u.file.current_zval, 1, 0);
index 8f77d7088e76f2dfd9407b308605041c2aff81ca..aa0854ab78f77e95aed368c5ed656a336fb3885d 100644 (file)
@@ -494,7 +494,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
                                }
 
                                if (user_caching_it_flags) {
-                                       ZVAL_ZVAL(&caching_it_flags, user_caching_it_flags, 1, 0);
+                                       ZVAL_COPY(&caching_it_flags, user_caching_it_flags);
                                } else {
                                        ZVAL_LONG(&caching_it_flags, CIT_CATCH_GET_CHILD);
                                }
@@ -1067,10 +1067,10 @@ static void spl_recursive_tree_iterator_get_entry(spl_recursive_it_object *objec
        if (data) {
                RETVAL_ZVAL(data, 1, 0);
                if (Z_TYPE_P(return_value) == IS_ARRAY) {
-                       zval_dtor(return_value);
+                       zval_ptr_dtor(return_value);
                        ZVAL_STRINGL(return_value, "Array", sizeof("Array")-1);
                } else {
-                       convert_to_string(return_value);
+                       convert_to_string_ex(return_value);
                }
        }
        zend_restore_error_handling(&error_handling);
@@ -1268,9 +1268,7 @@ SPL_METHOD(RecursiveTreeIterator, key)
        }
 
        if (object->flags & RTIT_BYPASS_KEY) {
-               zval *key_ptr = &key;
-               RETVAL_ZVAL(key_ptr, 1, 0);
-               zval_dtor(&key);
+               RETVAL_ZVAL(&key, 1, 1);
                return;
        }
 
@@ -2089,7 +2087,7 @@ SPL_METHOD(RegexIterator, accept)
                        }
 
                        if (replacement == &tmp_replacement) {
-                               zval_dtor(replacement);
+                               zval_ptr_dtor(replacement);
                        }
                        RETVAL_BOOL(count > 0);
        }
@@ -3528,7 +3526,7 @@ static int spl_iterator_to_array_apply(zend_object_iterator *iter, void *puser)
                        return ZEND_HASH_APPLY_STOP;
                }
                array_set_zval_key(Z_ARRVAL_P(return_value), &key, data);
-               zval_dtor(&key);
+               zval_ptr_dtor(&key);
        } else {
                Z_TRY_ADDREF_P(data);
                add_next_index_zval(return_value, data);
@@ -3570,7 +3568,7 @@ PHP_FUNCTION(iterator_to_array)
        array_init(return_value);
 
        if (spl_iterator_apply(obj, use_keys ? spl_iterator_to_array_apply : spl_iterator_to_values_apply, (void*)return_value) != SUCCESS) {
-               zval_dtor(return_value);
+               zval_ptr_dtor(return_value);
                RETURN_NULL();
        }
 } /* }}} */
index ddff20ea4fe2ef3f2f22f2924336d0162f6523db..e2a55735a32e80337499acc5a737ba3c171e4d36 100644 (file)
@@ -657,7 +657,7 @@ SPL_METHOD(SplObjectStorage, current)
        if ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) == NULL) {
                return;
        }
-       RETVAL_ZVAL(&element->obj, 1, 0);
+       ZVAL_COPY(return_value, &element->obj);
 } /* }}} */
 
 /* {{{ proto mixed SplObjectStorage::getInfo()
@@ -674,7 +674,7 @@ SPL_METHOD(SplObjectStorage, getInfo)
        if ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) == NULL) {
                return;
        }
-       RETVAL_ZVAL(&element->inf, 1, 0);
+       ZVAL_COPY(return_value, &element->inf);
 } /* }}} */
 
 /* {{{ proto mixed SplObjectStorage::setInfo(mixed $inf)
@@ -693,7 +693,7 @@ SPL_METHOD(SplObjectStorage, setInfo)
                return;
        }
        zval_ptr_dtor(&element->inf);
-       ZVAL_ZVAL(&element->inf, inf, 1, 0);
+       ZVAL_COPY(&element->inf, inf);
 } /* }}} */
 
 /* {{{ proto void SplObjectStorage::next()
index ca72adfaebee73ff677e5f3eaaacec33d4b21001..b93efe791994f2eb203af4eb749eeea10fcc5de6 100644 (file)
@@ -821,7 +821,7 @@ PHP_FUNCTION(end)
                        entry = Z_INDIRECT_P(entry);
                }
 
-               RETURN_ZVAL_FAST(entry);
+               RETURN_ZVAL(entry, 1, 0);
        }
 }
 /* }}} */
@@ -854,7 +854,7 @@ PHP_FUNCTION(prev)
                        entry = Z_INDIRECT_P(entry);
                }
 
-               RETURN_ZVAL_FAST(entry);
+               RETURN_ZVAL(entry, 1, 0);
        }
 }
 /* }}} */
@@ -887,7 +887,7 @@ PHP_FUNCTION(next)
                        entry = Z_INDIRECT_P(entry);
                }
 
-               RETURN_ZVAL_FAST(entry);
+               RETURN_ZVAL(entry, 1, 0);
        }
 }
 /* }}} */
@@ -920,7 +920,7 @@ PHP_FUNCTION(reset)
                        entry = Z_INDIRECT_P(entry);
                }
 
-               RETURN_ZVAL_FAST(entry);
+               RETURN_ZVAL(entry, 1, 0);
        }
 }
 /* }}} */
@@ -950,7 +950,7 @@ PHP_FUNCTION(current)
                entry = Z_INDIRECT_P(entry);
        }
 
-       RETURN_ZVAL_FAST(entry);
+       RETURN_ZVAL(entry, 1, 0);
 }
 /* }}} */
 
@@ -996,7 +996,7 @@ PHP_FUNCTION(min)
                        RETVAL_NULL();
                } else {
                        if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 0)) != NULL) {
-                               RETVAL_ZVAL_FAST(result);
+                               RETVAL_ZVAL(result, 1, 0);
                        } else {
                                php_error_docref(NULL, E_WARNING, "Array must contain at least one element");
                                RETVAL_FALSE;
@@ -1016,7 +1016,7 @@ PHP_FUNCTION(min)
                        }
                }
 
-               RETVAL_ZVAL_FAST(min);
+               RETVAL_ZVAL(min, 1, 0);
        }
 }
 /* }}} */
@@ -1043,7 +1043,7 @@ PHP_FUNCTION(max)
                        RETVAL_NULL();
                } else {
                        if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 1)) != NULL) {
-                               RETVAL_ZVAL_FAST(result);
+                               RETVAL_ZVAL(result, 1, 0);
                        } else {
                                php_error_docref(NULL, E_WARNING, "Array must contain at least one element");
                                RETVAL_FALSE;
@@ -1063,7 +1063,7 @@ PHP_FUNCTION(max)
                        }
                }
 
-               RETVAL_ZVAL_FAST(max);
+               RETVAL_ZVAL(max, 1, 0);
        }
 }
 /* }}} */
@@ -4701,7 +4701,8 @@ PHP_FUNCTION(array_reduce)
        htbl = Z_ARRVAL_P(input);
 
        if (zend_hash_num_elements(htbl) == 0) {
-               RETURN_ZVAL(&result, 1, 1);
+               ZVAL_COPY_VALUE(return_value, &result);
+               return;
        }
 
        fci.retval = &retval;
@@ -4856,7 +4857,7 @@ PHP_FUNCTION(array_map)
 
                /* Short-circuit: if no callback and only one array, just return it. */
                if (!ZEND_FCI_INITIALIZED(fci)) {
-                       RETVAL_ZVAL(&arrays[0], 1, 0);
+                       ZVAL_COPY(return_value, &arrays[0]);
                        return;
                }
 
index 965bd67071453ac1e5a36aa68f3eab99b0bb7e2a..9973f0334aa2fd6a74275a37fd92c46b03d29f6d 100644 (file)
@@ -1038,8 +1038,8 @@ PHP_FUNCTION(stream_context_get_params)
                add_assoc_zval_ex(return_value, "notification", sizeof("notification")-1, &context->notifier->ptr);
                if (Z_REFCOUNTED(context->notifier->ptr)) Z_ADDREF(context->notifier->ptr);
        }
-       ZVAL_ZVAL(&options, &context->options, 1, 0);
-       add_assoc_zval_ex(return_value, "options", sizeof("options")-1, &options);
+       if (Z_REFCOUNTED(context->options)) Z_ADDREF(context->options);
+       add_assoc_zval_ex(return_value, "options", sizeof("options")-1, &context->options);
 }
 /* }}} */
 
index 8d95290ca28b8cd82fb0295b1298d4e09ac11ae7..bc024a13cd8899f8846f6caa2956c49a28b5611e 100644 (file)
@@ -1735,7 +1735,7 @@ PHP_FUNCTION(pathinfo)
        }
 
        if (opt == PHP_PATHINFO_ALL) {
-               RETURN_ZVAL(&tmp, 0, 1);
+               ZVAL_COPY_VALUE(return_value, &tmp);
        } else {
                zval *element;
                if ((element = zend_hash_get_current_data(Z_ARRVAL(tmp))) != NULL) {
@@ -1743,9 +1743,8 @@ PHP_FUNCTION(pathinfo)
                } else {
                        ZVAL_EMPTY_STRING(return_value);
                }
+               zval_ptr_dtor(&tmp);
        }
-
-       zval_ptr_dtor(&tmp);
 }
 /* }}} */
 
index fdf0febe7af69f3c6c3e2fbbf21fd761cc67ec99..8251a3f1553345821d8ffd98889349d2876fa41a 100644 (file)
@@ -154,7 +154,7 @@ PHP_FUNCTION(intval)
        ZEND_PARSE_PARAMETERS_END();
 #endif
 
-       RETVAL_ZVAL(num, 1, 0);
+       ZVAL_DUP(return_value, num);
        convert_to_long_base(return_value, (int)base);
 }
 /* }}} */
@@ -169,8 +169,7 @@ PHP_FUNCTION(floatval)
                return;
        }
 
-       RETVAL_ZVAL(num, 1, 0);
-       convert_to_double(return_value);
+       RETURN_DOUBLE(zval_get_double(num));
 }
 /* }}} */
 
index 2a4fa90ca27984931eb149eaafab381750cab627..63405ea6cd2ea7e6932d5aab2a4db4ae9a3d61bf 100644 (file)
@@ -257,9 +257,10 @@ static zend_bool tokenize_parse(zval *return_value, zend_string *source)
 
                array_init(&token_stream);
                if((success = (zendparse() == SUCCESS))) {
-                       ZVAL_ZVAL(return_value, &token_stream, 1, 0);
+                       ZVAL_COPY_VALUE(return_value, &token_stream);
+               } else {
+                       zval_ptr_dtor(&token_stream);
                }
-               zval_dtor(&token_stream);
 
                zend_ast_destroy(CG(ast));
                zend_arena_destroy(CG(ast_arena));