[GRASS-SVN] r68378 - grass/branches/releasebranch_7_0/raster/r.volume

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 4 14:03:08 PDT 2016


Author: annakrat
Date: 2016-05-04 14:03:08 -0700 (Wed, 04 May 2016)
New Revision: 68378

Modified:
   grass/branches/releasebranch_7_0/raster/r.volume/centroids.c
   grass/branches/releasebranch_7_0/raster/r.volume/local_proto.h
   grass/branches/releasebranch_7_0/raster/r.volume/main.c
Log:
r.volume: change int type to prevent overflow, see #3004 (merge from trunk, r68376)

Modified: grass/branches/releasebranch_7_0/raster/r.volume/centroids.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.volume/centroids.c	2016-05-04 17:56:44 UTC (rev 68377)
+++ grass/branches/releasebranch_7_0/raster/r.volume/centroids.c	2016-05-04 21:03:08 UTC (rev 68378)
@@ -22,7 +22,7 @@
 int centroids(int fd,		/* File descriptor of map layer to process */
 	      /* This file is assumed to be opened before calling */
 	      /*   centroids. */
-	      int *e, int *n,	/* Pointers to arrays at least max+1 long */
+	      unsigned long *e, unsigned long *n,	/* Pointers to arrays at least max+1 long */
 	      int method,	/* 0, 1, or 2; see above. */
 	      int max)
 {				/* Highest positive cat number in map layer */

Modified: grass/branches/releasebranch_7_0/raster/r.volume/local_proto.h
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.volume/local_proto.h	2016-05-04 17:56:44 UTC (rev 68377)
+++ grass/branches/releasebranch_7_0/raster/r.volume/local_proto.h	2016-05-04 21:03:08 UTC (rev 68378)
@@ -1,3 +1,3 @@
 #define SEP "-----------------------------------------------------------------------------"
 
-int centroids(int, int *, int *, int, int);
+int centroids(int, unsigned long*, unsigned long*, int, int);

Modified: grass/branches/releasebranch_7_0/raster/r.volume/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.volume/main.c	2016-05-04 17:56:44 UTC (rev 68377)
+++ grass/branches/releasebranch_7_0/raster/r.volume/main.c	2016-05-04 21:03:08 UTC (rev 68378)
@@ -41,7 +41,8 @@
     CELL i, max;
 
     int row, col, rows, cols;
-    int out_mode, use_MASK, *n, *e;
+    int out_mode, use_MASK;
+    unsigned long *n, *e;
     long int *count;
     int fd_data, fd_clump;
 
@@ -216,8 +217,8 @@
     G_free(clump_buf);
 
     /* data lists for centroids of clumps */
-    e = (int *)G_malloc((max + 1) * sizeof(int));
-    n = (int *)G_malloc((max + 1) * sizeof(int));
+    e = (unsigned long*)G_malloc((max + 1) * sizeof(unsigned long));
+    n = (unsigned long*)G_malloc((max + 1) * sizeof(unsigned long));
 
     i = centroids(fd_clump, e, n, 1, max);
 



More information about the grass-commit mailing list