Bladeren bron

Vlib: fix memory leak

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@63512 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 10 jaren geleden
bovenliggende
commit
95d295b455
1 gewijzigde bestanden met toevoegingen van 6 en 4 verwijderingen
  1. 6 4
      lib/vector/Vlib/write_nat.c

+ 6 - 4
lib/vector/Vlib/write_nat.c

@@ -113,8 +113,8 @@ off_t V1_rewrite_line_nat(struct Map_info *Map, int line, int type, off_t offset
 			  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 @@ off_t V1_rewrite_line_nat(struct Map_info *Map, int line, int type, off_t offset
     /* 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)