IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 30, 2006, 3:33:07 PM (20 years ago)
Author:
Paul Price
Message:

Plugging memory leaks --- done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmFPA.c

    r6713 r6743  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.1.4.5 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-03-28 02:16:26 $
     14*  @version $Revision: 1.1.4.6 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-03-31 01:33:07 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3838static void readoutFree(pmReadout *readout)
    3939{
    40     if (readout != NULL) {
    41         psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t) readout, (size_t) readout->parent);
    42         if (readout->parent) {
    43             psArray *readouts = readout->parent->readouts;
    44             for (int i = 0; i < readouts->n; i++) {
    45                 if (readouts->data[i] == readout) {
    46                     //                    pmReadout *tmpReadout = readouts->data[i];
    47                     readouts->data[i] = NULL;
    48                     #if PARENT_LINKS
    49 
    50                     psFree(tmpReadout);
    51                     #endif
    52 
    53                     break;
    54                 }
     40    psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t) readout, (size_t) readout->parent);
     41    if (readout->parent) {
     42        psArray *readouts = readout->parent->readouts;
     43        for (int i = 0; i < readouts->n; i++) {
     44            if (readouts->data[i] == readout) {
     45                //                    pmReadout *tmpReadout = readouts->data[i];
     46                readouts->data[i] = NULL;
     47                #if PARENT_LINKS
     48
     49                psFree(tmpReadout);
     50                #endif
     51
     52                break;
    5553            }
    5654        }
    57         psTrace(__func__, 9, "Freeing readout %lx\n", (size_t) readout);
    58 
    59         #if PARENT_LINKS
    60 
    61         psFree(readout->parent);
    62         #endif
    63 
    64         psFree(readout->image);
    65         psFree(readout->mask);
    66         psFree(readout->weight);
    67         psFree(readout->analysis);
    68         psFree(readout->bias);
    69     }
     55    }
     56    psTrace(__func__, 9, "Freeing readout %lx\n", (size_t) readout);
     57
     58    #if PARENT_LINKS
     59
     60    psFree(readout->parent);
     61    #endif
     62
     63    psFree(readout->image);
     64    psFree(readout->mask);
     65    psFree(readout->weight);
     66    psFree(readout->analysis);
     67    psFree(readout->bias);
    7068}
    7169
    7270static void cellFree(pmCell *cell)
    7371{
    74     if (cell != NULL) {
    75         psTrace(__func__, 9, "Removing cell %lx from chip %lx...\n", (size_t)cell, (size_t)cell->parent);
    76         if (cell->parent) {
    77             psArray *cells = cell->parent->cells;
    78             for (int i = 0; i < cells->n; i++) {
    79                 if (cells->data[i] == cell) {
    80                     //                    pmCell *tmpCell = cells->data[i];
    81                     cells->data[i] = NULL;
    82                     #if PARENT_LINKS
    83 
    84                     psFree(tmpCell);
    85                     #endif
    86 
    87                     break;
    88                 }
     72    psTrace(__func__, 9, "Removing cell %lx from chip %lx...\n", (size_t)cell, (size_t)cell->parent);
     73    if (cell->parent) {
     74        psArray *cells = cell->parent->cells;
     75        for (int i = 0; i < cells->n; i++) {
     76            if (cells->data[i] == cell) {
     77                //                    pmCell *tmpCell = cells->data[i];
     78                cells->data[i] = NULL;
     79                #if PARENT_LINKS
     80
     81                psFree(tmpCell);
     82                #endif
     83
     84                break;
    8985            }
    9086        }
    91         psTrace(__func__, 9, "Freeing cell %lx\n", (size_t)cell);
    92 
    93         pmCellFreeReadouts(cell);
    94         psFree(cell->readouts);
    95         #if PARENT_LINKS
    96 
    97         psFree(cell->parent);
    98         #endif
    99 
    100         psFree(cell->concepts);
    101         psFree(cell->analysis);
    102         psFree(cell->config);
    103         psFree(cell->hdu);
    104     }
     87    }
     88    psTrace(__func__, 9, "Freeing cell %lx\n", (size_t)cell);
     89
     90    pmCellFreeReadouts(cell);
     91    psFree(cell->readouts);
     92    #if PARENT_LINKS
     93
     94    psFree(cell->parent);
     95    #endif
     96
     97    psFree(cell->concepts);
     98    psFree(cell->analysis);
     99    psFree(cell->config);
     100    psFree(cell->hdu);
    105101}
    106102
    107103static void chipFree(pmChip* chip)
    108104{
    109     if (chip != NULL) {
    110         psTrace(__func__, 9, "Removing chip %lx from fpa %lx...\n", (size_t)chip, (size_t)chip->parent);
    111         if (chip->parent) {
    112             psArray *chips = chip->parent->chips;
    113             for (int i = 0; i < chips->n; i++) {
    114                 if (chips->data[i] == chip) {
    115                     //                    pmChip *tmpChip = chips->data[i];
    116                     chips->data[i] = NULL;
    117                     #if PARENT_LINKS
    118 
    119                     psFree(tmpChip);
    120                     #endif
    121 
    122                     break;
    123                 }
     105    psTrace(__func__, 9, "Removing chip %lx from fpa %lx...\n", (size_t)chip, (size_t)chip->parent);
     106    if (chip->parent) {
     107        psArray *chips = chip->parent->chips;
     108        for (int i = 0; i < chips->n; i++) {
     109            if (chips->data[i] == chip) {
     110                //                    pmChip *tmpChip = chips->data[i];
     111                chips->data[i] = NULL;
     112                #if PARENT_LINKS
     113
     114                psFree(tmpChip);
     115                #endif
     116
     117                break;
    124118            }
    125119        }
    126         psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip);
    127 
    128         pmChipFreeCells(chip);
    129         psFree(chip->cells);
    130         #if PARENT_LINKS
    131 
    132         psFree(chip->parent);
    133         #endif
    134 
    135         #if 0
    136 
    137         psFree(chip->toFPA);
    138         psFree(chip->fromFPA);
    139         #endif
    140 
    141         psFree(chip->concepts);
    142         psFree(chip->analysis);
    143         psFree(chip->hdu);
    144     }
     120    }
     121    psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip);
     122
     123    pmChipFreeCells(chip);
     124    psFree(chip->cells);
     125    #if PARENT_LINKS
     126
     127    psFree(chip->parent);
     128    #endif
     129
     130    #if 0
     131
     132    psFree(chip->toFPA);
     133    psFree(chip->fromFPA);
     134    #endif
     135
     136    psFree(chip->concepts);
     137    psFree(chip->analysis);
     138    psFree(chip->hdu);
    145139}
    146140
     
    148142static void FPAFree(pmFPA *fpa)
    149143{
    150     if (fpa != NULL) {
    151         psTrace(__func__, 9, "Freeing fpa %lx\n", (size_t)fpa);
    152         #if 0
    153 
    154         psFree(fpa->fromTangentPlane);
    155         psFree(fpa->toTangentPlane);
    156         psFree(fpa->projection);
    157         #endif
    158 
    159         psFree(fpa->concepts);
    160         psFree(fpa->analysis);
    161         psFree(fpa->camera);
    162         //
    163         // Set the parent to NULL in all fpa->chips before psFree(fpa->chips)
    164         // in order to avoid memory reference counter problems.
    165         //
    166         psArray *chips = fpa->chips;
    167         for (psS32 i = 0 ; i < chips->n ; i++) {
    168             pmChip *tmpChip = chips->data[i];
    169             if (! tmpChip) {
    170                 continue;
    171             }
    172             chips->data[i] = NULL;
    173             tmpChip->parent = NULL;
    174             if (PS_FREE_HIERARCHY == 1) {
    175                 psFree(tmpChip);
    176             }
    177         }
    178         psFree(fpa->chips);
    179         psFree(fpa->hdu);
    180     }
     144    psTrace(__func__, 9, "Freeing fpa %lx\n", (size_t)fpa);
     145    #if 0
     146
     147    psFree(fpa->fromTangentPlane);
     148    psFree(fpa->toTangentPlane);
     149    psFree(fpa->projection);
     150    #endif
     151
     152    psFree(fpa->concepts);
     153    psFree(fpa->analysis);
     154    psFree(fpa->camera);
     155    //
     156    // Set the parent to NULL in all fpa->chips before psFree(fpa->chips)
     157    // in order to avoid memory reference counter problems.
     158    //
     159    psArray *chips = fpa->chips;
     160    for (psS32 i = 0 ; i < chips->n ; i++) {
     161        pmChip *tmpChip = chips->data[i];
     162        if (! tmpChip) {
     163            continue;
     164        }
     165        chips->data[i] = NULL;
     166        tmpChip->parent = NULL;
     167        if (PS_FREE_HIERARCHY == 1) {
     168            psFree(tmpChip);
     169        }
     170    }
     171    psFree(fpa->chips);
     172    psFree(fpa->hdu);
    181173}
    182174
Note: See TracChangeset for help on using the changeset viewer.