IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

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

File:
1 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...
Note: See TracChangeset for help on using the changeset viewer.