From d2a67ba6b76630610cffb292692b3ef4767274b4 Mon Sep 17 00:00:00 2001 From: Will Estes Date: Wed, 24 Feb 2016 17:50:00 -0500 Subject: Fixed size of bufferallocation, resolved gh#54. The value of n_alloc was a count, not a size. Multiplying the value by the element size was incorrect. That multiplication was already being done and having it done twice was incorrect. --- src/buf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/buf.c b/src/buf.c index f216b6d..5cfce60 100644 --- a/src/buf.c +++ b/src/buf.c @@ -237,8 +237,8 @@ struct Buf *buf_append (struct Buf *buf, const void *ptr, int n_elem) /* May need to alloc more. */ if (n_elem + buf->nelts > buf->nmax) { - /* exact amount needed... */ - n_alloc = (n_elem + buf->nelts) * buf->elt_size; + /* exact count needed... */ + n_alloc = n_elem + buf->nelts; /* ...plus some extra */ if (((n_alloc * buf->elt_size) % 512) != 0 -- cgit v1.2.3