mirror of
https://github.com/php-win-ext/phpredis.git
synced 2026-03-24 00:52:16 +01:00
PHP 7.3 doesn't have zend_string_concat2
This commit is contained in:
20
library.c
20
library.c
@@ -3496,10 +3496,22 @@ redis_key_prefix(RedisSock *redis_sock, char **key, size_t *key_len) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static zend_string *redis_zstr_concat(zend_string *prefix, zend_string *key) {
|
||||
ZEND_ASSERT(prefix != NULL && key != NULL);
|
||||
return zend_string_concat2(ZSTR_VAL(prefix), ZSTR_LEN(prefix),
|
||||
ZSTR_VAL(key), ZSTR_LEN(key));
|
||||
/* This is very similar to PHP >= 7.4 zend_string_concat2 only we are taking
|
||||
* two zend_string arguments rather than two char*, size_t pairs */
|
||||
static zend_string *redis_zstr_concat(zend_string *prefix, zend_string *suffix) {
|
||||
zend_string *res;
|
||||
size_t len;
|
||||
|
||||
ZEND_ASSERT(prefix != NULL && suffix != NULL);
|
||||
|
||||
len = ZSTR_LEN(prefix) + ZSTR_LEN(suffix);
|
||||
res = zend_string_alloc(len, 0);
|
||||
|
||||
memcpy(ZSTR_VAL(res), ZSTR_VAL(prefix), ZSTR_LEN(prefix));
|
||||
memcpy(ZSTR_VAL(res) + ZSTR_LEN(prefix), ZSTR_VAL(suffix), ZSTR_LEN(suffix));
|
||||
ZSTR_VAL(res)[len] = '\0';
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
PHP_REDIS_API zend_string *
|
||||
|
||||
Reference in New Issue
Block a user