From f3357792408fd28002847586a27f9043e08a4e2c Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 16 Sep 2010 11:59:53 +0200 Subject: [PATCH] Static buffer in client struct has a constant size --- src/networking.c | 8 ++------ src/redis.h | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/networking.c b/src/networking.c index 55b7475b4..26a6a4c04 100644 --- a/src/networking.c +++ b/src/networking.c @@ -11,11 +11,7 @@ int listMatchObjects(void *a, void *b) { } redisClient *createClient(int fd) { - redisClient *c; - - /* Allocate more space to hold a static write buffer. */ - c = zmalloc(sizeof(redisClient)+REDIS_REPLY_CHUNK_BYTES); - c->buflen = REDIS_REPLY_CHUNK_BYTES; + redisClient *c = zmalloc(sizeof(redisClient)); c->bufpos = 0; anetNonBlock(NULL,fd); @@ -84,7 +80,7 @@ robj *dupLastObjectIfNeeded(list *reply) { } int _addReplyToBuffer(redisClient *c, char *s, size_t len) { - size_t available = c->buflen-c->bufpos; + size_t available = sizeof(c->buf)-c->bufpos; /* If there already are entries in the reply list, we cannot * add anything more to the static buffer. */ diff --git a/src/redis.h b/src/redis.h index 1ef562887..38727ae20 100644 --- a/src/redis.h +++ b/src/redis.h @@ -313,8 +313,7 @@ typedef struct redisClient { /* Response buffer */ int bufpos; - int buflen; - char buf[]; + char buf[REDIS_REPLY_CHUNK_BYTES]; } redisClient; struct saveparam { -- GitLab