changeset 1509:15afe578f0ae

Add few comments to clarify things.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 May 2018 22:22:40 +0300
parents 97b8096f16dc
children 7bbf4b41fc33
files src/dmgrowbuf.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)