summaryrefslogtreecommitdiff
path: root/src/sp_php_compat.c
blob: a0693c3d8df6d30b9933598371a2317e3f070131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "php_snuffleupagus.h"

/* code in this file is licensed under its original license
   The PHP License, version 3.01 (https://www.php.net/license/3_01.txt)
   which is also included with these sources in the file `PHP_LICENSE` */

#if PHP_VERSION_ID < 80000

// copied from PHP 8.0.9 sources

ZEND_API zend_string *zend_string_concat2(
		const char *str1, size_t str1_len,
		const char *str2, size_t str2_len)
{
	size_t len = str1_len + str2_len;
	zend_string *res = zend_string_alloc(len, 0);

	memcpy(ZSTR_VAL(res), str1, str1_len);
	memcpy(ZSTR_VAL(res) + str1_len, str2, str2_len);
	ZSTR_VAL(res)[len] = '\0';

	return res;
}

#endif