]> granicus.if.org Git - php/commitdiff
Use specialized macro for string zval creation
authorDmitry Stogov <dmitry@zend.com>
Thu, 12 Mar 2015 13:53:51 +0000 (16:53 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 12 Mar 2015 13:53:51 +0000 (16:53 +0300)
32 files changed:
Zend/zend_API.h
Zend/zend_builtin_functions.c
Zend/zend_vm_def.h
ext/bz2/bz2.c
ext/curl/interface.c
ext/curl/multi.c
ext/date/php_date.c
ext/gmp/gmp.c
ext/hash/hash.c
ext/iconv/iconv.c
ext/intl/locale/locale_methods.c
ext/mysqli/mysqli_api.c
ext/opcache/ZendAccelerator.c
ext/openssl/openssl.c
ext/pcre/php_pcre.c
ext/pgsql/pgsql.c
ext/reflection/php_reflection.c
ext/session/session.c
ext/shmop/shmop.c
ext/soap/soap.c
ext/sockets/sockets.c
ext/spl/spl_array.c
ext/spl/spl_dllist.c
ext/spl/spl_iterators.c
ext/spl/spl_observer.c
ext/standard/array.c
ext/standard/http.c
ext/standard/string.c
ext/standard/var.c
ext/wddx/wddx.c
ext/xsl/xsltprocessor.c
ext/zip/php_zip.c

index 39ea3016f267d09a64315f0c72897af75fc75642..41ef47e4ffe99f78bf925a87f2532f55a4b0a443 100644 (file)
@@ -610,8 +610,9 @@ END_EXTERN_C()
 #define RETVAL_LONG(l)                                         ZVAL_LONG(return_value, l)
 #define RETVAL_DOUBLE(d)                               ZVAL_DOUBLE(return_value, d)
 #define RETVAL_STR(s)                                  ZVAL_STR(return_value, s)
-#define RETVAL_LONG_STR(s)                             ZVAL_INTERNED_STR(return_value, s)
+#define RETVAL_INTERNED_STR(s)                 ZVAL_INTERNED_STR(return_value, s)
 #define RETVAL_NEW_STR(s)                              ZVAL_NEW_STR(return_value, s)
+#define RETVAL_STR_COPY(s)                             ZVAL_STR_COPY(return_value, s)
 #define RETVAL_STRING(s)                               ZVAL_STRING(return_value, s)
 #define RETVAL_STRINGL(s, l)                   ZVAL_STRINGL(return_value, s, l)
 #define RETVAL_EMPTY_STRING()                  ZVAL_EMPTY_STRING(return_value)
@@ -626,8 +627,9 @@ END_EXTERN_C()
 #define RETURN_LONG(l)                                         { RETVAL_LONG(l); return; }
 #define RETURN_DOUBLE(d)                               { RETVAL_DOUBLE(d); return; }
 #define RETURN_STR(s)                                  { RETVAL_STR(s); return; }
-#define RETURN_LONG_STR(s)                             { RETVAL_LONG_STR(s); return; }
+#define RETURN_INTERNED_STR(s)                 { RETVAL_INTERNED_STR(s); return; }
 #define RETURN_NEW_STR(s)                              { RETVAL_NEW_STR(s); return; }
+#define RETURN_STR_COPY(s)                             { RETVAL_STR_COPY(s); return; }
 #define RETURN_STRING(s)                               { RETVAL_STRING(s); return; }
 #define RETURN_STRINGL(s, l)                   { RETVAL_STRINGL(s, l); return; }
 #define RETURN_EMPTY_STRING()                  { RETVAL_EMPTY_STRING(); return; }
index 195d9c2509f59c06c9dbf40c2898e2e33f1c9a37..a620e45a658b213860d122a7eae601f32817c4b8 100644 (file)
@@ -900,14 +900,14 @@ ZEND_FUNCTION(get_class)
 
        if (!obj) {
                if (EG(scope)) {
-                       RETURN_STR(zend_string_copy(EG(scope)->name));
+                       RETURN_STR_COPY(EG(scope)->name);
                } else {
                        zend_error(E_WARNING, "get_class() called without object from outside a class");
                        RETURN_FALSE;
                }
        }
 
-       RETURN_STR(zend_string_copy(Z_OBJCE_P(obj)->name));
+       RETURN_STR_COPY(Z_OBJCE_P(obj)->name);
 }
 /* }}} */
 
@@ -920,7 +920,7 @@ ZEND_FUNCTION(get_called_class)
        }
 
        if (EX(called_scope)) {
-               RETURN_STR(zend_string_copy(EX(called_scope)->name));
+               RETURN_STR_COPY(EX(called_scope)->name);
        } else if (!EG(scope))  {
                zend_error(E_WARNING, "get_called_class() called from outside a class");
        }
@@ -942,7 +942,7 @@ ZEND_FUNCTION(get_parent_class)
        if (!ZEND_NUM_ARGS()) {
                ce = EG(scope);
                if (ce && ce->parent) {
-                       RETURN_STR(zend_string_copy(ce->parent->name));
+                       RETURN_STR_COPY(ce->parent->name);
                } else {
                        RETURN_FALSE;
                }
@@ -955,7 +955,7 @@ ZEND_FUNCTION(get_parent_class)
        }
 
        if (ce && ce->parent) {
-               RETURN_STR(zend_string_copy(ce->parent->name));
+               RETURN_STR_COPY(ce->parent->name);
        } else {
                RETURN_FALSE;
        }
