summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-03-20 02:02:42 +0300
committerDmitry Stogov <dmitry@zend.com>2015-03-20 02:02:42 +0300
commitd146d15003442a2e5234dd2fab1605094dc21630 (patch)
tree3a20cd8866a8544ed8bfd04b8c71f7041b4ca91e /ext
parent184793b5c1e7a9df67e542893b69bace5cd7a67c (diff)
downloadphp-git-d146d15003442a2e5234dd2fab1605094dc21630.tar.gz
Optimize zend_string_realloc() add more specialized versions zend_string_extend() and zend_string_truncate()
Diffstat (limited to 'ext')
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/iconv/iconv.c6
-rw-r--r--ext/mysqli/mysqli_api.c2
-rw-r--r--ext/oci8/oci8_statement.c2
-rw-r--r--ext/opcache/Optimizer/block_pass.c4
-rw-r--r--ext/pcre/php_pcre.c4
-rw-r--r--ext/pgsql/pgsql.c4
-rw-r--r--ext/reflection/php_reflection.c4
-rw-r--r--ext/sockets/sockets.c2
-rw-r--r--ext/spl/php_spl.c4
-rw-r--r--ext/standard/exec.c4
-rw-r--r--ext/standard/formatted_print.c4
-rw-r--r--ext/standard/metaphone.c4
-rw-r--r--ext/standard/quot_print.c2
-rw-r--r--ext/standard/string.c14
-rw-r--r--ext/standard/url.c4
-rw-r--r--ext/standard/uuencode.c2
-rw-r--r--ext/wddx/wddx.c2
-rw-r--r--ext/xml/xml.c8
-rw-r--r--ext/zlib/zlib.c2
20 files changed, 41 insertions, 41 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 1946dacda1..3df1669c40 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1661,7 +1661,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
buf = zend_string_alloc(buf_len, 0);
while ((real_len = strftime(buf->val, buf_len, format, &ta)) == buf_len || real_len == 0) {
buf_len *= 2;
- buf = zend_string_realloc(buf, buf_len, 0);
+ buf = zend_string_extend(buf, buf_len, 0);
if (!--max_reallocs) {
break;
}
@@ -1680,7 +1680,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);
+ buf = zend_string_truncate(buf, real_len, 0);
RETURN_NEW_STR(buf);
}
zend_string_free(buf);
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 81dfd51136..7621ce75ac 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -581,7 +581,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
if (out_left < 8) {
size_t pos = out_p - out_buffer->val;
- out_buffer = zend_string_realloc(out_buffer, out_size + 8, 0);
+ out_buffer = zend_string_extend(out_buffer, out_size + 8, 0);
out_p = out_buffer->val + pos;
out_size += 7;
out_left += 7;
@@ -640,7 +640,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
/* converted string is longer than out buffer */
bsz += in_len;
- out_buf = zend_string_realloc(out_buf, bsz, 0);
+ out_buf = zend_string_extend(out_buf, bsz, 0);
out_p = out_buf->val;
out_p += out_size;
out_left = bsz - out_size;
@@ -662,7 +662,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
if (errno == E2BIG) {
bsz += 16;
- out_buf = zend_string_realloc(out_buf, bsz, 0);
+ out_buf = zend_string_extend(out_buf, bsz, 0);
out_p = out_buf->val;
out_p += out_size;
out_left = bsz - out_size;
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index eec5e74acb..d19126ff91 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -1988,7 +1988,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
newstr = zend_string_alloc(2 * escapestr_len, 0);
newstr->len = mysql_real_escape_string(mysql->mysql, newstr->val, escapestr, escapestr_len);
- newstr = zend_string_realloc(newstr, newstr->len, 0);
+ newstr = zend_string_truncate(newstr, newstr->len, 0);
RETURN_NEW_STR(newstr);
}
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index 4fcff43c4f..d55de3275e 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -983,7 +983,7 @@ int php_oci_bind_post_exec(void *data)
* binds, php_oci_bind_out_callback() should have allocated a
* new string that we can modify here.
*/
- Z_STR(bind->zval) = zend_string_realloc(Z_STR(bind->zval), Z_STRLEN(bind->zval)+1, 0);
+ Z_STR(bind->zval) = zend_string_extend(Z_STR(bind->zval), Z_STRLEN(bind->zval)+1, 0);
Z_STRVAL(bind->zval)[ Z_STRLEN(bind->zval) ] = '\0';
} else if (Z_TYPE(bind->zval) == IS_ARRAY) {
int i;
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 24be4d266a..3f57183ed3 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -899,7 +899,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
memcpy(tmp->val, Z_STRVAL(ZEND_OP1_LITERAL(last_op)), old_len);
Z_STR(ZEND_OP1_LITERAL(last_op)) = tmp;
} else {
- Z_STR(ZEND_OP1_LITERAL(last_op)) = zend_string_realloc(Z_STR(ZEND_OP1_LITERAL(last_op)), l, 0);
+ Z_STR(ZEND_OP1_LITERAL(last_op)) = zend_string_extend(Z_STR(ZEND_OP1_LITERAL(last_op)), l, 0);
}
Z_TYPE_INFO(ZEND_OP1_LITERAL(last_op)) = IS_STRING_EX;
memcpy(Z_STRVAL(ZEND_OP1_LITERAL(last_op)) + old_len, Z_STRVAL(ZEND_OP1_LITERAL(opline)), Z_STRLEN(ZEND_OP1_LITERAL(opline)));
@@ -954,7 +954,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
memcpy(tmp->val, Z_STRVAL(ZEND_OP2_LITERAL(src)), old_len);
Z_STR(ZEND_OP2_LITERAL(last_op)) = tmp;
} else {
- Z_STR(ZEND_OP2_LITERAL(src)) = zend_string_realloc(Z_STR(ZEND_OP2_LITERAL(src)), l, 0);
+ Z_STR(ZEND_OP2_LITERAL(src)) = zend_string_extend(Z_STR(ZEND_OP2_LITERAL(src)), l, 0);
}
Z_TYPE_INFO(ZEND_OP2_LITERAL(last_op)) = IS_STRING_EX;
memcpy(Z_STRVAL(ZEND_OP2_LITERAL(src)) + old_len, Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)));
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 6e769e06f0..8080823b09 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -1158,7 +1158,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
result = zend_string_alloc(alloc_len, 0);
} else {
alloc_len = alloc_len + 2 * new_len;
- result = zend_string_realloc(result, alloc_len, 0);
+ result = zend_string_extend(result, alloc_len, 0);
}
}
/* copy the part of the string before the match */
@@ -1779,7 +1779,7 @@ static PHP_FUNCTION(preg_quote)
*q = '\0';
/* Reallocate string and return it */
- out_str = zend_string_realloc(out_str, q - out_str->val, 0);
+ out_str = zend_string_truncate(out_str, q - out_str->val, 0);
RETURN_NEW_STR(out_str);
}
/* }}} */
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 4cbd218450..6e37f18287 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -4362,7 +4362,7 @@ PHP_FUNCTION(pg_escape_string)
to->len = PQescapeString(to->val, from->val, from->len);
}
- to = zend_string_realloc(to, to->len, 0);
+ to = zend_string_truncate(to, to->len, 0);
RETURN_NEW_STR(to);
}
/* }}} */
@@ -6048,7 +6048,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
str = zend_string_alloc(Z_STRLEN_P(val) * 2, 0);
/* better to use PGSQLescapeLiteral since PGescapeStringConn does not handle special \ */
str->len = PQescapeStringConn(pg_link, str->val, Z_STRVAL_P(val), Z_STRLEN_P(val), NULL);
- str = zend_string_realloc(str, str->len, 0);
+ str = zend_string_truncate(str, str->len, 0);
ZVAL_NEW_STR(&new_val, str);
php_pgsql_add_quotes(&new_val, 1);
}
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index bed3823a4e..72a88be47c 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -140,7 +140,7 @@ static string *string_printf(string *str, const char *format, ...)
if (str->alloced < nlen) {
size_t old_len = str->buf->len;
str->alloced = nlen;
- str->buf = zend_string_realloc(str->buf, str->alloced, 0);
+ str->buf = zend_string_extend(str->buf, str->alloced, 0);
str->buf->len = old_len;
}
memcpy(str->buf->val + str->buf->len, s_tmp, len + 1);
@@ -157,7 +157,7 @@ static string *string_write(string *str, char *buf, size_t len)
if (str->alloced < nlen) {
size_t old_len = str->buf->len;
str->alloced = nlen;
- str->buf = zend_string_realloc(str->buf, str->alloced, 0);
+ str->buf = zend_string_extend(str->buf, str->alloced, 0);
str->buf->len = old_len;
}
memcpy(str->buf->val + str->buf->len, buf, len);
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 32172c803b..5f6c17af9a 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -1177,7 +1177,7 @@ PHP_FUNCTION(socket_read)
RETURN_EMPTY_STRING();
}
- tmpbuf = zend_string_realloc(tmpbuf, retval, 0);
+ tmpbuf = zend_string_truncate(tmpbuf, retval, 0);
tmpbuf->len = retval;
tmpbuf->val[tmpbuf->len] = '\0' ;
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index f16734422b..78bdd6744f 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -552,7 +552,7 @@ PHP_FUNCTION(spl_autoload_register)
if (obj_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) {
/* add object id to the hash to ensure uniqueness, for more reference look at bug #40091 */
- lc_name = zend_string_realloc(lc_name, lc_name->len + sizeof(uint32_t), 0);
+ lc_name = zend_string_extend(lc_name, lc_name->len + sizeof(uint32_t), 0);
memcpy(lc_name->val + lc_name->len - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t));
lc_name->val[lc_name->len] = '\0';
ZVAL_OBJ(&alfi.obj, obj_ptr);
@@ -663,7 +663,7 @@ PHP_FUNCTION(spl_autoload_unregister)
/* remove specific */
success = zend_hash_del(SPL_G(autoload_functions), lc_name);
if (success != SUCCESS && obj_ptr) {
- lc_name = zend_string_realloc(lc_name, lc_name->len + sizeof(uint32_t), 0);
+ lc_name = zend_string_extend(lc_name, lc_name->len + sizeof(uint32_t), 0);
memcpy(lc_name->val + lc_name->len - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t));
lc_name->val[lc_name->len] = '\0';
success = zend_hash_del(SPL_G(autoload_functions), lc_name);
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index a98751ef12..71dfc7c361 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -326,7 +326,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
if ((estimate - y) > 4096) {
/* realloc if the estimate was way overill
* Arbitrary cutoff point of 4096 */
- cmd = zend_string_realloc(cmd, y, 0);
+ cmd = zend_string_truncate(cmd, y, 0);
}
cmd->len = y;
@@ -392,7 +392,7 @@ PHPAPI zend_string *php_escape_shell_arg(char *str)
if ((estimate - y) > 4096) {
/* realloc if the estimate was way overill
* Arbitrary cutoff point of 4096 */
- cmd = zend_string_realloc(cmd, y, 0);
+ cmd = zend_string_truncate(cmd, y, 0);
}
cmd->len = y;
return cmd;
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index cf4eee0657..4c0eeeebb9 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -61,7 +61,7 @@ php_sprintf_appendchar(zend_string **buffer, size_t *pos, char add)
{
if (!*buffer || (*pos + 1) >= (*buffer)->len) {
PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(), (*buffer)->len));
- *buffer = zend_string_realloc(*buffer, (*buffer)->len << 1, 0);
+ *buffer = zend_string_extend(*buffer, (*buffer)->len << 1, 0);
}
PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos));
(*buffer)->val[(*pos)++] = add;
@@ -101,7 +101,7 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add,
size <<= 1;
}
PRINTF_DEBUG(("sprintf ereallocing buffer to %d bytes\n", size));
- *buffer = zend_string_realloc(*buffer, size, 0);
+ *buffer = zend_string_extend(*buffer, size, 0);
}
if (alignment == ALIGN_RIGHT) {
if ((neg || always_sign) && padding=='0') {
diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c
index cc94b0372f..de29415cdf 100644
--- a/ext/standard/metaphone.c
+++ b/ext/standard/metaphone.c
@@ -142,7 +142,7 @@ static char Lookahead(char *word, int how_far)
* could be one though; or more too). */
#define Phonize(c) { \
if (p_idx >= max_buffer_len) { \
- *phoned_word = zend_string_realloc(*phoned_word, 2 * sizeof(char) + max_buffer_len, 0); \
+ *phoned_word = zend_string_extend(*phoned_word, 2 * sizeof(char) + max_buffer_len, 0); \
max_buffer_len += 2; \
} \
(*phoned_word)->val[p_idx++] = c; \
@@ -151,7 +151,7 @@ static char Lookahead(char *word, int how_far)
/* Slap a null character on the end of the phoned word */
#define End_Phoned_Word { \
if (p_idx == max_buffer_len) { \
- *phoned_word = zend_string_realloc(*phoned_word, 1 * sizeof(char) + max_buffer_len, 0); \
+ *phoned_word = zend_string_extend(*phoned_word, 1 * sizeof(char) + max_buffer_len, 0); \
max_buffer_len += 1; \
} \
(*phoned_word)->val[p_idx] = '\0'; \
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
index d19ef07e66..26d1d2b6fc 100644
--- a/ext/standard/quot_print.c
+++ b/ext/standard/quot_print.c
@@ -187,7 +187,7 @@ PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t lengt
}
}
*d = '\0';
- ret = zend_string_realloc(ret, d - (unsigned char*)ret->val, 0);
+ ret = zend_string_truncate(ret, d - (unsigned char*)ret->val, 0);
return ret;
}
/* }}} */
diff --git a/ext/standard/string.c b/ext/standard/string.c
index fbbb639dc2..01a87fe919 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1004,7 +1004,7 @@ PHP_FUNCTION(wordwrap)
for (current = 0; current < text->len; current++) {
if (chk <= 0) {
alloced += (size_t) (((text->len - current + 1)/linelength + 1) * breakchar_len) + 1;
- newtext = zend_string_realloc(newtext, alloced, 0);
+ newtext = zend_string_extend(newtext, alloced, 0);
chk = (size_t) ((text->len - current)/linelength) + 1;
}
/* when we hit an existing break, copy to new buffer, and
@@ -1065,7 +1065,7 @@ PHP_FUNCTION(wordwrap)
newtext->val[newtextlen] = '\0';
/* free unused memory */
- newtext = zend_string_realloc(newtext, newtextlen, 0);
+ newtext = zend_string_truncate(newtext, newtextlen, 0);
RETURN_NEW_STR(newtext);
}
@@ -2738,7 +2738,7 @@ PHP_FUNCTION(quotemeta)
*q = '\0';
- RETURN_NEW_STR(zend_string_realloc(str, q - str->val, 0));
+ RETURN_NEW_STR(zend_string_truncate(str, q - str->val, 0));
}
/* }}} */
@@ -3441,7 +3441,7 @@ PHPAPI zend_string *php_str_to_str(char *haystack, size_t length, char *needle,
}
*e = '\0';
- new_str = zend_string_realloc(new_str, e - s, 0);
+ new_str = zend_string_truncate(new_str, e - s, 0);
return new_str;
}
} else if (needle_len > length || memcmp(haystack, needle, length)) {
@@ -3878,7 +3878,7 @@ PHPAPI zend_string *php_addcslashes(zend_string *str, int should_free, char *wha
*target = 0;
newlen = target - new_str->val;
if (newlen < str->len * 4) {
- new_str = zend_string_realloc(new_str, newlen, 0);
+ new_str = zend_string_truncate(new_str, newlen, 0);
}
if (should_free) {
zend_string_release(str);
@@ -3954,7 +3954,7 @@ do_escape:
}
if (new_str->len - (target - new_str->val) > 16) {
- new_str = zend_string_realloc(new_str, target - new_str->val, 0);
+ new_str = zend_string_truncate(new_str, target - new_str->val, 0);
} else {
new_str->len = target - new_str->val;
}
@@ -5648,7 +5648,7 @@ PHP_FUNCTION(money_format)
str->len = (size_t)res_len;
str->val[str->len] = '\0';
- RETURN_NEW_STR(zend_string_realloc(str, str->len, 0));
+ RETURN_NEW_STR(zend_string_truncate(str, str->len, 0));
}
/* }}} */
#endif
diff --git a/ext/standard/url.c b/ext/standard/url.c
index b2ffa3750e..1dceda1483 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -524,7 +524,7 @@ PHPAPI zend_string *php_url_encode(char const *s, size_t len)
}
*to = '\0';
- start = zend_string_realloc(start, to - (unsigned char*)start->val, 0);
+ start = zend_string_truncate(start, to - (unsigned char*)start->val, 0);
return start;
}
@@ -631,7 +631,7 @@ PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len)
}
}
str->val[y] = '\0';
- str = zend_string_realloc(str, y, 0);
+ str = zend_string_truncate(str, y, 0);
return str;
}
diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c
index afe9f7bea1..91de87a194 100644
--- a/ext/standard/uuencode.c
+++ b/ext/standard/uuencode.c
@@ -122,7 +122,7 @@ PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */
*p++ = '\n';
*p = '\0';
- dest = zend_string_realloc(dest, p - dest->val, 0);
+ dest = zend_string_truncate(dest, p - dest->val, 0);
return dest;
}
/* }}} */
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 371b1e95d1..235efcdd18 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -991,7 +991,7 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len)
zval_ptr_dtor(&ent->data);
ZVAL_STRINGL(&ent->data, (char *)s, len);
} else {
- Z_STR(ent->data) = zend_string_realloc(Z_STR(ent->data), Z_STRLEN(ent->data) + len, 0);
+ Z_STR(ent->data) = zend_string_extend(Z_STR(ent->data), Z_STRLEN(ent->data) + len, 0);
memcpy(Z_STRVAL(ent->data) + Z_STRLEN(ent->data) - len, (char *)s, len);
Z_STRVAL(ent->data)[Z_STRLEN(ent->data)] = '\0';
}
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 0ced7a2284..8a26a7ff5c 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -604,7 +604,7 @@ PHPAPI zend_string *xml_utf8_encode(const char *s, size_t len, const XML_Char *e
s++;
}
str->val[str->len] = '\0';
- str = zend_string_realloc(str, str->len, 0);
+ str = zend_string_truncate(str, str->len, 0);
return str;
}
/* }}} */
@@ -644,7 +644,7 @@ PHPAPI zend_string *xml_utf8_decode(const XML_Char *s, size_t len, const XML_Cha
}
str->val[str->len] = '\0';
if (str->len < len) {
- str = zend_string_realloc(str, str->len, 0);
+ str = zend_string_truncate(str, str->len, 0);
}
return str;
@@ -892,7 +892,7 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
/* check if the current tag already has a value - if yes append to that! */
if ((myval = zend_hash_str_find(Z_ARRVAL_P(parser->ctag), "value", sizeof("value") - 1))) {
int newlen = Z_STRLEN_P(myval) + decoded_value->len;
- Z_STR_P(myval) = zend_string_realloc(Z_STR_P(myval), newlen, 0);
+ Z_STR_P(myval) = zend_string_extend(Z_STR_P(myval), newlen, 0);
strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - decoded_value->len,
decoded_value->val, decoded_value->len + 1);
zend_string_release(decoded_value);
@@ -909,7 +909,7 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
if (!strcmp(Z_STRVAL_P(mytype), "cdata")) {
if ((myval = zend_hash_str_find(Z_ARRVAL_P(curtag), "value", sizeof("value") - 1))) {
int newlen = Z_STRLEN_P(myval) + decoded_value->len;
- Z_STR_P(myval) = zend_string_realloc(Z_STR_P(myval), newlen, 0);
+ Z_STR_P(myval) = zend_string_extend(Z_STR_P(myval), newlen, 0);
strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - decoded_value->len,
decoded_value->val, decoded_value->len + 1);
zend_string_release(decoded_value);
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 64eac450cd..b638ab4377 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -336,7 +336,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod
if (Z_STREAM_END == status) {
/* size buffer down to actual length */
- out = zend_string_realloc(out, Z.total_out, 0);
+ out = zend_string_truncate(out, Z.total_out, 0);
out->val[out->len] = '\0';
return out;
} else {