[GRASS-SVN] r52594 - grass/trunk/raster/r.in.xyz
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 8 03:30:53 PDT 2012
Author: mmetz
Date: 2012-08-08 03:30:52 -0700 (Wed, 08 Aug 2012)
New Revision: 52594
Modified:
grass/trunk/raster/r.in.xyz/main.c
Log:
r.in.xyz: support for more than 2 billion cells in current region
Modified: grass/trunk/raster/r.in.xyz/main.c
===================================================================
--- grass/trunk/raster/r.in.xyz/main.c 2012-08-08 10:26:55 UTC (rev 52593)
+++ grass/trunk/raster/r.in.xyz/main.c 2012-08-08 10:30:52 UTC (rev 52594)
@@ -44,7 +44,7 @@
if (num_nodes >= max_nodes) {
max_nodes += SIZE_INCREMENT;
- nodes = G_realloc(nodes, max_nodes * sizeof(struct node));
+ nodes = G_realloc(nodes, (size_t)max_nodes * sizeof(struct node));
}
return n;
@@ -477,20 +477,29 @@
npasses = (int)ceil(1.0 * region.rows / rows);
if (!scan_flag->answer) {
+ /* check if rows * (cols + 1) go into a size_t */
+ if (sizeof(size_t) < 8) {
+ double dsize = rows * (cols + 1);
+
+ if (dsize != (size_t)rows * (cols + 1))
+ G_fatal_error(_("Unable to process the hole map at once. "
+ "Please set the %s option to some value lower than 100."),
+ percent_opt->key);
+ }
/* allocate memory (test for enough before we start) */
if (bin_n)
- n_array = G_calloc(rows * (cols + 1), Rast_cell_size(CELL_TYPE));
+ n_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(CELL_TYPE));
if (bin_min)
- min_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ min_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
if (bin_max)
- max_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ max_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
if (bin_sum)
- sum_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ sum_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
if (bin_sumsq)
- sumsq_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ sumsq_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
if (bin_index)
index_array =
- G_calloc(rows * (cols + 1), Rast_cell_size(CELL_TYPE));
+ G_calloc((size_t)rows * (cols + 1), Rast_cell_size(CELL_TYPE));
/* and then free it again */
if (bin_n)
@@ -591,33 +600,33 @@
if (bin_n) {
G_debug(2, "allocating n_array");
- n_array = G_calloc(rows * (cols + 1), Rast_cell_size(CELL_TYPE));
+ n_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(CELL_TYPE));
blank_array(n_array, rows, cols, CELL_TYPE, 0);
}
if (bin_min) {
G_debug(2, "allocating min_array");
- min_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ min_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
blank_array(min_array, rows, cols, rtype, -1); /* fill with NULLs */
}
if (bin_max) {
G_debug(2, "allocating max_array");
- max_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ max_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
blank_array(max_array, rows, cols, rtype, -1); /* fill with NULLs */
}
if (bin_sum) {
G_debug(2, "allocating sum_array");
- sum_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ sum_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
blank_array(sum_array, rows, cols, rtype, 0);
}
if (bin_sumsq) {
G_debug(2, "allocating sumsq_array");
- sumsq_array = G_calloc(rows * (cols + 1), Rast_cell_size(rtype));
+ sumsq_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(rtype));
blank_array(sumsq_array, rows, cols, rtype, 0);
}
if (bin_index) {
G_debug(2, "allocating index_array");
index_array =
- G_calloc(rows * (cols + 1), Rast_cell_size(CELL_TYPE));
+ G_calloc((size_t)rows * (cols + 1), Rast_cell_size(CELL_TYPE));
blank_array(index_array, rows, cols, CELL_TYPE, -1); /* fill with NULLs */
}
More information about the grass-commit
mailing list