The reply object functions may not change the read tasks
This commit is contained in:
parent
3f0394b8a9
commit
44a2d08b30
16
hiredis.c
16
hiredis.c
@ -52,10 +52,10 @@ typedef struct redisReader {
|
|||||||
} redisReader;
|
} redisReader;
|
||||||
|
|
||||||
static redisReply *createReplyObject(int type);
|
static redisReply *createReplyObject(int type);
|
||||||
static void *createStringObject(redisReadTask *task, char *str, size_t len);
|
static void *createStringObject(const redisReadTask *task, char *str, size_t len);
|
||||||
static void *createArrayObject(redisReadTask *task, int elements);
|
static void *createArrayObject(const redisReadTask *task, int elements);
|
||||||
static void *createIntegerObject(redisReadTask *task, long long value);
|
static void *createIntegerObject(const redisReadTask *task, long long value);
|
||||||
static void *createNilObject(redisReadTask *task);
|
static void *createNilObject(const redisReadTask *task);
|
||||||
static void redisSetReplyReaderError(redisReader *r, sds err);
|
static void redisSetReplyReaderError(redisReader *r, sds err);
|
||||||
|
|
||||||
/* Default set of functions to build the reply. */
|
/* Default set of functions to build the reply. */
|
||||||
@ -103,7 +103,7 @@ void freeReplyObject(void *reply) {
|
|||||||
free(r);
|
free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *createStringObject(redisReadTask *task, char *str, size_t len) {
|
static void *createStringObject(const redisReadTask *task, char *str, size_t len) {
|
||||||
redisReply *r = createReplyObject(task->type);
|
redisReply *r = createReplyObject(task->type);
|
||||||
char *value = malloc(len+1);
|
char *value = malloc(len+1);
|
||||||
if (!value) redisOOM();
|
if (!value) redisOOM();
|
||||||
@ -125,7 +125,7 @@ static void *createStringObject(redisReadTask *task, char *str, size_t len) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *createArrayObject(redisReadTask *task, int elements) {
|
static void *createArrayObject(const redisReadTask *task, int elements) {
|
||||||
redisReply *r = createReplyObject(REDIS_REPLY_ARRAY);
|
redisReply *r = createReplyObject(REDIS_REPLY_ARRAY);
|
||||||
r->elements = elements;
|
r->elements = elements;
|
||||||
if ((r->element = calloc(sizeof(redisReply*),elements)) == NULL)
|
if ((r->element = calloc(sizeof(redisReply*),elements)) == NULL)
|
||||||
@ -138,7 +138,7 @@ static void *createArrayObject(redisReadTask *task, int elements) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *createIntegerObject(redisReadTask *task, long long value) {
|
static void *createIntegerObject(const redisReadTask *task, long long value) {
|
||||||
redisReply *r = createReplyObject(REDIS_REPLY_INTEGER);
|
redisReply *r = createReplyObject(REDIS_REPLY_INTEGER);
|
||||||
r->integer = value;
|
r->integer = value;
|
||||||
if (task->parent) {
|
if (task->parent) {
|
||||||
@ -149,7 +149,7 @@ static void *createIntegerObject(redisReadTask *task, long long value) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *createNilObject(redisReadTask *task) {
|
static void *createNilObject(const redisReadTask *task) {
|
||||||
redisReply *r = createReplyObject(REDIS_REPLY_NIL);
|
redisReply *r = createReplyObject(REDIS_REPLY_NIL);
|
||||||
if (task->parent) {
|
if (task->parent) {
|
||||||
redisReply *parent = task->parent;
|
redisReply *parent = task->parent;
|
||||||
|
@ -67,10 +67,10 @@ typedef struct redisReadTask {
|
|||||||
} redisReadTask;
|
} redisReadTask;
|
||||||
|
|
||||||
typedef struct redisReplyObjectFunctions {
|
typedef struct redisReplyObjectFunctions {
|
||||||
void *(*createString)(redisReadTask*, char*, size_t);
|
void *(*createString)(const redisReadTask*, char*, size_t);
|
||||||
void *(*createArray)(redisReadTask*, int);
|
void *(*createArray)(const redisReadTask*, int);
|
||||||
void *(*createInteger)(redisReadTask*, long long);
|
void *(*createInteger)(const redisReadTask*, long long);
|
||||||
void *(*createNil)(redisReadTask*);
|
void *(*createNil)(const redisReadTask*);
|
||||||
void (*freeObject)(void*);
|
void (*freeObject)(void*);
|
||||||
} redisReplyObjectFunctions;
|
} redisReplyObjectFunctions;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user