]> git.street.me.uk Git - andy/viking.git/blobdiff - src/dem.c
Fix usage of vvp in gpslayer in uploading TRW layer data.
[andy/viking.git] / src / dem.c
index c528b81738184621f761f34c2530a3e834210dd5..84c257e94cbf8e40af9fdc8d138b8da00d180bee 100644 (file)
--- a/src/dem.c
+++ b/src/dem.c
@@ -2,6 +2,7 @@
  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
  *
  * Copyright (C) 2003-2008, Evan Battaglia <gtoevan@gmx.net>
  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
  *
  * Copyright (C) 2003-2008, Evan Battaglia <gtoevan@gmx.net>
+ * Copyright (C) 2007, Quy Tonthat <qtonthat@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #endif
 
 #include <stdio.h>
 #endif
 
 #include <stdio.h>
+#ifdef HAVE_STRING_H
 #include <string.h>
 #include <string.h>
+#endif
 #include <glib.h>
 #include <glib.h>
+#ifdef HAVE_MATH_H
 #include <math.h>
 #include <math.h>
+#endif
+#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #include <stdlib.h>
+#endif
 #include <zlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <zlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -435,11 +442,14 @@ VikDEM *vik_dem_new_from_file(const gchar *file)
 
       /* Header */
   f = g_fopen(file, "r");
 
       /* Header */
   f = g_fopen(file, "r");
-  if ( !f )
+  if ( !f ) {
+    g_free ( rv );
     return NULL;
     return NULL;
+  }
   buffer[fread(buffer, 1, DEM_BLOCK_SIZE, f)] = '\0';
   if ( ! dem_parse_header ( buffer, rv ) ) {
     g_free ( rv );
   buffer[fread(buffer, 1, DEM_BLOCK_SIZE, f)] = '\0';
   if ( ! dem_parse_header ( buffer, rv ) ) {
     g_free ( rv );
+    fclose(f);
     return NULL;
   }
   /* TODO: actually use header -- i.e. GET # OF COLUMNS EXPECTED */
     return NULL;
   }
   /* TODO: actually use header -- i.e. GET # OF COLUMNS EXPECTED */