X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lib%2Fbuffer.c;h=7131cb60a69cc7ee2fca6b69e0646898831e9750;hp=e1327c8e04463e58b34ae232a4a17ed84bdb9435;hb=20392fc3c433909de76c676c235524acd96bec60;hpb=230399f9632c37b66c1c117a17e8327eae6b3235 diff --git a/lib-lib/buffer.c b/lib-lib/buffer.c index e1327c8..7131cb6 100644 --- a/lib-lib/buffer.c +++ b/lib-lib/buffer.c @@ -26,15 +26,23 @@ * please see the file GPL in the top level source directory. */ -#include -#include -#include +#include "lib-lib.h" -#include "mem.h" -#include "str.h" -#include "ascii.h" -#include "buffer.h" -#include "file.h" +#define BUFSIZ_INCREMENT 256 + +void buffer_resize(buffer_t *buf, ssize_t newsize) +{ + if (newsize >= buf->size) { + /* rounds newsize to the 1024 multiple just after newsize+1 */ + newsize = (newsize + BUFSIZ_INCREMENT) & ~(BUFSIZ_INCREMENT - 1); + p_realloc(&buf->data, newsize); + } +} + + + + +/****** LEGACY BUFFERS *******/ /* * Creates and initializes a BUFFER*. If passed an existing BUFFER*,