@@ -1950,7 +1950,7 @@ ZEND_FUNCTION(create_function)
                do {
                        function_name->len = snprintf(function_name->val + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count)) + 1;
                } while (zend_hash_add_ptr(EG(function_table), function_name, func) == NULL);
-               RETURN_STR(function_name);
+               RETURN_NEW_STR(function_name);
        } else {
                zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
                RETURN_FALSE;
index 9714cf7ad3c534eb2731783a9d2ad59bccf0a57d..ffb737d2a2d00d305bbf42c609b52cb50b51309d 100644 (file)
@@ -4369,7 +4369,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
                        if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
                                char *actual = (char *)zend_memrchr(Z_STRVAL_P(EX_CONSTANT(opline->op2)), '\\', Z_STRLEN_P(EX_CONSTANT(opline->op2)));
                                if (!actual) {
-                                       ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(EX_CONSTANT(opline->op2))));
+                                       ZVAL_STR_COPY(EX_VAR(opline->result.var), Z_STR_P(EX_CONSTANT(opline->op2)));
                                } else {
                                        actual++;
                                        ZVAL_STRINGL(EX_VAR(opline->result.var),
index e4b283e78a1350a921c41a967188a30d3c9dcb15..52810719cc4df15a4f1fee55bb6d84a495126696 100644 (file)
@@ -379,7 +379,7 @@ static PHP_FUNCTION(bzread)
        data->len = php_stream_read(stream, data->val, data->len);
        data->val[data->len] = '\0';
 
-       RETURN_STR(data);
+       RETURN_NEW_STR(data);
 }
 /* }}} */
 
@@ -545,7 +545,7 @@ static PHP_FUNCTION(bzcompress)
                   so we erealloc() the buffer to the proper size */
                dest->len = dest_len;
                dest->val[dest->len] = '\0';
-               RETURN_STR(dest);
+               RETURN_NEW_STR(dest);
        }
 }
 /* }}} */
index 650bc158eb35a4573c3f07dc8e7a8bba31887628..e7f378c8a9a66e2ce18186ec010e1bf1b2b7bd25 100644 (file)
@@ -2862,7 +2862,7 @@ PHP_FUNCTION(curl_exec)
 
        if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.s) {
                smart_str_0(&ch->handlers->write->buf);
-               RETURN_STR(zend_string_copy(ch->handlers->write->buf.s));
+               RETURN_STR_COPY(ch->handlers->write->buf.s);
        }
 
        /* flush the file handle, so any remaining data is synched to disk */
@@ -3009,7 +3009,7 @@ PHP_FUNCTION(curl_getinfo)
                switch (option) {
                        case CURLINFO_HEADER_OUT:
                                if (ch->header.str) {
-                                       RETURN_STR(zend_string_copy(ch->header.str));
+                                       RETURN_STR_COPY(ch->header.str);
                                } else {
                                        RETURN_FALSE;
                                }
index 0cd4ae2761ca08004caac5f08340042c35739adf..240580cbcd7c819543e3a7485364939e0b6b8756 100644 (file)
@@ -264,7 +264,7 @@ PHP_FUNCTION(curl_multi_getcontent)
                        RETURN_EMPTY_STRING();
                }
                smart_str_0(&ch->handlers->write->buf);
-               RETURN_STR(zend_string_copy(ch->handlers->write->buf.s));
+               RETURN_STR_COPY(ch->handlers->write->buf.s);
        }
 
        RETURN_NULL();
index ffdea3d0909d7351a801d633305e5c85e3438dbf..1946dacda162223cd257e11c8675bbc623f3a2ed 100644 (file)
@@ -1681,7 +1681,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
 
        if (real_len && real_len != buf_len) {
                buf = zend_string_realloc(buf, real_len, 0);
-               RETURN_STR(buf);
+               RETURN_NEW_STR(buf);
        }
        zend_string_free(buf);
        RETURN_FALSE;
@@ -3742,7 +3742,7 @@ PHP_FUNCTION(timezone_name_get)
                                abs(utc_offset / 60),
                                abs((utc_offset % 60)));
 
-                       RETURN_STR(tmpstr);
+                       RETURN_NEW_STR(tmpstr);
                        }
                        break;
                case TIMELIB_ZONETYPE_ABBR:
@@ -4681,7 +4681,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
        switch (retformat) {
                case SUNFUNCS_RET_STRING:
                        retstr = strpprintf(0, "%02d:%02d", (int) N, (int) (60 * (N - (int) N)));
-                       RETURN_STR(retstr);
+                       RETURN_NEW_STR(retstr);
                        break;
                case SUNFUNCS_RET_DOUBLE:
                        RETURN_DOUBLE(N);
index 4d8e4c9bc64dd8a9fb32dc96b21c6a4079255316..45b86b2932f7b6c9c3045b9f328928d204764e9a 100644 (file)
@@ -1149,7 +1149,7 @@ ZEND_FUNCTION(gmp_export)
                mpz_export(out_string->val, NULL, order, size, endian, 0, gmpnumber);
                out_string->val[out_len] = '\0';
 
-               RETURN_STR(out_string);
+               RETURN_NEW_STR(out_string);
        }
 
        FREE_GMP_TEMP(temp_a);
