[GRASS-SVN] r63512 - grass/branches/releasebranch_7_0/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 12 11:54:20 PST 2014


Author: mmetz
Date: 2014-12-12 11:54:20 -0800 (Fri, 12 Dec 2014)
New Revision: 63512

Modified:
   grass/branches/releasebranch_7_0/lib/vector/Vlib/write_nat.c
Log:
Vlib: fix memory leak

Modified: grass/branches/releasebranch_7_0/lib/vector/Vlib/write_nat.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/vector/Vlib/write_nat.c	2014-12-12 19:27:06 UTC (rev 63511)
+++ grass/branches/releasebranch_7_0/lib/vector/Vlib/write_nat.c	2014-12-12 19:54:20 UTC (rev 63512)
@@ -113,8 +113,8 @@
 			  const struct line_pnts *points, const struct line_cats *cats)
 {
     int old_type;
-    struct line_pnts *old_points;
-    struct line_cats *old_cats;
+    static struct line_pnts *old_points = NULL;
+    static struct line_cats *old_cats = NULL;
     off_t new_offset;
     
     G_debug(3, "V1_rewrite_line_nat(): line = %d offset = %lu",
@@ -123,8 +123,10 @@
     /* TODO: enable points and cats == NULL  */
 
     /* First compare numbers of points and cats with tha old one */
-    old_points = Vect_new_line_struct();
-    old_cats = Vect_new_cats_struct();
+    if (!old_points) {
+	old_points = Vect_new_line_struct();
+	old_cats = Vect_new_cats_struct();
+    }
 
     old_type = V1_read_line_nat(Map, old_points, old_cats, offset);
     if (old_type == -1)



More information about the grass-commit mailing list