IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17568


Ignore:
Timestamp:
May 7, 2008, 2:04:11 PM (18 years ago)
Author:
Paul Price
Message:

Plugging memory leak.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotModelBackground.c

    r16820 r17568  
    163163            // XXX don't bother trying if there are no valid pixels...
    164164
    165             psVector *sample = NULL;
    166 
    167             // turn on stats tracing in desired cells
    168             # if (0)
    169             psMetadata *plots = psMetadataLookupPtr (&status, recipe, "DIAGNOSTIC.PLOTS");
    170             assert (plots);
    171            
    172             int xPlot = psMetadataLookupS32 (&status, plots, "IMAGE.BACKGROUND.CELL.HISTOGRAM.X");
    173             assert (status);
    174             int yPlot = psMetadataLookupS32 (&status, plots, "IMAGE.BACKGROUND.CELL.HISTOGRAM.Y");
    175             assert (status);
    176 
    177             bool gotX = (xPlot < 0) || (xPlot == ix);
    178             bool gotY = (yPlot < 0) || (yPlot == iy);
    179 
    180             if (gotX && gotY) {
    181                 psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 6);
    182                 psTraceSetLevel ("psLib.math.vectorRobustStats", 6);
    183             } else {
    184                 psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 0);
    185                 psTraceSetLevel ("psLib.math.vectorRobustStats", 0);
    186             }       
    187             # endif
     165            psVector *sample = NULL;
     166
     167            // turn on stats tracing in desired cells
     168            # if (0)
     169            psMetadata *plots = psMetadataLookupPtr (&status, recipe, "DIAGNOSTIC.PLOTS");
     170            assert (plots);
     171
     172            int xPlot = psMetadataLookupS32 (&status, plots, "IMAGE.BACKGROUND.CELL.HISTOGRAM.X");
     173            assert (status);
     174            int yPlot = psMetadataLookupS32 (&status, plots, "IMAGE.BACKGROUND.CELL.HISTOGRAM.Y");
     175            assert (status);
     176
     177            bool gotX = (xPlot < 0) || (xPlot == ix);
     178            bool gotY = (yPlot < 0) || (yPlot == iy);
     179
     180            if (gotX && gotY) {
     181                psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 6);
     182                psTraceSetLevel ("psLib.math.vectorRobustStats", 6);
     183            } else {
     184                psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 0);
     185                psTraceSetLevel ("psLib.math.vectorRobustStats", 0);
     186            }
     187            # endif
    188188
    189189            if (psImageBackground(stats, &sample, subset, submask, maskVal, rng)) {
     
    195195                modelStdevData[iy][ix] = psStatsGetValue(stats, statsOptionWidth);
    196196
    197                 // supply sample to plotting routing
    198                 psphotDiagnosticPlots (config, "IMAGE.BACKGROUND.CELL.HISTOGRAM", ix, iy, modelData[iy][ix], modelStdevData[iy][ix], sample);
    199                 psFree (sample);
     197                // supply sample to plotting routing
     198                psphotDiagnosticPlots (config, "IMAGE.BACKGROUND.CELL.HISTOGRAM", ix, iy, modelData[iy][ix], modelStdevData[iy][ix], sample);
    200199            } else {
    201200                psStatsOptions currentOptions = stats->options;
     
    210209                    modelStdevData[iy][ix] = psStatsGetValue(stats, PS_STAT_ROBUST_STDEV);
    211210
    212                     // supply sample to plotting routing
    213                     psphotDiagnosticPlots (config, "IMAGE.BACKGROUND.CELL.HISTOGRAM", ix, iy, modelData[iy][ix], modelStdevData[iy][ix], sample);
    214                     psFree (sample);
     211                    // supply sample to plotting routing
     212                    psphotDiagnosticPlots (config, "IMAGE.BACKGROUND.CELL.HISTOGRAM", ix, iy, modelData[iy][ix], modelStdevData[iy][ix], sample);
    215213                }
    216214                // drop errors caused by psImageBackground failures
     
    219217                stats->options = currentOptions;
    220218            }
     219            psFree(sample);
    221220            modelData[iy][ix] += SKY_BIAS;
    222221            psFree (subset);
     
    263262    if (Count == 0) {
    264263        psError (PSPHOT_ERR_DATA, true, "failed to build background image");
    265         psFree(stats);
    266         psFree(statsDefaults);
    267         psFree(binning);
    268         psFree(rng);
     264        psFree(stats);
     265        psFree(statsDefaults);
     266        psFree(binning);
     267        psFree(rng);
    269268        return false;
    270269    }
Note: See TracChangeset for help on using the changeset viewer.