[GRASS-SVN] r63399 - grass-addons/grass7/imagery/i.theilsen
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Dec 6 08:49:07 PST 2014
Author: ychemin
Date: 2014-12-06 08:49:07 -0800 (Sat, 06 Dec 2014)
New Revision: 63399
Modified:
grass-addons/grass7/imagery/i.theilsen/main.c
Log:
Fixed a memory allocation
Modified: grass-addons/grass7/imagery/i.theilsen/main.c
===================================================================
--- grass-addons/grass7/imagery/i.theilsen/main.c 2014-12-06 14:51:31 UTC (rev 63398)
+++ grass-addons/grass7/imagery/i.theilsen/main.c 2014-12-06 16:49:07 UTC (rev 63399)
@@ -36,7 +36,6 @@
struct History history; /*metadata */
struct Colors colors; /*Color rules */
- int outfd0, outfd1;
int nfiles=0, count=0, n=0, n0=0, n1=0, n0n1=0;
DCELL *signal;/*spectral/temporal signal*/
DCELL *sorted;/*spectral/temporal sorted slope*/
@@ -46,6 +45,8 @@
float mk_max=0.0;/*Mann-Kendall total max for colour palette */
float mk_min=0.0;/*Mann-Kendall total min for colour palette */
float temp=0.0;/*swapping temp value*/
+
+ int outfd0, outfd1;
DCELL *outrast0, *outrast1;
CELL val1, val2;
@@ -79,13 +80,17 @@
nrows = Rast_window_rows();
ncols = Rast_window_cols();
- /* Allocate output buffer, use input map data_type */
- outrast0 = Rast_allocate_buf(DCELL_TYPE);
- outrast1 = Rast_allocate_buf(DCELL_TYPE);
+ group = grp->answer;
+ subgroup = sgrp->answer;
+
/* Create New raster files */
outfd0 = Rast_open_new(out0->answer,DCELL_TYPE);
outfd1 = Rast_open_new(out1->answer,DCELL_TYPE);
+ /* Allocate output buffer, use input map data_type */
+ outrast0 = Rast_allocate_d_buf();
+ outrast1 = Rast_allocate_d_buf();
+
/* Open input files */
nfiles = open_files();
@@ -93,7 +98,10 @@
signal = (DCELL *) G_malloc(nfiles * sizeof(DCELL));
/* Allocate Theil-Sen Slope Matrix */
- slope = (DCELL **) G_malloc(nfiles*nfiles*sizeof(DCELL));
+ slope = (DCELL **) G_malloc(nfiles*nfiles*sizeof(DCELL *));
+ for (n=0;n<nfiles;n++){
+ slope[n]= (DCELL *) G_malloc(nfiles*sizeof(DCELL));
+ }
/* Allocate 1D Theil-Sen Slope sorting array */
sorted = (DCELL *) G_malloc(nfiles*nfiles*sizeof(DCELL));
@@ -159,18 +167,14 @@
Rast_put_d_row(outfd0, outrast0);
/* Mann-Kendall Trend Test */
/* Not yet implemented */
- /* Rast_put_d_row(outfd1, outrast1);*/
Rast_put_d_row(outfd1, outrast1);
/*-------------------------*/
}
for (n = 0; n < nfiles; n++) {
G_free(cell[n]);
- G_free(slope[n]);
Rast_close(cellfd[n]);
}
- G_free(signal);
- G_free(sorted);
G_free(outrast0);
G_free(outrast1);
Rast_close(outfd0);
@@ -196,7 +200,7 @@
Rast_short_history(out1->answer, "raster", &history);
Rast_command_history(&history);
Rast_write_history(out1->answer, &history);
-
+
exit(EXIT_SUCCESS);
}
More information about the grass-commit
mailing list