Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2018-03-26 14:24:33 +0300
committerPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2018-03-26 14:24:33 +0300
commit07c16e51b081b12bd19ae77af1143149fae5a760 (patch)
treed342fb47039c6c5966a27aadb878f6ac42bfa492 /common.h
parent5f75efcf95aab3b7387ba06e8c2a8f2d2a3da1ed (diff)
Apply zend_string API for redis_session_key
Diffstat (limited to 'common.h')
-rw-r--r--common.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/common.h b/common.h
index 4b1342df..11c243e4 100644
--- a/common.h
+++ b/common.h
@@ -26,15 +26,23 @@ typedef struct {
#define ZSTR_LEN(s) (s)->len
static zend_always_inline zend_string *
+zend_string_alloc(size_t len, int persistent)
+{
+ zend_string *zstr = emalloc(sizeof(*zstr) + len + 1);
+
+ ZSTR_VAL(zstr) = (char *)zstr + sizeof(*zstr);
+ zstr->len = len;
+ zstr->gc = 0x01;
+ return zstr;
+}
+
+static zend_always_inline zend_string *
zend_string_init(const char *str, size_t len, int persistent)
{
- zend_string *zstr = emalloc(sizeof(zend_string) + len + 1);
+ zend_string *zstr = zend_string_alloc(len, persistent);
- ZSTR_VAL(zstr) = (char *)zstr + sizeof(zend_string);
memcpy(ZSTR_VAL(zstr), str, len);
ZSTR_VAL(zstr)[len] = '\0';
- zstr->len = len;
- zstr->gc = 0x01;
return zstr;
}