X-Git-Url: https://git.distorted.org.uk/~mdw/dvdrip/blobdiff_plain/42c936a1884d40b6679ba9f7f80bf308c5fb1f7f..c62cd11a8bcfdacd01498ee08da82b2afa4b2f25:/lib.c diff --git a/lib.c b/lib.c index 25cc829..320f04d 100644 --- a/lib.c +++ b/lib.c @@ -98,7 +98,14 @@ long parse_int(const char **p_inout, unsigned f, return (x); } -/*----- Resizing arrays ---------------------------------------------------*/ +/*----- Resizing buffers and arrays ---------------------------------------*/ + +void buf__grow(struct buf *b) +{ + b->sz = b->sz ? 2*b->sz : 32; + b->p = realloc(b->p, b->sz); + if (!b->p) bail("out of memory allocating %zu bytes", b->sz); +} void *vec__grow(void *p, size_t esz, size_t *sz_inout) {