# HG changeset patch # User Matti Hamalainen # Date 1558654167 -10800 # Node ID 510ea816d1ff226741890780c1029b8e430330dd # Parent 5f8f170f8774eac30934986de66d6c6a18773ece Add helper function dmC64MemBlockAllocSubj(). diff -r 5f8f170f8774 -r 510ea816d1ff tools/lib64gfx.c --- 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) diff -r 5f8f170f8774 -r 510ea816d1ff tools/lib64gfx.h --- 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);