IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 30, 2006, 12:04:46 PM (20 years ago)
Author:
magnier
Message:

fixed cell/chip extra frees, added FPA_ASTROM elemenets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmFPA.c

    r6984 r7006  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-04-26 00:27:14 $
     14*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-04-30 22:04:46 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3636static void readoutFree(pmReadout *readout)
    3737{
    38     psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t)readout, (size_t)readout->parent);
     38    // if this readout has a parent, drop that instance
    3939    if (readout->parent) {
     40        psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t)readout, (size_t)readout->parent);
    4041        psArray *readouts = readout->parent->readouts;
    4142        for (int i = 0; i < readouts->n; i++) {
     
    5556static void cellFree(pmCell *cell)
    5657{
    57     psTrace(__func__, 9, "Removing cell %lx from chip %lx...\n", (size_t)cell, (size_t)cell->parent);
     58
     59    // if this cell has a parent, drop that instance
    5860    if (cell->parent) {
     61        psTrace(__func__, 9, "Removing cell %lx from chip %lx...\n", (size_t)cell, (size_t)cell->parent);
    5962        psArray *cells = cell->parent->cells;
    6063        for (int i = 0; i < cells->n; i++) {
     
    7679static void chipFree(pmChip* chip)
    7780{
    78     psTrace(__func__, 9, "Removing chip %lx from fpa %lx...\n", (size_t)chip, (size_t)chip->parent);
     81    // if this chip has a parent, drop that instance
    7982    if (chip->parent) {
     83        psTrace(__func__, 9, "Removing chip %lx from fpa %lx...\n", (size_t)chip, (size_t)chip->parent);
    8084        psArray *chips = chip->parent->chips;
    8185        for (int i = 0; i < chips->n; i++) {
     
    8589        }
    8690    }
     91
    8792    psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip);
    8893    pmChipFreeCells(chip);
     
    9398    psFree(chip->hdu);
    9499    psFree(chip->mosaic);
     100
     101    # if FPA_ASTROM
     102
     103    psFree(chip->toFPA);
     104    psFree(chip->fromFPA);
     105    # endif
    95106}
    96107
     
    99110{
    100111    psTrace(__func__, 9, "Freeing fpa %lx\n", (size_t)fpa);
     112
     113    // NULL the parent pointers
    101114    psArray *chips = fpa->chips;
    102     for (psS32 i = 0 ; i < chips->n ; i++) {
     115    for (int i = 0 ; i < chips->n ; i++) {
    103116        pmChip *tmpChip = chips->data[i];
    104117        if (! tmpChip) {
    105118            continue;
    106119        }
    107         chips->data[i] = NULL;
    108120        tmpChip->parent = NULL;
    109121    }
     
    113125    psFree(fpa->camera);
    114126    psFree(fpa->hdu);
     127
     128    # if FPA_ASTROM
     129
     130    psFree(fpa->fromTangentPlane);
     131    psFree(fpa->toTangentPlane);
     132    psFree(fpa->projection);
     133    # endif
    115134}
    116135
     
    127146            continue;
    128147        }
    129         readouts->data[i] = NULL;
    130148        tmpReadout->parent = NULL;
    131149        psTrace(__func__, 9, "Will now free readout %lx...\n", (size_t)tmpReadout);
    132         psFree(tmpReadout); // Drop the readout
    133150    }
    134151    cell->readouts = psArrayRealloc(cell->readouts, 0);
     
    149166            continue;
    150167        }
    151         cells->data[i] = NULL;
    152168        tmpCell->parent = NULL;
    153169        pmCellFreeReadouts(tmpCell);// Drop all readouts the cell holds
    154         psFree(tmpCell);            // Drop the cell
    155170    }
    156171    chip->cells = psArrayRealloc(chip->cells, 0);
     
    221236    psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree);
    222237
    223     tmpChip->analysis = psMetadataAlloc();
     238    # if FPA_ASTROM
     239
     240    tmpChip->col0 = 0;
     241tmpChip->row0 = 0;
     242tmpChip->toFPA = NULL;
     243tmpChip->fromFPA = NULL;
     244# endif
     245
     246tmpChip->analysis = psMetadataAlloc();
    224247    tmpChip->cells = psArrayAlloc(0);
    225248    tmpChip->parent = fpa;
    226249    if (fpa != NULL) {
    227         fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip);
     250        psArrayAdd(fpa->chips, 1, (psPtr) tmpChip);
    228251    }
    229252    tmpChip->hdu = NULL;
     
    239262    }
    240263    pmConceptsBlankChip(tmpChip);
    241 
    242264    return(tmpChip);
    243265}
     
    248270    psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree);
    249271
    250     tmpFPA->analysis = NULL;
    251     tmpFPA->camera = psMemIncrRefCounter((psPtr)camera);
     272    # if FPA_ASTROM
     273
     274    tmpFPA->fromTangentPlane = NULL;
     275tmpFPA->toTangentPlane = NULL;
     276tmpFPA->projection = NULL;
     277# endif
     278
     279tmpFPA->analysis = NULL;
     280tmpFPA->camera = psMemIncrRefCounter((psPtr)camera);
    252281    tmpFPA->chips = psArrayAlloc(0);
    253282    tmpFPA->hdu = NULL;
Note: See TracChangeset for help on using the changeset viewer.