X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lib%2Fbuffer.c;h=b442721d480d76d04fe6fa0ea038d7250ea6b7b1;hp=f186bfdf29c11f958907107b749047d273f01560;hb=aed03232cc25bcb1104a17c631924b867659944c;hpb=1ee89902de184a640c171ae3285bff6882a791bd diff --git a/lib-lib/buffer.c b/lib-lib/buffer.c index f186bfd..b442721 100644 --- a/lib-lib/buffer.c +++ b/lib-lib/buffer.c @@ -28,6 +28,22 @@ #include "lib-lib.h" +#define BUFSIZ_INCREMENT 1024 + +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*, * just initializes. Frees anything already in the buffer.