[GRASS-SVN] r57281 - grass/trunk/raster/r.to.vect

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 26 06:36:06 PDT 2013


Author: mmetz
Date: 2013-07-26 06:36:03 -0700 (Fri, 26 Jul 2013)
New Revision: 57281

Modified:
   grass/trunk/raster/r.to.vect/areas_io.c
Log:
r.to.vect: fix memory leak

Modified: grass/trunk/raster/r.to.vect/areas_io.c
===================================================================
--- grass/trunk/raster/r.to.vect/areas_io.c	2013-07-26 11:49:00 UTC (rev 57280)
+++ grass/trunk/raster/r.to.vect/areas_io.c	2013-07-26 13:36:03 UTC (rev 57281)
@@ -84,12 +84,16 @@
 		     int n	/* number of points to write */
     )
 {
-    struct line_pnts *points = Vect_new_line_struct();
+    static struct line_pnts *points = NULL;
     double x;
     double y;
     struct COOR *p, *last;
     int i;
 
+    if (!points)
+	points = Vect_new_line_struct();
+    Vect_reset_line(points);
+
     n++;			/* %% 6.4.88 */
 
     p = line_begin;
@@ -157,13 +161,17 @@
 			    int n	/* number of points to write */
     )
 {
-    struct line_pnts *points = Vect_new_line_struct();
+    static struct line_pnts *points = NULL;
     double x, y;
     double dx, dy;
     int idx, idy;
     struct COOR *p, *last;
     int i, total;
 
+    if (!points)
+	points = Vect_new_line_struct();
+    Vect_reset_line(points);
+
     n++;			/* %% 6.4.88 */
 
     p = line_begin;



More information about the grass-commit mailing list