summaryrefslogtreecommitdiff
path: root/src/buf.c
diff options
context:
space:
mode:
authorWill Estes <westes575@gmail.com>2016-02-24 17:50:00 -0500
committerWill Estes <westes575@gmail.com>2016-02-24 17:50:00 -0500
commitd2a67ba6b76630610cffb292692b3ef4767274b4 (patch)
treeb24e82dcb24e39624100fb5a5d6e16996bb547f1 /src/buf.c
parentdcf0226b06289a468578ba9a68f67c73bbcdd7c7 (diff)
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.
Diffstat (limited to 'src/buf.c')
-rw-r--r--src/buf.c4
1 files 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