changeset 1510:8efe8ad78f3b

Various cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 07 Feb 2015 06:35:42 +0200
parents 7eeae6b4bce0
children 7082f8b41042
files colormap.c
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/colormap.c	Sat Feb 07 06:35:34 2015 +0200
+++ b/colormap.c	Sat Feb 07 06:35:42 2015 +0200
@@ -645,7 +645,8 @@
 {
     if (!srcFilename)
         srcFilename = currArg;
-    else {
+    else
+    {
         THERR("Too many input map files specified!\n");
         return FALSE;
     }
@@ -658,7 +659,7 @@
  */
 int main(int argc, char *argv[])
 {
-    FILE *inFile, *outFile;
+    FILE *inFile = NULL, *outFile = NULL;
     CMapOutFormat *fmt = NULL;
 
     /* Initialize */
@@ -756,7 +757,7 @@
     {
         THERR("Error opening input file '%s'!\n",
             srcFilename);
-        exit(1);
+        goto out;
     }
     
     /* Open output file */
@@ -767,7 +768,7 @@
     {
         THERR("Error opening output file '%s'!\n",
             destFilename);
-        exit(1);
+        goto out;
     }
 
     /* Okay, let's process the shit */
@@ -782,8 +783,12 @@
     if (!optNoHeaders && fmt->putFileEnd)
         fmt->putFileEnd(outFile);
 
-    fclose(outFile);
-    fclose(inFile);
+out:
+    if (outFile != NULL)
+        fclose(outFile);
+
+    if (inFile != NULL)
+        fclose(inFile);
     
     THMSG(1, "Done.\n");