#include <stdarg.h>
#include "mem.h"
#include "str.h"
+#include "array.h"
-typedef struct buffer_t {
- char *data;
- ssize_t len;
- ssize_t size;
-} buffer_t;
+typedef A(char) buffer_t;
#define BUFFER_INIT {NULL, 0, 0}
return res;
}
+#define buffer_resize(buffer, newsize) \
+ array_ensure_exact_capacity(*(buffer), (newsize) + 1)
-void buffer_resize(buffer_t *, ssize_t newsize);
static inline void buffer_ensure(buffer_t *buf, ssize_t extra) {
assert (extra >= 0);
if (buf->len + extra >= buf->size) {