浏览代码

r3.flow: fix pointers freeing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@62255 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 10 年之前
父节点
当前提交
26c54d7f71
共有 3 个文件被更改,包括 7 次插入7 次删除
  1. 1 1
      raster3d/r3.flow/flowline.c
  2. 5 5
      raster3d/r3.flow/voxel_traversal.c
  3. 1 1
      raster3d/r3.flow/voxel_traversal.h

+ 1 - 1
raster3d/r3.flow/flowline.c

@@ -182,7 +182,7 @@ void compute_flowline(RASTER3D_Region * region, const struct Seed *seed,
 		    /* if not run for the 1. time and previous and next point coordinates
 		       differ by more than 1 voxel coordinate */
 		    if (coor_diff > 1) {
-			traverse(region, point, new_point, trav_coords, &size,
+			traverse(region, point, new_point, &trav_coords, &size,
 				 &trav_count);
 			for (j = 0; j < trav_count; j++) {
 			    value =

+ 5 - 5
raster3d/r3.flow/voxel_traversal.c

@@ -4,7 +4,7 @@
 #include "voxel_traversal.h"
 
 void traverse(RASTER3D_Region * region, double *start, double *end,
-	      int *coordinates, int *size, int *coor_count)
+	      int **coordinates, int *size, int *coor_count)
 {
     double dx, dy, dz;
     int step_x, step_y, step_z;
@@ -81,15 +81,15 @@ void traverse(RASTER3D_Region * region, double *start, double *end,
 
 	    break;
 
-	coordinates[count * 3 + 0] = x;
-	coordinates[count * 3 + 1] = region->rows - y - 1;
-	coordinates[count * 3 + 2] = z;
+	(*coordinates)[count * 3 + 0] = x;
+	(*coordinates)[count * 3 + 1] = region->rows - y - 1;
+	(*coordinates)[count * 3 + 2] = z;
 	count++;
 
 	/* reallocation for cases when the steps would be too big */
 	if (*size <= count) {
 	    *size = 2 * (*size);
-	    coordinates = G_realloc(coordinates, (*size) * 3 * sizeof(int));
+	    *coordinates = G_realloc(*coordinates, (*size) * 3 * sizeof(int));
 	}
     }
     *coor_count = count;

+ 1 - 1
raster3d/r3.flow/voxel_traversal.h

@@ -4,6 +4,6 @@
 #include <grass/raster3d.h>
 
 void traverse(RASTER3D_Region *region, double *start, double *end,
-              int *coordinates, int *size, int *coor_count);
+              int **coordinates, int *size, int *coor_count);
 
 #endif // VOXEL_TRAVERSAL_H