index 4c4f96fc8975707741e0c1674d8af132cfe182fb..40563708e75bda798afda3d759bcc94f7f7208c4 100644 (file)
@@ -167,14 +167,14 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
 
        if (raw_output) {
                digest->val[ops->digest_size] = 0;
-               RETURN_STR(digest);
+               RETURN_NEW_STR(digest);
        } else {
                zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0);
 
                php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, ops->digest_size);
                hex_digest->val[2 * ops->digest_size] = 0;
                zend_string_release(digest);
-               RETURN_STR(hex_digest);
+               RETURN_NEW_STR(hex_digest);
        }
 }
 /* }}} */
@@ -293,14 +293,14 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
 
        if (raw_output) {
                digest->val[ops->digest_size] = 0;
-               RETURN_STR(digest);
+               RETURN_NEW_STR(digest);
        } else {
                zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0);
 
                php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, ops->digest_size);
                hex_digest->val[2 * ops->digest_size] = 0;
                zend_string_release(digest);
-               RETURN_STR(hex_digest);
+               RETURN_NEW_STR(hex_digest);
        }
 }
 /* }}} */
@@ -542,14 +542,14 @@ PHP_FUNCTION(hash_final)
        zend_list_close(Z_RES_P(zhash));
 
        if (raw_output) {
-               RETURN_STR(digest);
+               RETURN_NEW_STR(digest);
        } else {
                zend_string *hex_digest = zend_string_safe_alloc(digest_len, 2, 0, 0);
 
                php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, digest_len);
                hex_digest->val[2 * digest_len] = 0;
                zend_string_release(digest);
-               RETURN_STR(hex_digest);
+               RETURN_NEW_STR(hex_digest);
        }
 }
 /* }}} */
@@ -727,7 +727,7 @@ PHP_FUNCTION(hash_pbkdf2)
        }
        returnval->val[length] = 0;
        efree(result);
-       RETURN_STR(returnval);
+       RETURN_NEW_STR(returnval);
 }
 /* }}} */
 
index e723f6e2eb60b3e16b6be31844029f72da990d9a..81dfd5113604672620ca713e8369195e52c129a5 100644 (file)
@@ -2080,7 +2080,7 @@ PHP_FUNCTION(iconv_substr)
        _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset);
 
        if (err == PHP_ICONV_ERR_SUCCESS && str->val[0] != '\0' && retval.s != NULL) {
-               RETURN_STR(retval.s);
+               RETURN_NEW_STR(retval.s);
        }
        smart_str_free(&retval);
        RETURN_FALSE;
index 994cf5e96a5ebcc363388aa72c76153b3a597ce2..1c5e95bf5f93bc7212e720b36978e8bd82abba82 100644 (file)
@@ -898,7 +898,7 @@ static int handleAppendResult( int result, smart_str* loc_name)
 }
 /* }}} */
 
-#define RETURN_SMART_STR(str) smart_str_0((str)); RETURN_STR((str)->s)
+#define RETURN_SMART_STR(str) smart_str_0((str)); RETURN_NEW_STR((str)->s)
 /* {{{ proto static string Locale::composeLocale($array)
 * Creates a locale by combining the parts of locale-ID passed
 * }}} */
index 9f6d8220ce64cef1fd46fc700ef014234a7bd2ad..eec5e74acb8fcc305c58eb73348542966a765ca2 100644 (file)
@@ -1990,7 +1990,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
        newstr->len = mysql_real_escape_string(mysql->mysql, newstr->val, escapestr, escapestr_len);
        newstr = zend_string_realloc(newstr, newstr->len, 0);
 
-       RETURN_STR(newstr);
+       RETURN_NEW_STR(newstr);
 }
 /* }}} */
 
index 718457de064f70458bda059f7e5e750ccd6cacd2..7f4988fb3b7e51ff35691ec152858ed15eef0db2 100644 (file)
@@ -356,7 +356,7 @@ zend_string *accel_new_interned_string(zend_string *str)
        p->key->h = str->h;
        p->key->len = str->len;
        memcpy(p->key->val, str->val, str->len);
-       ZVAL_STR(&p->val, p->key);
+       ZVAL_INTERNED_STR(&p->val, p->key);
        Z_NEXT(p->val) = ZCSG(interned_strings).arHash[nIndex];
        ZCSG(interned_strings).arHash[nIndex] = idx;
        zend_string_release(str);
