X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common%2Fbuffer.h;h=c6c11c6a63abdfa6ff0ef716a1d572699505f7c7;hb=d39a00392903e1a3f029ec9533abf9f11835ffd3;hp=24bc590cd0aafa8b35967e425d69cebc2cbcfe4e;hpb=8977d252fc44ae953df4bde4a2f1c5895beea4e0;p=apps%2Fpfixtools.git diff --git a/common/buffer.h b/common/buffer.h index 24bc590..c6c11c6 100644 --- a/common/buffer.h +++ b/common/buffer.h @@ -39,12 +39,9 @@ #include #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} @@ -66,8 +63,9 @@ static inline char *buffer_unwrap(buffer_t **buf) { 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) {