changeset 2444:fd31b5d1ed5e

Add few comments.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 09 Mar 2020 22:29:29 +0200
parents d18fd4866650
children fa089a430121
files src/dmres.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmres.c	Tue Mar 03 14:31:14 2020 +0200
+++ b/src/dmres.c	Mon Mar 09 22:29:29 2020 +0200
@@ -569,15 +569,18 @@
 {
     size_t grow;
 
+    // Check against max size
     if (ctx->maxSize > 0 && newSize > ctx->maxSize)
     {
         ctx->error = DMERR_BOUNDS;
         return FALSE;
     }
 
+    // New size is smaller than old
     if (newSize < ctx->memAlloc)
-        return TRUE;
+        goto out;
 
+    // Compute the allocation grow amount
     grow = (ctx->minAlloc > 0) ? ctx->minAlloc : 8 * 1024;
     if (newSize - ctx->memAlloc > grow)
         grow += newSize - ctx->memAlloc;
@@ -588,6 +591,7 @@
         return FALSE;
     }
 
+    // Grow the buffer
     ctx->memAlloc += grow;
     if ((ctx->memData = dmRealloc(ctx->memData, ctx->memAlloc)) == NULL)
     {
@@ -595,6 +599,7 @@
         return FALSE;
     }
 
+out:
     ctx->memSize = newSize;
 
     return TRUE;