changeset 1694:e568535e1a96

Backed out changeset 9611ecd2c4fb
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Jun 2018 11:03:17 +0300
parents ce8d4552ffd5
children ce3e56cfa9b9
files src/dmgrowbuf.c src/dmgrowbuf.h tools/gfxconv.c
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/dmgrowbuf.c	Tue Jun 05 09:52:53 2018 +0300
+++ b/src/dmgrowbuf.c	Tue Jun 05 11:03:17 2018 +0300
@@ -15,16 +15,29 @@
 #endif
 
 
-int dmGrowBufAlloc(DMGrowBuf *buf, const size_t initial, const size_t mingrow)
+int dmGrowBufInit(DMGrowBuf *buf)
 {
-    DM_DBG("dmGrowBufAlloc(%p, %" DM_PRIu_SIZE_T ", %" DM_PRIu_SIZE_T ")\n",
-        buf, initial, mingrow);
+    DM_DBG("dmGrowBufInit(%p)\n", buf);
 
     if (buf == NULL)
         return DMERR_NULLPTR;
 
     memset(buf, 0, sizeof(DMGrowBuf));
 
+    return DMERR_OK;
+}
+
+
+int dmGrowBufAlloc(DMGrowBuf *buf, const size_t initial, const size_t mingrow)
+{
+    int res;
+
+    DM_DBG("dmGrowBufAlloc(%p, %" DM_PRIu_SIZE_T ", %" DM_PRIu_SIZE_T ")\n",
+        buf, initial, mingrow);
+
+    if ((res = dmGrowBufInit(buf)) != DMERR_OK)
+        return res;
+
     buf->len  = 0;
     buf->offs = 0;
     buf->size = initial;
--- a/src/dmgrowbuf.h	Tue Jun 05 09:52:53 2018 +0300
+++ b/src/dmgrowbuf.h	Tue Jun 05 11:03:17 2018 +0300
@@ -25,6 +25,7 @@
 } DMGrowBuf;
 
 
+int    dmGrowBufInit(DMGrowBuf *buf);
 int    dmGrowBufAlloc(DMGrowBuf *buf, const size_t initial, const size_t mingrow);
 int    dmGrowBufNew(DMGrowBuf **pbuf, const size_t initial, const size_t mingrow);
 void   dmGrowBufFree(DMGrowBuf *buf);
--- a/tools/gfxconv.c	Tue Jun 05 09:52:53 2018 +0300
+++ b/tools/gfxconv.c	Tue Jun 05 11:03:17 2018 +0300
@@ -1058,6 +1058,8 @@
     int res = DMERR_OK;
     DMGrowBuf buf;
 
+    dmGrowBufInit(&buf);
+
     // Encode to target format
     dmMsg(1, "Encoding C64 bitmap data to format '%s'\n", fmt->name);
     if ((res = dmC64EncodeBMP(&buf, image, fmt)) != DMERR_OK)