index dff4cebf06da0b586d3c04023a50c749ff7e608e..2b6ee3e6b40a415fe6c7cd10ec68fbeb96938134 100644 (file)
@@ -4008,7 +4008,7 @@ PHP_FUNCTION(openssl_pbkdf2)
 
        if (PKCS5_PBKDF2_HMAC(password, (int)password_len, (unsigned char *)salt, (int)salt_len, (int)iterations, digest, (int)key_length, (unsigned char*)out_buffer->val) == 1) {
                out_buffer->val[key_length] = 0;
-               RETURN_STR(out_buffer);
+               RETURN_NEW_STR(out_buffer);
        } else {
                zend_string_release(out_buffer);
                RETURN_FALSE;
index 27440bb49049400816243ccb1148f7a6553a0f0c..6e769e06f0045e3fd2e6bfa9b125d8cf3f297551 100644 (file)
@@ -1780,7 +1780,7 @@ static PHP_FUNCTION(preg_quote)
 
        /* Reallocate string and return it */
        out_str = zend_string_realloc(out_str, q - out_str->val, 0);
-       RETURN_STR(out_str);
+       RETURN_NEW_STR(out_str);
 }
 /* }}} */
 
index 2e8c6633dbc7bd1073b137308472924b53d8b474..4cbd218450050ce0333a13a3fdfd82a7e5c55d80 100644 (file)
@@ -72,7 +72,7 @@
                smart_str s = {0}; \
                smart_str_append_unsigned(&s, oid); \
                smart_str_0(&s); \
-               RETURN_STR(s.s); \
+               RETURN_NEW_STR(s.s); \
        } \
        RETURN_LONG((zend_long)oid); \
 } while(0)
@@ -2431,7 +2431,7 @@ PHP_FUNCTION(pg_field_table)
                        smart_str oidstr = {0};
                        smart_str_append_unsigned(&oidstr, oid);
                        smart_str_0(&oidstr);
-                       RETURN_STR(oidstr.s);
+                       RETURN_NEW_STR(oidstr.s);
                } else
 #endif
                        RETURN_LONG((zend_long)oid);
@@ -2536,7 +2536,7 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ
                                smart_str s = {0};
                                smart_str_append_unsigned(&s, oid);
                                smart_str_0(&s);
-                               RETURN_STR(s.s);
+                               RETURN_NEW_STR(s.s);
                        } else
 #endif
                        {
@@ -3515,7 +3515,7 @@ PHP_FUNCTION(pg_lo_read)
 
        buf->len = nbytes;
        buf->val[buf->len] = '\0';
-       RETURN_STR(buf);
+       RETURN_NEW_STR(buf);
 }
 /* }}} */
 
@@ -4363,7 +4363,7 @@ PHP_FUNCTION(pg_escape_string)
        }
 
        to = zend_string_realloc(to, to->len, 0);
-       RETURN_STR(to);
+       RETURN_NEW_STR(to);
 }
 /* }}} */
 
index 80e04046ed17e75a9b2c1916d836cb28cbba25af..4ab0559edabb591745b3f2b0f42391ea81315337 100644 (file)
@@ -1208,7 +1208,7 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
                if (fptr->type == ZEND_INTERNAL_FUNCTION) {
                        ZVAL_STRING(&name, ((zend_internal_arg_info*)arg_info)->name);
                } else {
-                       ZVAL_STR(&name, zend_string_copy(arg_info->name));
+                       ZVAL_STR_COPY(&name, arg_info->name);
                }
        } else {
                ZVAL_NULL(&name);
@@ -1636,7 +1636,7 @@ ZEND_METHOD(reflection_function, __toString)
        GET_REFLECTION_OBJECT_PTR(fptr);
        string_init(&str);
        _function_string(&str, fptr, intern->ce, "");
-       RETURN_STR(str.buf);
+       RETURN_NEW_STR(str.buf);
 }
 /* }}} */
 
@@ -1777,7 +1777,7 @@ ZEND_METHOD(reflection_function, getFileName)
        }
        GET_REFLECTION_OBJECT_PTR(fptr);
        if (fptr->type == ZEND_USER_FUNCTION) {
-               RETURN_STR(zend_string_copy(fptr->op_array.filename));
+               RETURN_STR_COPY(fptr->op_array.filename);
        }
        RETURN_FALSE;
 }
@@ -1831,7 +1831,7 @@ ZEND_METHOD(reflection_function, getDocComment)
        }
        GET_REFLECTION_OBJECT_PTR(fptr);
        if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
-               RETURN_STR(zend_string_copy(fptr->op_array.doc_comment));
+               RETURN_STR_COPY(fptr->op_array.doc_comment);
        }
        RETURN_FALSE;
 }
@@ -2288,7 +2288,7 @@ ZEND_METHOD(reflection_parameter, __construct)
                if (fptr->type == ZEND_INTERNAL_FUNCTION) {
                        ZVAL_STRING(&name, ((zend_internal_arg_info*)arg_info)[position].name);
                } else {
-                       ZVAL_STR(&name, zend_string_copy(arg_info[position].name));
+                       ZVAL_STR_COPY(&name, arg_info[position].name);
                }
        } else {
                ZVAL_NULL(&name);
@@ -2324,7 +2324,7 @@ ZEND_METHOD(reflection_parameter, __toString)
        GET_REFLECTION_OBJECT_PTR(param);
        string_init(&str);
        _parameter_string(&str, param->fptr, param->arg_info, param->offset, param->required, "");
-       RETURN_STR(str.buf);
+       RETURN_NEW_STR(str.buf);
 }
 /* }}} */
 
