[GRASS-SVN] r62295 - in grass/branches/releasebranch_6_4: . raster/r.li/r.li.daemon raster/r.li/r.li.dominance raster/r.li/r.li.pielou raster/r.li/r.li.renyi raster/r.li/r.li.shannon raster/r.li/r.li.simpson
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 19 14:30:33 PDT 2014
Author: neteler
Date: 2014-10-19 14:30:32 -0700 (Sun, 19 Oct 2014)
New Revision: 62295
Modified:
grass/branches/releasebranch_6_4/
grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.c
grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.h
grass/branches/releasebranch_6_4/raster/r.li/r.li.dominance/dominance.c
grass/branches/releasebranch_6_4/raster/r.li/r.li.pielou/pielou.c
grass/branches/releasebranch_6_4/raster/r.li/r.li.renyi/renyi.c
grass/branches/releasebranch_6_4/raster/r.li/r.li.shannon/shannon.c
grass/branches/releasebranch_6_4/raster/r.li/r.li.simpson/simpson.c
Log:
r.li: fix and improve memory handling by better allocations and proper type use (backport of trunk r61812 via devbr6 r62294)
Property changes on: grass/branches/releasebranch_6_4
___________________________________________________________________
Added: svn:mergeinfo
+ /grass/branches/develbranch_6:62294
/grass/trunk:61812
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.c 2014-10-19 21:27:55 UTC (rev 62294)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.c 2014-10-19 21:30:32 UTC (rev 62295)
@@ -193,7 +193,7 @@
-long avl_to_array(avl_node * root, long i, AVL_table * a)
+long avl_to_array(avl_node * root, long i, AVL_table a)
{
if (root != NULL) {
@@ -201,9 +201,8 @@
if (a == NULL)
G_fatal_error("avl, avl_to_array: null value");
else {
- a[i] = G_malloc(sizeof(AVL_tableRow));
- a[i]->k = root->key;
- a[i]->tot = root->counter;
+ a[i].k = root->key;
+ a[i].tot = root->counter;
i++;
i = avl_to_array(root->right_child, i, a);
}
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.h
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.h 2014-10-19 21:27:55 UTC (rev 62294)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/avl.h 2014-10-19 21:30:32 UTC (rev 62295)
@@ -37,7 +37,7 @@
void avl_destroy(avl_tree root);
avl_node *avl_find(const avl_tree root, const generic_cell k);
int avl_add(avl_tree * root, const generic_cell k, const long n);
-long avl_to_array(avl_node * root, long i, AVL_table * a);
+long avl_to_array(avl_node * root, long i, AVL_table a);
long howManyCell(const avl_tree root, const generic_cell k);
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.dominance/dominance.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.dominance/dominance.c 2014-10-19 21:27:55 UTC (rev 62294)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.dominance/dominance.c 2014-10-19 21:30:32 UTC (rev 62295)
@@ -121,7 +121,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = CELL_TYPE;
@@ -267,7 +267,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
@@ -308,7 +308,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = DCELL_TYPE;
@@ -454,7 +454,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
@@ -495,7 +495,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = FCELL_TYPE;
@@ -641,7 +641,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.pielou/pielou.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.pielou/pielou.c 2014-10-19 21:27:55 UTC (rev 62294)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.pielou/pielou.c 2014-10-19 21:30:32 UTC (rev 62295)
@@ -121,7 +121,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = CELL_TYPE;
@@ -267,7 +267,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
@@ -308,7 +308,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = DCELL_TYPE;
@@ -454,7 +454,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
@@ -495,7 +495,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = FCELL_TYPE;
@@ -641,7 +641,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.renyi/renyi.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.renyi/renyi.c 2014-10-19 21:27:55 UTC (rev 62294)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.renyi/renyi.c 2014-10-19 21:30:32 UTC (rev 62295)
@@ -145,7 +145,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = CELL_TYPE;
@@ -295,7 +295,7 @@
sum = 0;
sum2 = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
pi = t / area;
sum += pow(pi, alpha);
sum2 += pi;
@@ -346,7 +346,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = DCELL_TYPE;
@@ -496,7 +496,7 @@
sum = 0;
sum2 = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
pi = t / area;
sum += pow(pi, alpha);
sum += pi;
@@ -547,7 +547,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = FCELL_TYPE;
@@ -697,7 +697,7 @@
sum = 0;
sum2 = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
pi = t / area;
sum += pow(pi, alpha);
sum2 += pi;
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.shannon/shannon.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.shannon/shannon.c 2014-10-19 21:27:55 UTC (rev 62294)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.shannon/shannon.c 2014-10-19 21:30:32 UTC (rev 62295)
@@ -121,7 +121,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = CELL_TYPE;
@@ -267,7 +267,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
@@ -308,7 +308,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = DCELL_TYPE;
@@ -454,7 +454,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
@@ -495,7 +495,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = FCELL_TYPE;
@@ -641,7 +641,7 @@
/* calculate shannon */
shannon = 0;
for (i = 0; i < m; i++) {
- t = array[i]->tot;
+ t = array[i].tot;
perc = t / area;
logarithm = log(perc);
shannon += perc * logarithm;
Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.simpson/simpson.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.simpson/simpson.c 2014-10-19 21:27:55 UTC (rev 62294)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.simpson/simpson.c 2014-10-19 21:30:32 UTC (rev 62295)
@@ -121,7 +121,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = CELL_TYPE;
@@ -267,7 +267,7 @@
/* calculate simpson */
simpson = 0;
for (i = 0; i < m; i++) {
- t = (double)(array[i]->tot);
+ t = (double)(array[i].tot);
p = t / area;
simpson += (p * p);
}
@@ -307,7 +307,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = DCELL_TYPE;
@@ -453,7 +453,7 @@
/* calculate simpson */
simpson = 0;
for (i = 0; i < m; i++) {
- t = (double)(array[i]->tot);
+ t = (double)(array[i].tot);
p = t / area;
simpson += (p * p);
}
@@ -493,7 +493,7 @@
long area = 0;
avl_tree albero = NULL;
- AVL_table *array;
+ AVL_table array;
generic_cell uc;
uc.t = FCELL_TYPE;
@@ -639,7 +639,7 @@
/* calculate simpson */
simpson = 0;
for (i = 0; i < m; i++) {
- t = (double)(array[i]->tot);
+ t = (double)(array[i].tot);
p = t / area;
simpson += (p * p);
}
More information about the grass-commit
mailing list