diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-11-26 13:04:42 +0100 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-11-26 13:04:42 +0100 |
commit | adb0895e999cd61503ce221702ead7e2957b115a (patch) | |
tree | a32d18c69a668564e138864eab245241a0ee71fb | |
parent | b4dd17b57f90edfcba80ce666218ef4173ca6d9e (diff) |
Rename 'parent' field in read tasks to 'obj'
-rw-r--r-- | hiredis.c | 16 | ||||
-rw-r--r-- | hiredis.h | 4 |
2 files changed, 11 insertions, 9 deletions
@@ -112,7 +112,7 @@ static void *createStringObject(const redisReadTask *task, char *str, size_t len r->len = len; if (task->parent) { - redisReply *parent = task->parent; + redisReply *parent = task->parent->obj; assert(parent->type == REDIS_REPLY_ARRAY); parent->element[task->idx] = r; } @@ -125,7 +125,7 @@ static void *createArrayObject(const redisReadTask *task, int elements) { if ((r->element = calloc(sizeof(redisReply*),elements)) == NULL) redisOOM(); if (task->parent) { - redisReply *parent = task->parent; + redisReply *parent = task->parent->obj; assert(parent->type == REDIS_REPLY_ARRAY); parent->element[task->idx] = r; } @@ -136,7 +136,7 @@ static void *createIntegerObject(const redisReadTask *task, long long value) { redisReply *r = createReplyObject(REDIS_REPLY_INTEGER); r->integer = value; if (task->parent) { - redisReply *parent = task->parent; + redisReply *parent = task->parent->obj; assert(parent->type == REDIS_REPLY_ARRAY); parent->element[task->idx] = r; } @@ -146,7 +146,7 @@ static void *createIntegerObject(const redisReadTask *task, long long value) { static void *createNilObject(const redisReadTask *task) { redisReply *r = createReplyObject(REDIS_REPLY_NIL); if (task->parent) { - redisReply *parent = task->parent; + redisReply *parent = task->parent->obj; assert(parent->type == REDIS_REPLY_ARRAY); parent->element[task->idx] = r; } @@ -316,12 +316,13 @@ static int processMultiBulkItem(redisReader *r) { /* Modify task stack when there are more than 0 elements. */ if (elements > 0) { cur->elements = elements; + cur->obj = obj; r->ridx++; r->rstack[r->ridx].type = -1; r->rstack[r->ridx].elements = -1; - r->rstack[r->ridx].parent = obj; - r->rstack[r->ridx].parentTask = cur; r->rstack[r->ridx].idx = 0; + r->rstack[r->ridx].obj = NULL; + r->rstack[r->ridx].parent = cur; r->rstack[r->ridx].privdata = r->privdata; } else { moveToNextTask(r); @@ -478,8 +479,9 @@ int redisReplyReaderGetReply(void *reader, void **reply) { if (r->ridx == -1) { r->rstack[0].type = -1; r->rstack[0].elements = -1; - r->rstack[0].parent = r->rstack[0].parentTask = NULL; r->rstack[0].idx = -1; + r->rstack[0].obj = NULL; + r->rstack[0].parent = NULL; r->rstack[0].privdata = r->privdata; r->ridx = 0; } @@ -86,9 +86,9 @@ typedef struct redisReply { typedef struct redisReadTask { int type; int elements; /* number of elements in multibulk container */ - void *parent; /* optional pointer to parent object */ int idx; /* index in parent (array) object */ - struct redisReadTask *parentTask; /* pointer to parent task */ + void *obj; /* holds user-generated value for a read task */ + struct redisReadTask *parent; /* parent task */ void *privdata; /* user-settable arbitrary field */ } redisReadTask; |