Mercurial > hg > dmlib
changeset 1459:1155f4bc4afc
More work on growbuf.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 10 May 2018 21:16:43 +0300 |
parents | b2dd6a72d162 |
children | 361cad3b8445 |
files | src/dmgrowbuf.c |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmgrowbuf.c Thu May 10 21:00:59 2018 +0300 +++ b/src/dmgrowbuf.c Thu May 10 21:16:43 2018 +0300 @@ -20,8 +20,10 @@ int dmGrowBufAlloc(DMGrowBuf *buf, const size_t initial, const size_t mingrow) { - if (buf == NULL) - return DMERR_NULLPTR; + int res; + + if ((res = dmGrowBufInit(buf)) != DMERR_OK) + return res; buf->len = 0; buf->size = initial; @@ -46,7 +48,11 @@ if ((res = dmGrowBufAlloc(*pbuf, initial, mingrow)) != DMERR_OK) { + // The "allocated" flag has not yet been set dmGrowBufFree(*pbuf); + + // .. thus free the allocated struct here + dmFreeR(pbuf); return res; }