IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 14, 2005, 9:21:41 AM (21 years ago)
Author:
gusciora
Message:

I think I fixed a problem with memory reference counters in the psFree-ing
of pmFPA, Chip, Cell, Readout.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/pmAstrometry.c

    r4997 r5052  
    88*  @author GLG, MHPCC
    99*
    10 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-09-12 20:38:25 $
     10*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-09-14 19:21:41 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4848XXX: Is this the correct way to free database structs?
    4949 
    50 XXX: The meory dereferencing is not quite right with these functions.  If I
     50 
     51 
     52XXX: The memory dereferencing is not quite right with these functions.  If I
    5153call the alloc functions with non-NULL pointers, there will be memory leaks.
    5254 *****************************************************************************/
     
    6062        psFree(fpa->analysis);
    6163        psFree(fpa->camera);
     64        //
     65        // Set the parent to NULL in all fpa->chips before psFree(fpa->chips)
     66        // in order to avoid memory reference counter problems.
     67        //
     68        for (psS32 i = 0 ; i < fpa->chips->n ; i++) {
     69            pmChip *tmpChip = (pmChip *) fpa->chips->data[i];
     70            tmpChip->parent = NULL;
     71        }
    6272        psFree(fpa->chips);
    6373        psFree(fpa->header);
     
    7383        psFree(chip->concepts);
    7484        psFree(chip->analysis);
     85        //
     86        // Set the parent to NULL in all chip->cells before psFree(chip->cells)
     87        // in order to avoid memory reference counter problems.
     88        //
     89        for (psS32 i = 0 ; i < chip->cells->n ; i++) {
     90            pmCell *tmpCell = (pmCell *) chip->cells->data[i];
     91            tmpCell->parent = NULL;
     92        }
    7593        psFree(chip->cells);
    7694        psFree(chip->parent);
     
    89107        psFree(cell->concepts);
    90108        psFree(cell->analysis);
     109        //
     110        // Set the parent to NULL in all cell->readouts before psFree(cell->readouts)
     111        // in order to avoid memory reference counter problems.
     112        //
     113        for (psS32 i = 0 ; i < cell->readouts->n ; i++) {
     114            pmReadout *tmpReadout = (pmReadout *) cell->readouts->data[i];
     115            tmpReadout->parent = NULL;
     116        }
    91117        psFree(cell->readouts);
    92118        psFree(cell->parent);
     
    122148    tmpReadout->concepts = psMetadataAlloc();
    123149    tmpReadout->parent = cell;
    124     psMemIncrRefCounter((psPtr) cell);
    125150    if (cell != NULL) {
    126151        cell->readouts = psArrayAdd(cell->readouts, 1, (psPtr) tmpReadout);
     
    143168    tmpCell->readouts = psArrayAlloc(0);
    144169    tmpCell->parent = chip;
    145     psMemIncrRefCounter((psPtr) chip);
    146170    if (chip != NULL) {
    147171        chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell);
     
    168192    tmpChip->cells = psArrayAlloc(0);
    169193    tmpChip->parent = fpa;
    170     psMemIncrRefCounter((psPtr) fpa);
    171194    if (fpa != NULL) {
    172195        fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip);
    173         psMemIncrRefCounter((psPtr) tmpChip);
    174196    }
    175197    tmpChip->valid = false;
Note: See TracChangeset for help on using the changeset viewer.