vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 32fe7465729f0b87f33fec6ee746a09b6804e1d5 parent 18c7be777d15f17f8709b1ab6c6dd5767de5c4e4 Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 22 Dec 2016 09:25:07 +0100 buffer: make default buffer size overridable via C pre-processor Diffstat:
| M | buffer.c | | | 8 | +++++--- |
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/buffer.c b/buffer.c @@ -6,7 +6,9 @@ #include "buffer.h" #include "util.h" -#define BUF_SIZE 1024 +#ifndef BUFFER_SIZE +#define BUFFER_SIZE 1024 +#endif void buffer_init(Buffer *buf) { memset(buf, 0, sizeof *buf); @@ -14,8 +16,8 @@ void buffer_init(Buffer *buf) { bool buffer_grow(Buffer *buf, size_t size) { /* ensure minimal buffer size, to avoid repeated realloc(3) calls */ - if (size < BUF_SIZE) - size = BUF_SIZE; + if (size < BUFFER_SIZE) + size = BUFFER_SIZE; if (buf->size < size) { size = MAX(size, buf->size*2); char *data = realloc(buf->data, size);