diff options
Diffstat (limited to 'src/sp_php_compat.c')
| -rw-r--r-- | src/sp_php_compat.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/sp_php_compat.c b/src/sp_php_compat.c new file mode 100644 index 0000000..a0693c3 --- /dev/null +++ b/src/sp_php_compat.c | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #include "php_snuffleupagus.h" | ||
| 2 | |||
| 3 | /* code in this file is licensed under its original license | ||
| 4 | The PHP License, version 3.01 (https://www.php.net/license/3_01.txt) | ||
| 5 | which is also included with these sources in the file `PHP_LICENSE` */ | ||
| 6 | |||
| 7 | #if PHP_VERSION_ID < 80000 | ||
| 8 | |||
| 9 | // copied from PHP 8.0.9 sources | ||
| 10 | |||
| 11 | ZEND_API zend_string *zend_string_concat2( | ||
| 12 | const char *str1, size_t str1_len, | ||
| 13 | const char *str2, size_t str2_len) | ||
| 14 | { | ||
| 15 | size_t len = str1_len + str2_len; | ||
| 16 | zend_string *res = zend_string_alloc(len, 0); | ||
| 17 | |||
| 18 | memcpy(ZSTR_VAL(res), str1, str1_len); | ||
| 19 | memcpy(ZSTR_VAL(res) + str1_len, str2, str2_len); | ||
| 20 | ZSTR_VAL(res)[len] = '\0'; | ||
| 21 | |||
| 22 | return res; | ||
| 23 | } | ||
| 24 | |||
| 25 | #endif | ||
