* 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
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
#include <glib.h>
+#ifdef HAVE_MATH_H
#include <math.h>
+#endif
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
+#endif
#include <zlib.h>
#include <sys/types.h>
#include <sys/stat.h>
gint num_rows;
GMappedFile *mf;
gint arcsec;
+ GError *error = NULL;
dem = g_malloc(sizeof(VikDEM));
dem->columns = g_ptr_array_new();
dem->n_columns = 0;
- if ((mf = g_mapped_file_new(file_name, FALSE, NULL)) == NULL) {
- g_error("%s(): couldn't map temp file\n", __PRETTY_FUNCTION__);
+ if ((mf = g_mapped_file_new(file_name, FALSE, &error)) == NULL) {
+ g_error(_("Couldn't map file %s: %s"), file_name, error->message);
+ g_error_free(error);
g_free(dem);
return NULL;
}
/* Header */
f = g_fopen(file, "r");
- if ( !f )
+ if ( !f ) {
+ g_free ( rv );
return NULL;
+ }
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 */