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>2017-08-01 23:41:48 +0300
committerPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2017-08-16 16:58:10 +0300
commit2bf7b2f7142f3fc14ba83260c065ef98e6499b8b (patch)
tree9a2c55f66dd9f4c33f92fc04a5b23ecbc966f541 /common.h
parentacc84cccb9f590e13a421a87f6fa3c82a1b33ea9 (diff)
Use zend_string to store strings in RedisSock
Following fields were changed: err, prefix, persistent_id, auth and host
Diffstat (limited to 'common.h')
-rw-r--r--common.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/common.h b/common.h
index c9c78ac4..133b4e8a 100644
--- a/common.h
+++ b/common.h
@@ -25,6 +25,19 @@ typedef struct {
#define ZSTR_VAL(s) (s)->val
#define ZSTR_LEN(s) (s)->len
+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);
+
+ 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;
+}
+
#define zend_string_release(s) do { \
if ((s) && (s)->gc) { \
if ((s)->gc & 0x10 && ZSTR_VAL(s)) efree(ZSTR_VAL(s)); \
@@ -619,9 +632,9 @@ typedef struct fold_item {
/* {{{ struct RedisSock */
typedef struct {
php_stream *stream;
- char *host;
+ zend_string *host;
short port;
- char *auth;
+ zend_string *auth;
double timeout;
double read_timeout;
long retry_interval;
@@ -629,13 +642,12 @@ typedef struct {
int status;
int persistent;
int watching;
- char *persistent_id;
+ zend_string *persistent_id;
int serializer;
long dbNumber;
- char *prefix;
- int prefix_len;
+ zend_string *prefix;
short mode;
fold_item *head;
@@ -644,8 +656,8 @@ typedef struct {
char *pipeline_cmd;
size_t pipeline_len;
- char *err;
- int err_len;
+ zend_string *err;
+
zend_bool lazy_connect;
int scan;