# HG changeset patch # User Matti Hamalainen # Date 1525976203 -10800 # Node ID 1155f4bc4afc8fb74c2f68910319564b0b52ca02 # Parent b2dd6a72d162751a46c3219ad753e74cd02ecb67 More work on growbuf. diff -r b2dd6a72d162 -r 1155f4bc4afc src/dmgrowbuf.c --- 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; }