diff options
Diffstat (limited to 'src/sp_php_compat.c')
| -rw-r--r-- | src/sp_php_compat.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/sp_php_compat.c b/src/sp_php_compat.c new file mode 100644 index 0000000..933acd8 --- /dev/null +++ b/src/sp_php_compat.c | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | #include "php_snuffleupagus.h" | ||
| 2 | |||
| 3 | #if PHP_VERSION_ID < 80000 | ||
| 4 | |||
| 5 | // zend_string_concat2 taken from PHP 8.0.9 zend_string.c | ||
| 6 | // TODO: license clarification | ||
| 7 | |||
| 8 | ZEND_API zend_string *zend_string_concat2( | ||
| 9 | const char *str1, size_t str1_len, | ||
| 10 | const char *str2, size_t str2_len) | ||
| 11 | { | ||
| 12 | size_t len = str1_len + str2_len; | ||
| 13 | zend_string *res = zend_string_alloc(len, 0); | ||
| 14 | |||
| 15 | memcpy(ZSTR_VAL(res), str1, str1_len); | ||
| 16 | memcpy(ZSTR_VAL(res) + str1_len, str2, str2_len); | ||
| 17 | ZSTR_VAL(res)[len] = '\0'; | ||
| 18 | |||
| 19 | return res; | ||
| 20 | } | ||
| 21 | |||
| 22 | #endif | ||
