[GRASS-SVN] r66610 - grass/trunk/raster/r.in.lidar

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 26 18:26:58 PDT 2015


Author: wenzeslaus
Date: 2015-10-26 18:26:58 -0700 (Mon, 26 Oct 2015)
New Revision: 66610

Modified:
   grass/trunk/raster/r.in.lidar/main.c
   grass/trunk/raster/r.in.lidar/string_list.c
Log:
r.in.lidar: move clean of list of files (fixes r66601)

List of files dealloc at the end, not inside the loops.
Also use standard library for string copy instead of
custom code marked by valgrind as wrong.

Change done message to tell more.


Modified: grass/trunk/raster/r.in.lidar/main.c
===================================================================
--- grass/trunk/raster/r.in.lidar/main.c	2015-10-26 15:50:08 UTC (rev 66609)
+++ grass/trunk/raster/r.in.lidar/main.c	2015-10-27 01:26:58 UTC (rev 66610)
@@ -611,7 +611,6 @@
 
 	/* free memory */
 	point_binning_free(&point_binning, &bin_index_nodes);
-    string_list_free(&infiles);
     }				/* passes loop */
     if (base_array)
         Rast_close(base_raster);
@@ -633,11 +632,22 @@
     Rast_set_history(&history, HIST_DATSRC_1, infile);
     Rast_write_history(outmap, &history);
 
+    if (infiles.num_items > 1) {
+        sprintf(buff, _("Raster map <%s> created."
+                        " %lu points from %d files found in region."),
+                outmap, count_total, infiles.num_items);
+    }
+    else {
+        sprintf(buff, _("Raster map <%s> created."
+                        " %lu points found in region."),
+                outmap, count_total);
+    }
 
-    sprintf(buff, _("%lu points found in region."), count_total);
     G_done_msg("%s", buff);
     G_debug(1, "Processed %lu points.", line_total);
 
+    string_list_free(&infiles);
+
     exit(EXIT_SUCCESS);
 
 }

Modified: grass/trunk/raster/r.in.lidar/string_list.c
===================================================================
--- grass/trunk/raster/r.in.lidar/string_list.c	2015-10-26 15:50:08 UTC (rev 66609)
+++ grass/trunk/raster/r.in.lidar/string_list.c	2015-10-27 01:26:58 UTC (rev 66610)
@@ -46,10 +46,7 @@
     string_list->num_items = 0;
     string_list->max_items = 0;
     string_list->items = NULL;
-    char *new_item = G_malloc(strlen(item) * sizeof(char));
-
-    strcpy(new_item, item);
-    string_list_add_item(string_list, new_item);
+    string_list_add_item(string_list, strdup(item));
 }
 
 void string_list_free(struct StringList *string_list)



More information about the grass-commit mailing list