@@ -2668,7 +2668,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValueConstantName)
 
        precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
        if (precv && Z_TYPE_P(RT_CONSTANT(&param->fptr->op_array, precv->op2)) == IS_CONSTANT) {
-               RETURN_STR(zend_string_copy(Z_STR_P(RT_CONSTANT(&param->fptr->op_array, precv->op2))));
+               RETURN_STR_COPY(Z_STR_P(RT_CONSTANT(&param->fptr->op_array, precv->op2)));
        }
 }
 /* }}} */
@@ -2805,7 +2805,7 @@ ZEND_METHOD(reflection_method, __toString)
        GET_REFLECTION_OBJECT_PTR(mptr);
        string_init(&str);
        _function_string(&str, mptr, intern->ce, "");
-       RETURN_STR(str.buf);
+       RETURN_NEW_STR(str.buf);
 }
 /* }}} */
 
@@ -3530,7 +3530,7 @@ ZEND_METHOD(reflection_class, __toString)
        GET_REFLECTION_OBJECT_PTR(ce);
        string_init(&str);
        _class_string(&str, ce, &intern->obj, "");
-       RETURN_STR(str.buf);
+       RETURN_NEW_STR(str.buf);
 }
 /* }}} */
 
@@ -3587,7 +3587,7 @@ ZEND_METHOD(reflection_class, getFileName)
        }
        GET_REFLECTION_OBJECT_PTR(ce);
        if (ce->type == ZEND_USER_CLASS) {
-               RETURN_STR(zend_string_copy(ce->info.user.filename));
+               RETURN_STR_COPY(ce->info.user.filename);
        }
        RETURN_FALSE;
 }
@@ -3641,7 +3641,7 @@ ZEND_METHOD(reflection_class, getDocComment)
        }
        GET_REFLECTION_OBJECT_PTR(ce);
        if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) {
-               RETURN_STR(zend_string_copy(ce->info.user.doc_comment));
+               RETURN_STR_COPY(ce->info.user.doc_comment);
        }
        RETURN_FALSE;
 }
@@ -4883,7 +4883,7 @@ ZEND_METHOD(reflection_property, __toString)
        GET_REFLECTION_OBJECT_PTR(ref);
        string_init(&str);
        _property_string(&str, &ref->prop, NULL, "");
-       RETURN_STR(str.buf);
+       RETURN_NEW_STR(str.buf);
 }
 /* }}} */
 
@@ -5134,7 +5134,7 @@ ZEND_METHOD(reflection_property, getDocComment)
        }
        GET_REFLECTION_OBJECT_PTR(ref);
        if (ref->prop.doc_comment) {
-               RETURN_STR(zend_string_copy(ref->prop.doc_comment));
+               RETURN_STR_COPY(ref->prop.doc_comment);
        }
        RETURN_FALSE;
 }
@@ -5222,7 +5222,7 @@ ZEND_METHOD(reflection_extension, __toString)
        GET_REFLECTION_OBJECT_PTR(module);
        string_init(&str);
        _extension_string(&str, module, "");
-       RETURN_STR(str.buf);
+       RETURN_NEW_STR(str.buf);
 }
 /* }}} */
 
@@ -5588,7 +5588,7 @@ ZEND_METHOD(reflection_zend_extension, __toString)
        GET_REFLECTION_OBJECT_PTR(extension);
        string_init(&str);
        _zend_extension_string(&str, extension, "");
-       RETURN_STR(str.buf);
+       RETURN_NEW_STR(str.buf);
 }
 /* }}} */
 
index 8c5943a28c864eeb70a2f86163ef2f4b27937c23..25139d5ddb1a3e0c82ee0d21526ed87943663708 100644 (file)
@@ -1472,7 +1472,7 @@ PHPAPI void php_session_reset_id(void) /* {{{ */
                smart_str_0(&var);
                if (sid) {
                        zend_string_release(Z_STR_P(sid));
-                       ZVAL_STR(sid, var.s);
+                       ZVAL_NEW_STR(sid, var.s);
                } else {
                        REGISTER_STRINGL_CONSTANT("SID", var.s->val, var.s->len, 0);
                        smart_str_free(&var);
@@ -1988,9 +1988,9 @@ static PHP_FUNCTION(session_id)
                 * see: ext/session/tests/session_id_error3.phpt */
                int len = strlen(PS(id)->val);
                if (UNEXPECTED(len != PS(id)->len)) {
-                       RETVAL_STR(zend_string_init(PS(id)->val, len, 0));
+                       RETVAL_NEW_STR(zend_string_init(PS(id)->val, len, 0));
                } else {
-                       RETVAL_STR(zend_string_copy(PS(id)));
+                       RETVAL_STR_COPY(PS(id));
                }
        } else {
                RETVAL_EMPTY_STRING();
@@ -2085,7 +2085,7 @@ static PHP_FUNCTION(session_create_id)
                RETURN_FALSE;
        }
        smart_str_0(&id);
