IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17371


Ignore:
Timestamp:
Apr 7, 2008, 2:16:31 PM (18 years ago)
Author:
Paul Price
Message:

Fixed so that sample can be used as a buffer (to save allocating over
and over; at least, that's what I thought it was for until I ran into
lots of memory leaks due to the function overwriting the used
pointer). It should still give the correct output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageBackground.c

    r15938 r17371  
    4242    const int Nsubset = (stats->nSubsample == 0) ? Npixels : PS_MIN(stats->nSubsample, Npixels); // Number of pixels in subset
    4343
    44     psVector *values = psVectorAllocEmpty(Nsubset, PS_TYPE_F32); // Vector containing subsample
     44    psVector *values;                   // Vector containing subsample
     45    if (sample) {
     46        *sample = psVectorRecycle(*sample, Nsubset, PS_TYPE_F32);
     47        values = psMemIncrRefCounter(*sample);
     48        values->n = 0;
     49    } else {
     50        values = psVectorAllocEmpty(Nsubset, PS_TYPE_F32);
     51    }
    4552
    4653    // Minimum and maximum values
     
    6774    }
    6875    if (n < 0.01*Nsubset) {
    69         psLogMsg ("psLib", PS_LOG_INFO, "too few data points");
    70         psFree (values);
    71         return false;
     76        psLogMsg ("psLib", PS_LOG_INFO, "too few data points");
     77        psFree (values);
     78        return false;
    7279    }
    7380
     
    121128    }
    122129
    123     if (sample != NULL) {
    124         *sample = values;
    125     } else {
    126         psFree(values);
    127     }
     130    psFree(values);
     131
    128132    return true;
    129133}
Note: See TracChangeset for help on using the changeset viewer.