summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-04 13:26:45 +0100
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-04 13:26:45 +0100
commit183220bf6002d904813468e7396d36267b1496e3 (patch)
tree458935af6cd73e219a3945595b89f4fcbe8e1c4f
parent9c4ee606d6cd04648ae4e34d42847ea65818448f (diff)
Make moveToNextTask non-recursive
-rw-r--r--hiredis.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/hiredis.c b/hiredis.c
index 48ff7f9..66789d0 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -186,26 +186,26 @@ static char *readLine(redisReader *r, int *_len) {
static void moveToNextTask(redisReader *r) {
redisReadTask *cur, *prv;
- assert(r->ridx >= 0);
-
- /* Return a.s.a.p. when the stack is now empty. */
- if (r->ridx == 0) {
- r->ridx--;
- return;
- }
+ while (r->ridx >= 0) {
+ /* Return a.s.a.p. when the stack is now empty. */
+ if (r->ridx == 0) {
+ r->ridx--;
+ return;
+ }
- cur = &(r->rstack[r->ridx]);
- prv = &(r->rstack[r->ridx-1]);
- assert(prv->type == REDIS_REPLY_ARRAY);
- if (cur->idx == prv->elements-1) {
- r->ridx--;
- moveToNextTask(r);
- } else {
- /* Reset the type because the next item can be anything */
- assert(cur->idx < prv->elements);
- cur->type = -1;
- cur->elements = -1;
- cur->idx++;
+ cur = &(r->rstack[r->ridx]);
+ prv = &(r->rstack[r->ridx-1]);
+ assert(prv->type == REDIS_REPLY_ARRAY);
+ if (cur->idx == prv->elements-1) {
+ r->ridx--;
+ } else {
+ /* Reset the type because the next item can be anything */
+ assert(cur->idx < prv->elements);
+ cur->type = -1;
+ cur->elements = -1;
+ cur->idx++;
+ return;
+ }
}
}