IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42806 for trunk/psModules


Ignore:
Timestamp:
May 8, 2025, 11:18:19 AM (14 months ago)
Author:
eugene
Message:

fix memleak in pmDark

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psModules

  • trunk/psModules/src/detrend/pmDark.c

    r42379 r42806  
    252252    }
    253253
     254# if (PS_TRACE_ON)
    254255    if (psTraceGetLevel("psModules.detrend") > 9) {
    255256        for (int i = 0; i < inputs->n; i++) {
    256257            psVector *val = values->data[i];
    257             (void) val; // avoid unused variable message when tracing is compiled out
    258258            for (int j = 0; j < ordinates->n; j++) {
    259259                psTrace("psModules.detrend", 9, "Image %d, ordinate %d: %f\n", i, j, val->data.F32[j]);
     
    261261        }
    262262    }
     263# endif
    263264
    264265    int numTerms = 1;                   // Number of terms in polynomial
     
    292293        pmReadout *readout = output->readouts->data[i]; // Readout to update
    293294        if (!readout) {
    294             readout = output->readouts->data[i] = pmReadoutAlloc(output);
    295         }
    296 
     295            // pmReadoutAlloc places a reference to the readout on cell->readouts
     296            // and returns a second mem reference to the readout
     297            readout = pmReadoutAlloc(output);
     298            psFree (readout); // free the extra mem reference returned by pmReadoutAlloc
     299        }
    297300        pmReadoutStackDefineOutput(readout, col0, row0, numCols, numRows, false, false, 0);
    298301        psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", col0, row0);
     
    469472              for (int m = 0; m < poly->deviations->n; m++) {
    470473                logL->data.F64[k] += pow(poly->deviations->data.F32[m] / polySig->stdevFit,2);
    471 /*              if ((xOut == 20) && (yOut == 256)) { */
    472 /*                psTrace("psModules.detrend",3,"pmDarkCombine DEV: %d %d: input %d models: Norders: %d logL: %g value: %g\n", */
    473 /*                        xOut,yOut,m,k,logL->data.F64[k],poly->deviations->data.F32[m]); */
    474 /*              } */
    475474              }
    476475              if (k > 0) {
     
    487486              k_best = 1;
    488487            }
    489 /*          k_best = 1; */
     488
    490489            // Select the polynomial that seems best.
    491490            psPolynomialMD *poly = poly_set->data[k_best];
    492491             
    493             //            for (int k = 0; k < poly->coeff->n; k++) {
    494492            for (int k = 0; k < max_orders->n + 1; k++) { // There is one more coefficient than is stored here.
    495493                pmReadout *ro = output->readouts->data[k]; // Readout of interest
    496494                if (k < poly->coeff->n) {
    497495                  ro->image->data.F32[yOut][xOut] = poly->coeff->data.F64[k];
    498                 }
    499                 else {
     496                } else {
    500497                  ro->image->data.F32[yOut][xOut] = 0.0;
    501498                }
Note: See TracChangeset for help on using the changeset viewer.