[GRASS-SVN] r58993 - grass/trunk/raster/r.li/r.li.mps
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 11 06:04:03 PST 2014
Author: neteler
Date: 2014-02-11 06:04:03 -0800 (Tue, 11 Feb 2014)
New Revision: 58993
Modified:
grass/trunk/raster/r.li/r.li.mps/mps.c
Log:
r.li.mps: avoid double free corruption; trivial white space
Modified: grass/trunk/raster/r.li/r.li.mps/mps.c
===================================================================
--- grass/trunk/raster/r.li/r.li.mps/mps.c 2014-02-11 14:03:49 UTC (rev 58992)
+++ grass/trunk/raster/r.li/r.li.mps/mps.c 2014-02-11 14:04:03 UTC (rev 58993)
@@ -6,7 +6,7 @@
*
* This program is free software under the GPL (>=v2)
* Read the COPYING file that comes with GRASS for details.
- *
+ *
*/
#include <stdlib.h>
@@ -27,7 +27,6 @@
int calculateD(int fd, struct area_entry *ad, struct Cell_head hd, double *result);
int calculateF(int fd, struct area_entry *ad, struct Cell_head hd, double *result);
-
int main(int argc, char *argv[])
{
struct Option *raster, *conf, *output;
@@ -60,10 +59,8 @@
}
-
int meanPatchSize(int fd, char **par, struct area_entry *ad, double *result)
{
-
int ris = 0;
double indice = 0;
struct Cell_head hd;
@@ -91,14 +88,14 @@
G_fatal_error("data type unknown");
return RLI_ERRORE;
}
+
}
- if (ris != RLI_OK) {
- return RLI_ERRORE;
- }
+ if (ris != RLI_OK)
+ return RLI_ERRORE;
*result = indice;
- return RLI_OK;
+ return RLI_OK;
}
@@ -133,11 +130,8 @@
double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
avlID_tree albero = NULL;
-
avlID_table *array;
-
-
/* open mask if needed */
if (ad->mask == 1) {
if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
@@ -469,7 +463,7 @@
G_free(mask_patch_corr);
- G_free(buf_sup);
+ /* G_free(buf_sup); */ /* <-- why not free it? */
return RLI_OK;
}
@@ -478,16 +472,13 @@
{
DCELL *buf;
DCELL *buf_sup;
-
DCELL corrCell;
DCELL precCell;
DCELL supCell;
-
int i, j;
int mask_fd = -1, *mask_buf;
int ris = 0;
int masked = FALSE;
-
long npatch = 0;
long tot = 0;
long zero = 0;
@@ -497,7 +488,6 @@
long doppi = 0;
long *mask_patch_sup;
long *mask_patch_corr;
-
double indice = 0;
double area = 0; /*if all cells are null area=0 */
double areaCorrect = 0;
@@ -1158,7 +1148,6 @@
}
}
-
array = G_malloc(npatch * sizeof(avlID_tableRow));
if (array == NULL) {
G_fatal_error("malloc array failed");
@@ -1203,8 +1192,8 @@
if (masked)
- G_free(mask_buf);
-
+ G_free(mask_buf);
+/* TODO: fix if? */
G_free(mask_patch_corr);
return RLI_OK;
More information about the grass-commit
mailing list