preliminary work for the configuration parser.
[apps/madmutt.git] / lib-lib / buffer.c
index f186bfd..b442721 100644 (file)
 
 #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.