diff options
| author | Ben Fuhrmannek | 2021-08-07 22:33:21 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-08-07 22:33:21 +0200 |
| commit | 26ee817a0e5a2bed4994fd4efc13e7f5106ca55c (patch) | |
| tree | 5cb9d274592fa4869c10a25affec977ce8b778a8 /src/sp_php_compat.c | |
| parent | 51c020904f25ac7400e4db2e5174edc8c49fcb43 (diff) | |
PHP7 compatibility
Diffstat (limited to '')
| -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 | ||
