lib.[ch], dvd-sector-copy.c: Publish the `buf' machinery as inline functions.
[dvdrip] / lib.c
diff --git a/lib.c b/lib.c
index 25cc829..320f04d 100644 (file)
--- 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)
 {