Changeset 62279


Ignore:
Timestamp:
Oct 17, 2014, 8:55:35 AM (10 years ago)
Author:
wenzeslaus
Message:

fix and improve memory handling by better allocations and proper type use (backport of r61812)

Location:
grass/branches/releasebranch_7_0/raster/r.li
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • grass/branches/releasebranch_7_0/raster/r.li/r.li.daemon/avl.c

    r59044 r62279  
    194194
    195195
    196 long avl_to_array(avl_node * root, long i, AVL_table * a)
     196long avl_to_array(avl_node * root, long i, AVL_table a)
    197197{
    198198
     
    202202            G_fatal_error("avl, avl_to_array: null value");
    203203        else {
    204             a[i] = G_malloc(sizeof(AVL_tableRow));
    205             a[i]->k = root->key;
    206             a[i]->tot = root->counter;
     204            a[i].k = root->key;
     205            a[i].tot = root->counter;
    207206            i++;
    208207            i = avl_to_array(root->right_child, i, a);
  • grass/branches/releasebranch_7_0/raster/r.li/r.li.daemon/avl.h

    r59025 r62279  
    3838avl_node *avl_find(const avl_tree root, const generic_cell k);
    3939int avl_add(avl_tree * root, const generic_cell k, const long n);
    40 long avl_to_array(avl_node * root, long i, AVL_table * a);
     40long avl_to_array(avl_node * root, long i, AVL_table a);
    4141long howManyCell(const avl_tree root, const generic_cell k);
    4242
  • grass/branches/releasebranch_7_0/raster/r.li/r.li.dominance/dominance.c

    r59170 r62279  
    124124
    125125    avl_tree albero = NULL;
    126     AVL_table *array;
     126    AVL_table array;
    127127    generic_cell uc;
    128128
     
    270270        shannon = 0;
    271271        for (i = 0; i < m; i++) {
    272             t = array[i]->tot;
     272            t = array[i].tot;
    273273            perc = t / area;
    274274            logarithm = log(perc);
     
    311311
    312312    avl_tree albero = NULL;
    313     AVL_table *array;
     313    AVL_table array;
    314314    generic_cell uc;
    315315
     
    457457        shannon = 0;
    458458        for (i = 0; i < m; i++) {
    459             t = array[i]->tot;
     459            t = array[i].tot;
    460460            perc = t / area;
    461461            logarithm = log(perc);
     
    498498
    499499    avl_tree albero = NULL;
    500     AVL_table *array;
     500    AVL_table array;
    501501    generic_cell uc;
    502502
     
    644644        shannon = 0;
    645645        for (i = 0; i < m; i++) {
    646             t = array[i]->tot;
     646            t = array[i].tot;
    647647            perc = t / area;
    648648            logarithm = log(perc);
  • grass/branches/releasebranch_7_0/raster/r.li/r.li.pielou/pielou.c

    r59170 r62279  
    124124
    125125    avl_tree albero = NULL;
    126     AVL_table *array;
     126    AVL_table array;
    127127    generic_cell uc;
    128128
     
    270270        shannon = 0;
    271271        for (i = 0; i < m; i++) {
    272             t = array[i]->tot;
     272            t = array[i].tot;
    273273            perc = t / area;
    274274            logarithm = log(perc);
     
    311311
    312312    avl_tree albero = NULL;
    313     AVL_table *array;
     313    AVL_table array;
    314314    generic_cell uc;
    315315
     
    457457        shannon = 0;
    458458        for (i = 0; i < m; i++) {
    459             t = array[i]->tot;
     459            t = array[i].tot;
    460460            perc = t / area;
    461461            logarithm = log(perc);
     
    498498
    499499    avl_tree albero = NULL;
    500     AVL_table *array;
     500    AVL_table array;
    501501    generic_cell uc;
    502502
     
    644644        shannon = 0;
    645645        for (i = 0; i < m; i++) {
    646             t = array[i]->tot;
     646            t = array[i].tot;
    647647            perc = t / area;
    648648            logarithm = log(perc);
  • grass/branches/releasebranch_7_0/raster/r.li/r.li.renyi/renyi.c

    r59300 r62279  
    148148
    149149    avl_tree albero = NULL;
    150     AVL_table *array;
     150    AVL_table array;
    151151    generic_cell uc;
    152152
     
    298298        sum2 = 0;
    299299        for (i = 0; i < m; i++) {
    300             t = array[i]->tot;
     300            t = array[i].tot;
    301301            pi = t / area;
    302302            sum += pow(pi, alpha);
     
    349349
    350350    avl_tree albero = NULL;
    351     AVL_table *array;
     351    AVL_table array;
    352352    generic_cell uc;
    353353
     
    499499        sum2 = 0;
    500500        for (i = 0; i < m; i++) {
    501             t = array[i]->tot;
     501            t = array[i].tot;
    502502            pi = t / area;
    503503            sum += pow(pi, alpha);
     
    550550
    551551    avl_tree albero = NULL;
    552     AVL_table *array;
     552    AVL_table array;
    553553    generic_cell uc;
    554554
     
    700700        sum2 = 0;
    701701        for (i = 0; i < m; i++) {
    702             t = array[i]->tot;
     702            t = array[i].tot;
    703703            pi = t / area;
    704704            sum += pow(pi, alpha);
  • grass/branches/releasebranch_7_0/raster/r.li/r.li.shannon/shannon.c

    r59170 r62279  
    124124
    125125    avl_tree albero = NULL;
    126     AVL_table *array;
     126    AVL_table array;
    127127    generic_cell uc;
    128128
     
    270270        shannon = 0;
    271271        for (i = 0; i < m; i++) {
    272             t = array[i]->tot;
     272            t = array[i].tot;
    273273            perc = t / area;
    274274            logarithm = log(perc);
     
    311311
    312312    avl_tree albero = NULL;
    313     AVL_table *array;
     313    AVL_table array;
    314314    generic_cell uc;
    315315
     
    457457        shannon = 0;
    458458        for (i = 0; i < m; i++) {
    459             t = array[i]->tot;
     459            t = array[i].tot;
    460460            perc = t / area;
    461461            logarithm = log(perc);
     
    498498
    499499    avl_tree albero = NULL;
    500     AVL_table *array;
     500    AVL_table array;
    501501    generic_cell uc;
    502502
     
    644644        shannon = 0;
    645645        for (i = 0; i < m; i++) {
    646             t = array[i]->tot;
     646            t = array[i].tot;
    647647            perc = t / area;
    648648            logarithm = log(perc);
  • grass/branches/releasebranch_7_0/raster/r.li/r.li.simpson/simpson.c

    r59170 r62279  
    124124
    125125    avl_tree albero = NULL;
    126     AVL_table *array;
     126    AVL_table array;
    127127    generic_cell uc;
    128128
     
    270270        simpson = 0;
    271271        for (i = 0; i < m; i++) {
    272             t = (double)(array[i]->tot);
     272            t = (double)(array[i].tot);
    273273            p = t / area;
    274274            simpson += (p * p);
     
    310310
    311311    avl_tree albero = NULL;
    312     AVL_table *array;
     312    AVL_table array;
    313313    generic_cell uc;
    314314
     
    456456        simpson = 0;
    457457        for (i = 0; i < m; i++) {
    458             t = (double)(array[i]->tot);
     458            t = (double)(array[i].tot);
    459459            p = t / area;
    460460            simpson += (p * p);
     
    496496
    497497    avl_tree albero = NULL;
    498     AVL_table *array;
     498    AVL_table array;
    499499    generic_cell uc;
    500500
     
    642642        simpson = 0;
    643643        for (i = 0; i < m; i++) {
    644             t = (double)(array[i]->tot);
     644            t = (double)(array[i].tot);
    645645            p = t / area;
    646646            simpson += (p * p);
Note: See TracChangeset for help on using the changeset viewer.