提交 f3357792 编写于 作者: P Pieter Noordhuis

Static buffer in client struct has a constant size

上级 9e83ac06
...@@ -11,11 +11,7 @@ int listMatchObjects(void *a, void *b) { ...@@ -11,11 +11,7 @@ int listMatchObjects(void *a, void *b) {
} }
redisClient *createClient(int fd) { redisClient *createClient(int fd) {
redisClient *c; redisClient *c = zmalloc(sizeof(redisClient));
/* Allocate more space to hold a static write buffer. */
c = zmalloc(sizeof(redisClient)+REDIS_REPLY_CHUNK_BYTES);
c->buflen = REDIS_REPLY_CHUNK_BYTES;
c->bufpos = 0; c->bufpos = 0;
anetNonBlock(NULL,fd); anetNonBlock(NULL,fd);
...@@ -84,7 +80,7 @@ robj *dupLastObjectIfNeeded(list *reply) { ...@@ -84,7 +80,7 @@ robj *dupLastObjectIfNeeded(list *reply) {
} }
int _addReplyToBuffer(redisClient *c, char *s, size_t len) { 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 /* If there already are entries in the reply list, we cannot
* add anything more to the static buffer. */ * add anything more to the static buffer. */
......
...@@ -313,8 +313,7 @@ typedef struct redisClient { ...@@ -313,8 +313,7 @@ typedef struct redisClient {
/* Response buffer */ /* Response buffer */
int bufpos; int bufpos;
int buflen; char buf[REDIS_REPLY_CHUNK_BYTES];
char buf[];
} redisClient; } redisClient;
struct saveparam { struct saveparam {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册