PHP 7.3 doesn't have zend_string_concat2

This commit is contained in:
michael-grunder
2022-09-28 21:04:20 -07:00
parent f42a26a7f9
commit 2234bd552f

View File

@@ -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 *