changeset 1213:505317227ab4

Rename variable, improve two error messages.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Mar 2015 23:12:37 +0200
parents 1483b6af6065
children 1133dffe3713
files minijss/jloadjss.c
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/minijss/jloadjss.c	Thu Mar 05 22:23:51 2015 +0200
+++ b/minijss/jloadjss.c	Thu Mar 05 23:12:37 2015 +0200
@@ -494,26 +494,23 @@
         if (inst && inst->hasData)
         {
             int ret;
-            size_t sz;
-
-            // Calculate data size
-            if (inst->flags & jsf16bit)
-                sz = inst->size * sizeof(Uint16);
-            else
-                sz = inst->size * sizeof(Uint8);
+            size_t bsize = (inst->flags & jsf16bit) ? sizeof(Uint16) : sizeof(Uint8);
+            bsize *= inst->size;
 
             // Allocate
-            if ((inst->data = dmMalloc(sz)) == NULL)
+            if ((inst->data = dmMalloc(bsize)) == NULL)
             {
                 JSSERROR(DMERR_MALLOC, DMERR_MALLOC,
-                "Could not allocate sample data #%d\n", index);
+                "Could not allocate %d bytes of sample data #%d\n",
+                bsize, index);
             }
 
             // Copy data
-            if (!dmf_read_str(inFile, inst->data, sz))
+            if (!dmf_read_str(inFile, inst->data, bsize))
             {
                 JSSERROR(DMERR_FREAD, DMERR_FREAD,
-                "Could not read sample data for #%d\n", index);
+                "Could not read %d bytes of sample data for #%d\n",
+                bsize, index);
             }
 
             // Convert, if needed