Individual reply object functions may be NULL
This commit is contained in:
parent
b4f85484ea
commit
921150fc8a
39
hiredis.c
39
hiredis.c
@ -271,14 +271,17 @@ static int processLineItem(redisReader *r) {
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
if ((p = readLine(r,&len)) != NULL) {
|
if ((p = readLine(r,&len)) != NULL) {
|
||||||
if (r->fn) {
|
if (cur->type == REDIS_REPLY_INTEGER) {
|
||||||
if (cur->type == REDIS_REPLY_INTEGER) {
|
if (r->fn && r->fn->createInteger)
|
||||||
obj = r->fn->createInteger(cur,readLongLong(p));
|
obj = r->fn->createInteger(cur,readLongLong(p));
|
||||||
} else {
|
else
|
||||||
obj = r->fn->createString(cur,p,len);
|
obj = (void*)REDIS_REPLY_INTEGER;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
obj = (void*)(size_t)(cur->type);
|
/* Type will be error or status. */
|
||||||
|
if (r->fn && r->fn->createString)
|
||||||
|
obj = r->fn->createString(cur,p,len);
|
||||||
|
else
|
||||||
|
obj = (void*)(size_t)(cur->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set reply if this is the root object. */
|
/* Set reply if this is the root object. */
|
||||||
@ -306,15 +309,19 @@ static int processBulkItem(redisReader *r) {
|
|||||||
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
/* The nil object can always be created. */
|
/* The nil object can always be created. */
|
||||||
obj = r->fn ? r->fn->createNil(cur) :
|
if (r->fn && r->fn->createNil)
|
||||||
(void*)REDIS_REPLY_NIL;
|
obj = r->fn->createNil(cur);
|
||||||
|
else
|
||||||
|
obj = (void*)REDIS_REPLY_NIL;
|
||||||
success = 1;
|
success = 1;
|
||||||
} else {
|
} else {
|
||||||
/* Only continue when the buffer contains the entire bulk item. */
|
/* Only continue when the buffer contains the entire bulk item. */
|
||||||
bytelen += len+2; /* include \r\n */
|
bytelen += len+2; /* include \r\n */
|
||||||
if (r->pos+bytelen <= r->len) {
|
if (r->pos+bytelen <= r->len) {
|
||||||
obj = r->fn ? r->fn->createString(cur,s+2,len) :
|
if (r->fn && r->fn->createString)
|
||||||
(void*)REDIS_REPLY_STRING;
|
obj = r->fn->createString(cur,s+2,len);
|
||||||
|
else
|
||||||
|
obj = (void*)REDIS_REPLY_STRING;
|
||||||
success = 1;
|
success = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,12 +358,16 @@ static int processMultiBulkItem(redisReader *r) {
|
|||||||
root = (r->ridx == 0);
|
root = (r->ridx == 0);
|
||||||
|
|
||||||
if (elements == -1) {
|
if (elements == -1) {
|
||||||
obj = r->fn ? r->fn->createNil(cur) :
|
if (r->fn && r->fn->createNil)
|
||||||
(void*)REDIS_REPLY_NIL;
|
obj = r->fn->createNil(cur);
|
||||||
|
else
|
||||||
|
obj = (void*)REDIS_REPLY_NIL;
|
||||||
moveToNextTask(r);
|
moveToNextTask(r);
|
||||||
} else {
|
} else {
|
||||||
obj = r->fn ? r->fn->createArray(cur,elements) :
|
if (r->fn && r->fn->createArray)
|
||||||
(void*)REDIS_REPLY_ARRAY;
|
obj = r->fn->createArray(cur,elements);
|
||||||
|
else
|
||||||
|
obj = (void*)REDIS_REPLY_ARRAY;
|
||||||
|
|
||||||
/* Modify task stack when there are more than 0 elements. */
|
/* Modify task stack when there are more than 0 elements. */
|
||||||
if (elements > 0) {
|
if (elements > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user