IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6351


Ignore:
Timestamp:
Feb 7, 2006, 2:52:13 PM (20 years ago)
Author:
Paul Price
Message:

Squashing memory leaks... some more yet to do.

Location:
branches/eam_rel9_p0/psModules/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c

    r6342 r6351  
    157157        }
    158158
    159         psMetadataPrint(cell->concepts, 10);
    160 
    161159        nCells++;
    162160        gain       += psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN");
     
    303301        psArrayElementsFree(hdu->weights);
    304302        psArrayElementsFree(hdu->masks);
    305         hdu->images  = psArrayAlloc(1);
    306         hdu->weights = psArrayAlloc(1);
    307         hdu->masks   = psArrayAlloc(1);
     303        hdu->images  = psArrayRealloc(hdu->images,1);
     304        hdu->weights = psArrayRealloc(hdu->weights, 1);
     305        hdu->masks   = psArrayRealloc(hdu->masks, 1);
    308306        hdu->images->data[0]  = image;
    309307        hdu->weights->data[0] = weight;
     
    314312
    315313    // Chop off all the component cells, and put in a new one
    316     #if !MEM_LEAKS
     314    pmCell *newCell = pmCellAlloc(NULL, NULL, __func__); // New cell
     315    cellConcepts(newCell, cells, xBinChip, yBinChip);
    317316    pmChipFreeCells(chip);
    318     #else
    319 
    320     chip->cells = psArrayAlloc(0);
    321     #endif
    322 
    323     pmCell *cell = pmCellAlloc(chip, NULL, __func__); // New cell
    324     cellConcepts(cell, cells, xBinChip, yBinChip);
    325 
    326     #if 0
    327     // XXX For the sake of getting something working, I am not going to bother with sorting out where
    328     // the double free is coming from.  I'm going to drop the pointers on the array and create a memory
    329     // leak.  We can clean this up later, when we're not under as much pressure.
    330     psArrayElementsFree(chip->cells);
    331     chip->cells->n = 0;
    332     #endif
    333 
    334     cell->exists = true;
    335     cell->process = true;
    336     pmReadout *readout = pmReadoutAlloc(cell); // New readout
    337     psRegion entire = {0.0, 0.0, 0.0, 0.0};
     317    // Have to put in the new cell manually, since we didn't want to put it in before blowing the cells away.
     318    newCell->parent = chip;
     319    psArrayAdd(chip->cells, 1, newCell);
     320    newCell->exists = true;
     321    newCell->process = true;
     322
     323    // Now make a new readout to go in the new cell
     324    pmReadout *newReadout = pmReadoutAlloc(newCell); // New readout
    338325    // Want the readouts to contain a subimage, but that subimage is the whole image.
    339326    // This preserves the relationship there was before, where freeing the parent frees the child.
    340     readout->image = psImageSubset(image, entire);
    341     readout->weight = psImageSubset(weight, entire);
    342     readout->mask = psImageSubset(mask, entire);
    343     psFree(readout);
     327    psRegion entire = {0.0, 0.0, 0.0, 0.0};
     328    newReadout->image = psImageSubset(image, entire);
     329    newReadout->weight = psImageSubset(weight, entire);
     330    newReadout->mask = psImageSubset(mask, entire);
     331    // Drop references
     332    psFree(newReadout);
     333    psFree(newCell);
    344334
    345335    // Well, we've stuffed around with the camera configuration, so it's no longer valid...
  • branches/eam_rel9_p0/psModules/src/astrom/pmConcepts.c

    r6342 r6351  
    8585{
    8686    switch (blank->type) {
    87     case PS_DATA_STRING:
    88         return psMetadataItemAllocStr(blank->name, blank->comment,
    89                                       pmConceptReadString(fpa, chip, cell, db, blank->name));
     87    case PS_DATA_STRING: {
     88            psString string = pmConceptReadString(fpa, chip, cell, db, blank->name);
     89            psMetadataItem *item = psMetadataItemAllocStr(blank->name, blank->comment, string);
     90            psFree(string);
     91            return item;
     92        }
    9093    case PS_DATA_S32:
    9194        return psMetadataItemAllocS32(blank->name, blank->comment,
     
    152155        }
    153156        psMetadataAddItem(target, conceptItem, PS_LIST_TAIL, PS_META_REPLACE);
     157        psFree(conceptItem);            // Drop reference
    154158    }
    155159    psFree(specsIter);
  • branches/eam_rel9_p0/psModules/src/imsubtract/pmSubtractBias.c

    r6080 r6351  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.6.8.1.2.4 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-01-20 09:47:06 $
     13 *  @version $Revision: 1.6.8.1.2.5 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-02-08 00:52:13 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    376376        break;
    377377    case PM_FIT_POLY_ORD:
    378         overscanOpts->poly = psPolynomial1DAlloc(overscanOpts->order, PS_POLYNOMIAL_ORD);
    379         overscanOpts->poly = psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL,
    380                              ordinate);
     378        if (overscanOpts->poly && (overscanOpts->poly->nX != overscanOpts->order ||
     379                                   overscanOpts->poly->type != PS_POLYNOMIAL_ORD)) {
     380            psFree(overscanOpts->poly);
     381            overscanOpts->poly = psPolynomial1DAlloc(overscanOpts->order, PS_POLYNOMIAL_ORD);
     382        }
     383        psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL, ordinate);
    381384        psFree(reduced);
    382385        reduced = psPolynomial1DEvalVector(overscanOpts->poly, ordinate);
    383386        break;
    384387    case PM_FIT_POLY_CHEBY:
    385         overscanOpts->poly = psPolynomial1DAlloc(overscanOpts->order, PS_POLYNOMIAL_CHEB);
    386         overscanOpts->poly = psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL,
    387                              ordinate);
     388        if (overscanOpts->poly && (overscanOpts->poly->nX != overscanOpts->order ||
     389                                   overscanOpts->poly->type != PS_POLYNOMIAL_CHEB)) {
     390            psFree(overscanOpts->poly);
     391            overscanOpts->poly = psPolynomial1DAlloc(overscanOpts->order, PS_POLYNOMIAL_CHEB);
     392        }
     393        psVectorFitPolynomial1D(overscanOpts->poly, mask, 1, reduced, NULL, ordinate);
    388394        psFree(reduced);
    389395        reduced = psPolynomial1DEvalVector(overscanOpts->poly, ordinate);
     
    501507                // Reduce the overscans
    502508                psVector *reduced = overscanVector(overscanOpts, pixels, myStats);
     509                psFree(pixels);
    503510                if (! reduced) {
    504511                    return in;
     
    544551                // Reduce the overscans
    545552                psVector *reduced = overscanVector(overscanOpts, pixels, myStats);
     553                psFree(pixels);
    546554                if (! reduced) {
    547555                    return in;
Note: See TracChangeset for help on using the changeset viewer.