Przeglądaj źródła

r.to.vect: fix memory leak

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57281 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 11 lat temu
rodzic
commit
3dc35b9071
1 zmienionych plików z 10 dodań i 2 usunięć
  1. 10 2
      raster/r.to.vect/areas_io.c

+ 10 - 2
raster/r.to.vect/areas_io.c

@@ -84,12 +84,16 @@ static int write_bnd(struct COOR *line_begin, struct COOR *line_end,	/* start an
 		     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 @@ static int write_smooth_bnd(struct COOR *line_begin, struct COOR *line_end,	/* s
 			    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;