-       RETVAL_STR(id.s);
+       RETVAL_NEW_STR(id.s);
        smart_str_free(&id);
 }
 /* }}} */
index 2000bd24f01d6bbdf5082a9ecb2bcb8af36ebf99..751cb05c0d605ae19b57fcc3589da62ea3ca8511 100644 (file)
@@ -256,7 +256,7 @@ PHP_FUNCTION(shmop_read)
 
        return_string = zend_string_init(startaddr, bytes, 0);
 
-       RETURN_STR(return_string);
+       RETURN_NEW_STR(return_string);
 }
 /* }}} */
 
index d411345d44b78d1827857229907f3205e18fb18b..2f580cc8d3eb9e38b7017ac5426c8396dcd70afd 100644 (file)
@@ -3017,7 +3017,7 @@ PHP_METHOD(SoapClient, __getLastRequest)
 
        if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_request", sizeof("__last_request")-1)) != NULL &&
            Z_TYPE_P(tmp) == IS_STRING) {
-               RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
+               RETURN_STR_COPY(Z_STR_P(tmp));
        }
        RETURN_NULL();
 }
@@ -3036,7 +3036,7 @@ PHP_METHOD(SoapClient, __getLastResponse)
 
        if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_response", sizeof("__last_response")-1)) != NULL &&
            Z_TYPE_P(tmp) == IS_STRING) {
-               RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
+               RETURN_STR_COPY(Z_STR_P(tmp));
        }
        RETURN_NULL();
 }
@@ -3055,7 +3055,7 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
 
        if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_request_headers", sizeof("__last_request_headers")-1)) != NULL &&
            Z_TYPE_P(tmp) == IS_STRING) {
-               RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
+               RETURN_STR_COPY(Z_STR_P(tmp));
        }
        RETURN_NULL();
 }
@@ -3074,7 +3074,7 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
 
        if ((tmp = zend_hash_str_find(Z_OBJPROP_P(getThis()), "__last_response_headers", sizeof("__last_response_headers")-1)) != NULL &&
            Z_TYPE_P(tmp) == IS_STRING) {
-               RETURN_STR(zend_string_copy(Z_STR_P(tmp)));
+               RETURN_STR_COPY(Z_STR_P(tmp));
        }
        RETURN_NULL();
 }
@@ -3230,7 +3230,7 @@ PHP_METHOD(SoapClient, __setLocation)
        }
 
        if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "location", sizeof("location")-1)) != NULL && Z_TYPE_P(tmp) == IS_STRING) {
-               RETVAL_STR(zend_string_copy(Z_STR_P(tmp)));
+               RETVAL_STR_COPY(Z_STR_P(tmp));
        } else {
                RETVAL_NULL();
        }
index ad68d352c34ecd9274e62a23dca75f6b20c7e91b..32172c803b5f309fa0705033e48bed9c5f786b6d 100644 (file)
@@ -1181,7 +1181,7 @@ PHP_FUNCTION(socket_read)
        tmpbuf->len = retval;
        tmpbuf->val[tmpbuf->len] = '\0' ;
 
-       RETURN_STR(tmpbuf);
+       RETURN_NEW_STR(tmpbuf);
 }
 /* }}} */
 
index 2796ca650118ad6d3d8adbbefd5c461fe91c3817..7c75511c24f9a192f2aa268aae0ce68847b950b6 100644 (file)
@@ -1755,7 +1755,7 @@ SPL_METHOD(Array, serialize)
        PHP_VAR_SERIALIZE_DESTROY(var_hash);
 
        if (buf.s) {
-               RETURN_STR(buf.s);
+               RETURN_NEW_STR(buf.s);
        }
 
        RETURN_NULL();
index 3db762883702686852ed40ef9985e8210fd55e49..68c46486e10ac17085a5ecb85100cc94a2fe1e36 100644 (file)
@@ -1143,7 +1143,7 @@ SPL_METHOD(SplDoublyLinkedList, serialize)
        PHP_VAR_SERIALIZE_DESTROY(var_hash);
 
        if (buf.s) {
-               RETURN_STR(buf.s);
+               RETURN_NEW_STR(buf.s);
        } else {
                RETURN_NULL();
        }
index f0ce313eb6c8832ea19278cf0cc2a44e60f2e3f9..3ffb8f7becc817f7129b08c0bf3223be3fa82b9d 100644 (file)
@@ -1056,7 +1056,7 @@ static void spl_recursive_tree_iterator_get_prefix(spl_recursive_it_object *obje
        smart_str_appendl(&str, object->prefix[5].s->val, object->prefix[5].s->len);
        smart_str_0(&str);
 
-       RETURN_STR(str.s);
+       RETURN_NEW_STR(str.s);
 }
 
 static void spl_recursive_tree_iterator_get_entry(spl_recursive_it_object *object, zval *return_value)
@@ -2128,7 +2128,7 @@ SPL_METHOD(RegexIterator, getRegex)
                return;
        }
 
