changeset 2109:510ea816d1ff

Add helper function dmC64MemBlockAllocSubj().
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 24 May 2019 02:29:27 +0300
parents 5f8f170f8774
children 85f76ec15090
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Fri May 24 02:27:45 2019 +0300
+++ b/tools/lib64gfx.c	Fri May 24 02:29:27 2019 +0300
@@ -1465,6 +1465,24 @@
 }
 
 
+int dmC64MemBlockAllocSubj(DMC64Image *img, const int subject, const int bank)
+{
+    const char *subjname = dmC64GetOpSubjectName(subject);
+    size_t size = dmC64GetSubjectSize(subject, img->fmt);
+    DMC64MemBlock *blk = (DMC64MemBlock *) dmC64GetOpMemBlock(img, subject, bank);
+    int res;
+
+    if ((res = dmC64MemBlockAlloc(blk, size)) != DMERR_OK)
+    {
+        return dmError(res,
+            "Could not allocate '%s' block with size %d bytes.\n",
+            subjname, size);
+    }
+
+    return DMERR_OK;
+}
+
+
 // Convert a generic bitmap image to DMC64Image
 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src,
     const DMC64ImageFormat *fmt, const DMC64ImageConvSpec *spec)
--- a/tools/lib64gfx.h	Fri May 24 02:27:45 2019 +0300
+++ b/tools/lib64gfx.h	Fri May 24 02:29:27 2019 +0300
@@ -327,6 +327,7 @@
 const char *dmC64GetOpSubjectName(const int subject);
 const DMC64MemBlock * dmC64GetOpMemBlock(const DMC64Image *img, const int subject, const int bank);
 int       dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img);
+int      dmC64MemBlockAllocSubj(DMC64Image *img, const int subject, const int bank);
 
 size_t    dmC64GetSubjectSize(const int subject, const DMC64ImageCommonFormat *fmt);
 size_t    dmC64GetOpSubjectSize(const DMC64EncDecOp *op, const DMC64ImageCommonFormat *fmt);