# HG changeset patch # User Matti Hamalainen # Date 1526066560 -10800 # Node ID 15afe578f0ae88585d4770f5983fb9592bafc3a9 # Parent 97b8096f16dc686bf06a54d6aa502d96e61b8f09 Add few comments to clarify things. diff -r 97b8096f16dc -r 15afe578f0ae src/dmgrowbuf.c --- a/src/dmgrowbuf.c Fri May 11 22:22:23 2018 +0300 +++ b/src/dmgrowbuf.c Fri May 11 22:22:40 2018 +0300 @@ -30,6 +30,7 @@ buf->mingrow = mingrow; buf->allocated = FALSE; + // Allocate the data if ((buf->data = dmMalloc0(initial)) == NULL) return DMERR_MALLOC; @@ -72,6 +73,11 @@ } +// +// Grow the buffer by "amount" bytes, but at least by buf->mingrow, +// if there is not enough space for at least that amount compared to +// current buffer "len". +// BOOL dmGrowBufGrow(DMGrowBuf *buf, const size_t amount) { size_t grow = (amount > buf->mingrow) ? amount : buf->mingrow; @@ -89,6 +95,10 @@ } +// +// Grow the buffer if "nsize" is larger than the current buffer size. +// Buffer is enlarged to nsize + mingrow. +// BOOL dmGrowBufCheckGrow(DMGrowBuf *buf, const size_t nsize) { if (buf->data == NULL || nsize > buf->size)