]> git.saurik.com Git - redis.git/commitdiff
Static buffer in client struct has a constant size
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Thu, 16 Sep 2010 09:59:53 +0000 (11:59 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Thu, 16 Sep 2010 09:59:53 +0000 (11:59 +0200)
src/networking.c
src/redis.h

index 55b7475b4db0d70f9a65e319f642a3fc6e5f5751..26a6a4c0408d2df8d40eeaaad622e63620447c6c 100644 (file)
@@ -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. */
index 1ef5628872b771d0f79e0321658eb110b6c0b806..38727ae200d48493aaf2cac7420e3485eab18ed1 100644 (file)
@@ -313,8 +313,7 @@ typedef struct redisClient {
 
     /* Response buffer */
     int bufpos;
-    int buflen;
-    char buf[];
+    char buf[REDIS_REPLY_CHUNK_BYTES];
 } redisClient;
 
 struct saveparam {