-       RETURN_STR(zend_string_copy(intern->u.regex.regex));
+       RETURN_STR_COPY(intern->u.regex.regex);
 } /* }}} */
 
 /* {{{ proto bool RegexIterator::getMode()
@@ -2812,7 +2812,7 @@ SPL_METHOD(CachingIterator, __toString)
                return;
        }
        if (Z_TYPE(intern->u.caching.zstr) == IS_STRING) {
-               RETURN_STR(zend_string_copy(Z_STR_P(&intern->u.caching.zstr)));
+               RETURN_STR_COPY(Z_STR_P(&intern->u.caching.zstr));
        } else {
                RETURN_NULL();
        }
index 41687d02a33ddc6fe3e26cf47ec56a63d5c2a43b..6316431635cec61b36605658dc93e0bab8ff2430 100644 (file)
@@ -778,7 +778,7 @@ SPL_METHOD(SplObjectStorage, serialize)
        PHP_VAR_SERIALIZE_DESTROY(var_hash);
 
        if (buf.s) {
-               RETURN_STR(buf.s);
+               RETURN_NEW_STR(buf.s);
        } else {
                RETURN_NULL();
        }
index e3f2a5d7cb702fbafbf4658effd3e9cfc2465355..63bf5e95c589dbe243ccea715e9dfc85bc44e7af 100644 (file)
@@ -1272,7 +1272,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
                                        RETURN_TRUE;
                                } else {
                                        if (str_idx) {
-                                               RETVAL_STR(zend_string_copy(str_idx));
+                                               RETVAL_STR_COPY(str_idx);
                                        } else {
                                                RETVAL_LONG(num_idx);
                                        }
@@ -1289,7 +1289,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
                                                RETURN_TRUE;
                                        } else {
                                                if (str_idx) {
-                                                       RETVAL_STR(zend_string_copy(str_idx));
+                                                       RETVAL_STR_COPY(str_idx);
                                                } else {
                                                        RETVAL_LONG(num_idx);
                                                }
@@ -1304,7 +1304,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
                                                RETURN_TRUE;
                                        } else {
                                                if (str_idx) {
-                                                       RETVAL_STR(zend_string_copy(str_idx));
+                                                       RETVAL_STR_COPY(str_idx);
                                                } else {
                                                        RETVAL_LONG(num_idx);
                                                }
@@ -1319,7 +1319,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
                                                RETURN_TRUE;
                                        } else {
                                                if (str_idx) {
-                                                       RETVAL_STR(zend_string_copy(str_idx));
+                                                       RETVAL_STR_COPY(str_idx);
                                                } else {
                                                        RETVAL_LONG(num_idx);
                                                }
@@ -4597,7 +4597,7 @@ PHP_FUNCTION(array_rand)
                        /* If we are returning a single result, just do it. */
                        if (Z_TYPE_P(return_value) != IS_ARRAY) {
                                if (string_key) {
-                                       RETURN_STR(zend_string_copy(string_key));
+                                       RETURN_STR_COPY(string_key);
                                } else {
                                        RETURN_LONG(num_key);
                                }
index 46389a407b0ca7061c3531fbbd0b41883a35e525..25b77280de9f374c25ee9f917e7da3919e25bbd5 100644 (file)
@@ -256,7 +256,7 @@ PHP_FUNCTION(http_build_query)
 
        smart_str_0(&formstr);
 
-       RETURN_STR(formstr.s);
+       RETURN_NEW_STR(formstr.s);
 }
 /* }}} */
 
index b55abb7feaab3ef2600bb03615de19048845df7d..fbbb639dc212ec42183a112eed9074756085841b 100644 (file)
@@ -1247,7 +1247,7 @@ again:
        smart_str_0(&implstr);
 
        if (implstr.s) {
-               RETURN_STR(implstr.s);
+               RETURN_NEW_STR(implstr.s);
        } else {
                smart_str_free(&implstr);
                RETURN_EMPTY_STRING();
@@ -2442,12 +2442,12 @@ PHP_FUNCTION(substr_replace)
                        (argc == 4 && Z_TYPE_P(from) != Z_TYPE_P(len))
                ) {
                        php_error_docref(NULL, E_WARNING, "'from' and 'len' should be of same type - numerical or array ");
-                       RETURN_STR(zend_string_copy(Z_STR_P(str)));
+                       RETURN_STR_COPY(Z_STR_P(str));
                }
                if (argc == 4 && Z_TYPE_P(from) == IS_ARRAY) {
                        if (zend_hash_num_elements(Z_ARRVAL_P(from)) != zend_hash_num_elements(Z_ARRVAL_P(len))) {
                                php_error_docref(NULL, E_WARNING, "'from' and 'len' should have the same number of elements");
-                               RETURN_STR(zend_string_copy(Z_STR_P(str)));
+                               RETURN_STR_COPY(Z_STR_P(str));
                        }
                }
        }
