diff minijss/jssmod.c @ 1403:6aa0897265e8

Modernization cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 30 Oct 2017 18:15:11 +0200
parents b47109fce375
children cedb5ca1533b
line wrap: on
line diff
--- a/minijss/jssmod.c	Mon Oct 30 18:12:38 2017 +0200
+++ b/minijss/jssmod.c	Mon Oct 30 18:15:11 2017 +0200
@@ -232,12 +232,11 @@
  */
 int jssConvertModuleForPlaying(JSSModule *module)
 {
-    int i;
     if (module == NULL)
         return DMERR_NULLPTR;
 
     // Convert instruments
-    for (i = 0; i < module->ninstruments; i++)
+    for (int i = 0; i < module->ninstruments; i++)
     {
         JSSInstrument *inst = module->instruments[i];
         if (inst != NULL && inst->data != NULL)
@@ -267,7 +266,6 @@
  */
 JSSModule *jssAllocateModule(void)
 {
-    int i;
     JSSModule *module;
 
     // Allocate module structure
@@ -276,10 +274,10 @@
         return NULL;
 
     // Initialize structure
-    for (i = 0; i < jsetNChannels; i++)
+    for (int i = 0; i < jsetNChannels; i++)
         module->defPanning[i] = jchPanMiddle;
 
-    for (i = 0; i < jsetMaxOrders; i++)
+    for (int i = 0; i < jsetMaxOrders; i++)
         module->orderList[i] = jsetOrderEnd;
 
     // Allocate mutex
@@ -296,8 +294,6 @@
  */
 int jssFreeModule(JSSModule * module)
 {
-    int i;
-
     if (module == NULL)
         return DMERR_NULLPTR;
 
@@ -308,18 +304,18 @@
 #endif
 
     // Free patterns
-    for (i = 0; i < module->npatterns; i++)
+    for (int i = 0; i < module->npatterns; i++)
         jssFreePattern(module->patterns[i]);
 
     // Free the "empty" pattern
     jssFreePattern(module->patterns[jsetMaxPatterns]);
 
     // Free instruments
-    for (i = 0; i < module->ninstruments; i++)
+    for (int i = 0; i < module->ninstruments; i++)
         jssFreeInstrument(module->instruments[i]);
 
     // Free extended instruments
-    for (i = 0; i < module->nextInstruments; i++)
+    for (int i = 0; i < module->nextInstruments; i++)
         jssFreeExtInstrument(module->extInstruments[i]);
 
     // Free mutex
@@ -339,7 +335,6 @@
  */
 JSSPattern *jssAllocatePattern(const int nrows, const int nchannels)
 {
-    int row, chn;
     JSSPattern *pattern;
     JSSNote *pnote;
 
@@ -365,15 +360,13 @@
     pattern->nchannels = nchannels;
 
     pnote = pattern->data;
-    for (row = 0; row < nrows; row++)
+    for (int row = 0; row < nrows; row++)
+    for (int chn = 0; chn < nchannels; chn++)
     {
-        for (chn = 0; chn < nchannels; chn++)
-        {
-            pnote->note = pnote->instrument = pnote->volume =
-                pnote->effect = pnote->param = jsetNotSet;
+        pnote->note = pnote->instrument = pnote->volume =
+            pnote->effect = pnote->param = jsetNotSet;
 
-            pnote++;
-        }
+        pnote++;
     }
 
     return pattern;
@@ -421,7 +414,6 @@
  */
 JSSExtInstrument *jssAllocateExtInstrument(void)
 {
-    int i;
     JSSExtInstrument *inst;
 
     // Allocate a instrument structure
@@ -429,7 +421,7 @@
         return NULL;
 
     // Initialize the requisite fields
-    for (i = 0; i < jsetNNotes; i++)
+    for (int i = 0; i < jsetNNotes; i++)
         inst->sNumForNotes[i] = jsetNotSet;
 
     return inst;