Skip to content

Commit 75dcdad

Browse files
committed
use zend_string_concat3
1 parent 778712e commit 75dcdad

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

ext/uri/uri_parser_rfc3986.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,12 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_host_read(void
238238
if (uriparser_uri->hostData.ip6 != NULL || uriparser_uri->hostData.ipFuture.first != NULL) {
239239
/* the textual representation of the host is always accessible in the .hostText field no matter what the host is */
240240
const size_t host_len = get_text_range_length(&uriparser_uri->hostText);
241-
zend_string *host_str = zend_string_alloc(host_len + 2, false);
242-
243-
char *out = ZSTR_VAL(host_str);
244-
245-
*(out++) = '[';
246-
out = zend_mempcpy(out, uriparser_uri->hostText.first, host_len);
247-
*(out++) = ']';
248-
*out = '\0';
249-
241+
242+
zend_string *host_str = zend_string_concat3(
243+
"[", 1,
244+
uriparser_uri->hostText.first, host_len,
245+
"]", 1
246+
);
250247
ZVAL_NEW_STR(retval, host_str);
251248
} else {
252249
ZVAL_STRINGL(retval, uriparser_uri->hostText.first, get_text_range_length(&uriparser_uri->hostText));

0 commit comments

Comments
 (0)