[MEDIUM] replace BUFSIZE with buf->size in computations
The first step towards dynamic buffer size consists in removing
all static definitions of the buffer size. Instead, we store a
buffer's size in itself. Right now they're all preinitialized
to BUFSIZE, but we will change that.
diff --git a/src/buffers.c b/src/buffers.c
index c8681cf..55b7963 100644
--- a/src/buffers.c
+++ b/src/buffers.c
@@ -24,7 +24,7 @@
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
int init_buffer()
{
- pool2_buffer = create_pool("buffer", sizeof(struct buffer), MEM_F_SHARED);
+ pool2_buffer = create_pool("buffer", sizeof(struct buffer) + BUFSIZE, MEM_F_SHARED);
return pool2_buffer != NULL;
}
@@ -48,7 +48,7 @@
buf->send_max += len;
buf->r += len;
buf->total += len;
- if (buf->r == buf->data + BUFSIZE)
+ if (buf->r == buf->data + buf->size)
buf->r = buf->data;
buf->flags &= ~(BF_EMPTY|BF_FULL);
@@ -82,7 +82,7 @@
buf->send_max += chunk->len;
buf->r += chunk->len;
buf->total += chunk->len;
- if (buf->r == buf->data + BUFSIZE)
+ if (buf->r == buf->data + buf->size)
buf->r = buf->data;
buf->flags &= ~(BF_EMPTY|BF_FULL);
@@ -111,7 +111,7 @@
len = strlen(str);
delta = len - (end - pos);
- if (delta + b->r >= b->data + BUFSIZE)
+ if (delta + b->r >= b->data + b->size)
return 0; /* no space left */
/* first, protect the end of the buffer */
@@ -145,7 +145,7 @@
delta = len - (end - pos);
- if (delta + b->r >= b->data + BUFSIZE)
+ if (delta + b->r >= b->data + b->size)
return 0; /* no space left */
if (b->data + b->l < end) {
@@ -192,7 +192,7 @@
delta = len + 2;
- if (delta + b->r >= b->data + BUFSIZE)
+ if (delta + b->r >= b->data + b->size)
return 0; /* no space left */
/* first, protect the end of the buffer */