@@ -2516,7 +2516,7 @@ PHP_FUNCTION(substr_replace)
                        RETURN_NEW_STR(result);
                } else {
                        php_error_docref(NULL, E_WARNING, "Functionality of 'from' and 'len' as arrays is not implemented");
-                       RETURN_STR(zend_string_copy(Z_STR_P(str)));
+                       RETURN_STR_COPY(Z_STR_P(str));
                }
        } else { /* str is array of strings */
                zend_string *str_index = NULL;
@@ -3143,10 +3143,10 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
        if (result.s) {
                smart_str_appendl(&result, str + old_pos, slen - old_pos);
                smart_str_0(&result);
-               RETVAL_STR(result.s);
+               RETVAL_NEW_STR(result.s);
        } else {
                smart_str_free(&result);
-               RETVAL_STR(zend_string_copy(input));
+               RETVAL_STR_COPY(input);
        }
 
        if (pats == &str_hash) {
@@ -3492,7 +3492,7 @@ PHP_FUNCTION(strtr)
                HashTable *pats = HASH_OF(from);
 
                if (zend_hash_num_elements(pats) < 1) {
-                       RETURN_STR(zend_string_copy(str));
+                       RETURN_STR_COPY(str);
                } else if (zend_hash_num_elements(pats) == 1) {
                        zend_long num_key;
                        zend_string *str_key, *replace;
@@ -3507,7 +3507,7 @@ PHP_FUNCTION(strtr)
                                }               
                                replace = zval_get_string(entry);
                                if (str_key->len < 1) {
-                                       RETVAL_STR(zend_string_copy(str));
+                                       RETVAL_STR_COPY(str);
                                } else if (str_key->len == 1) {
                                        RETVAL_STR(php_char_to_str_ex(str,
                                                                str_key->val[0],
@@ -4585,7 +4585,7 @@ PHP_FUNCTION(setlocale)
                                        } else {
                                                BG(locale_string) = zend_string_init(retval, len, 0);
                                                zend_string_release(loc);
-                                               RETURN_STR(zend_string_copy(BG(locale_string)));
+                                               RETURN_STR_COPY(BG(locale_string));
                                        }
                                } else if (len == loc->len && !memcmp(loc->val, retval, len)) {
                                        RETURN_STR(loc);
index 1c5a000c2503bee378fe8110af455ea35f1aedc2..f8fe2cedd209b853ccd34f97837a5e0d9716ee13 100644 (file)
@@ -584,7 +584,7 @@ PHP_FUNCTION(var_export)
        smart_str_0 (&buf);
 
        if (return_output) {
-               RETURN_STR(buf.s);
+               RETURN_NEW_STR(buf.s);
        } else {
                PHPWRITE(buf.s->val, buf.s->len);
                smart_str_free(&buf);
@@ -983,7 +983,7 @@ PHP_FUNCTION(serialize)
        }
 
        if (buf.s) {
-               RETURN_STR(buf.s);
+               RETURN_NEW_STR(buf.s);
        } else {
                RETURN_NULL();
        }
index 99b7632119c78a0871597aeaca063919a25f25fa..371b1e95d1630efc3e0a55024eab84b9633794e2 100644 (file)
@@ -1093,7 +1093,7 @@ PHP_FUNCTION(wddx_serialize_value)
        php_wddx_packet_end(packet);
        smart_str_0(packet);
 
-       RETVAL_STR(zend_string_copy(packet->s));
+       RETVAL_STR_COPY(packet->s);
        php_wddx_destructor(packet);
 }
 /* }}} */
@@ -1132,7 +1132,7 @@ PHP_FUNCTION(wddx_serialize_vars)
        php_wddx_packet_end(packet);
        smart_str_0(packet);
 
-       RETVAL_STR(zend_string_copy(packet->s));
+       RETVAL_STR_COPY(packet->s);
        php_wddx_destructor(packet);
 }
 /* }}} */
@@ -1201,7 +1201,7 @@ PHP_FUNCTION(wddx_packet_end)
        php_wddx_packet_end(packet);
        smart_str_0(packet);
 
-       RETVAL_STR(zend_string_copy(packet->s));
+       RETVAL_STR_COPY(packet->s);
 
        zend_list_close(Z_RES_P(packet_id));
 }
index 553836b8c5a95ec4a264c92d6d4399e229afbf68..1aa3412aad2bc59842b8481e20d4f02df62fb41b 100644 (file)
@@ -803,7 +803,7 @@ PHP_FUNCTION(xsl_xsltprocessor_get_parameter)
        intern = Z_XSL_P(id);
        if ((value = zend_hash_find(intern->parameter, name)) != NULL) {
                convert_to_string_ex(value);
-               RETURN_STR(zend_string_copy(Z_STR_P(value)));
+               RETURN_STR_COPY(Z_STR_P(value));
        } else {
                RETURN_FALSE;
        }
index e90ee9f9792048f73be3647d4b4da6c2a817f0bd..375df46bc94b93f4cea388179b6114033f8839f0 100644 (file)
@@ -1279,7 +1279,7 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read)
                if (n > 0) {
                        buffer->val[n] = '\0';
                        buffer->len = n;
-                       RETURN_STR(buffer);
+                       RETURN_NEW_STR(buffer);
                } else {
                        zend_string_free(buffer);
                        RETURN_EMPTY_STRING()
@@ -2648,7 +2648,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
        zip_fclose(zf);
        buffer->val[n] = '\0';
        buffer->len = n;
-       RETURN_STR(buffer);
+       RETURN_NEW_STR(buffer);
 }
 /* }}} */