[GRASS-SVN] r62294 - in grass/branches/develbranch_6: . 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:27:55 PDT 2014


Author: neteler
Date: 2014-10-19 14:27:55 -0700 (Sun, 19 Oct 2014)
New Revision: 62294

Modified:
   grass/branches/develbranch_6/
   grass/branches/develbranch_6/raster/r.li/r.li.daemon/avl.c
   grass/branches/develbranch_6/raster/r.li/r.li.daemon/avl.h
   grass/branches/develbranch_6/raster/r.li/r.li.dominance/dominance.c
   grass/branches/develbranch_6/raster/r.li/r.li.pielou/pielou.c
   grass/branches/develbranch_6/raster/r.li/r.li.renyi/renyi.c
   grass/branches/develbranch_6/raster/r.li/r.li.shannon/shannon.c
   grass/branches/develbranch_6/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 r61812)


Property changes on: grass/branches/develbranch_6
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/branches/releasebranch_6_4:59764,59799
   + /grass/branches/releasebranch_6_4:59764,59799
/grass/trunk:61812

Modified: grass/branches/develbranch_6/raster/r.li/r.li.daemon/avl.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.daemon/avl.c	2014-10-19 21:22:41 UTC (rev 62293)
+++ grass/branches/develbranch_6/raster/r.li/r.li.daemon/avl.c	2014-10-19 21:27:55 UTC (rev 62294)
@@ -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/develbranch_6/raster/r.li/r.li.daemon/avl.h
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.daemon/avl.h	2014-10-19 21:22:41 UTC (rev 62293)
+++ grass/branches/develbranch_6/raster/r.li/r.li.daemon/avl.h	2014-10-19 21:27:55 UTC (rev 62294)
@@ -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/develbranch_6/raster/r.li/r.li.dominance/dominance.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.dominance/dominance.c	2014-10-19 21:22:41 UTC (rev 62293)
+++ grass/branches/develbranch_6/raster/r.li/r.li.dominance/dominance.c	2014-10-19 21:27:55 UTC (rev 62294)
@@ -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/develbranch_6/raster/r.li/r.li.pielou/pielou.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.pielou/pielou.c	2014-10-19 21:22:41 UTC (rev 62293)
+++ grass/branches/develbranch_6/raster/r.li/r.li.pielou/pielou.c	2014-10-19 21:27:55 UTC (rev 62294)
@@ -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/develbranch_6/raster/r.li/r.li.renyi/renyi.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.renyi/renyi.c	2014-10-19 21:22:41 UTC (rev 62293)
+++ grass/branches/develbranch_6/raster/r.li/r.li.renyi/renyi.c	2014-10-19 21:27:55 UTC (rev 62294)
@@ -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/develbranch_6/raster/r.li/r.li.shannon/shannon.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.shannon/shannon.c	2014-10-19 21:22:41 UTC (rev 62293)
+++ grass/branches/develbranch_6/raster/r.li/r.li.shannon/shannon.c	2014-10-19 21:27:55 UTC (rev 62294)
@@ -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/develbranch_6/raster/r.li/r.li.simpson/simpson.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.simpson/simpson.c	2014-10-19 21:22:41 UTC (rev 62293)
+++ grass/branches/develbranch_6/raster/r.li/r.li.simpson/simpson.c	2014-10-19 21:27:55 UTC (rev 62294)
@@ -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