IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 23, 2004, 1:00:17 PM (22 years ago)
Author:
desonia
Message:

Changed the means of deallocation of memory. ps_Alloc now registers an optional free function to handle any additional processing of a memory object.

Location:
trunk/psLib/src/dataManip
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psFFT.c

    r1010 r1073  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-06-12 02:17:25 $
     7 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-06-23 23:00:15 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535    /* got good image data? */
    3636    if (in==NULL) {
    37         psImageFree(out);
     37        psFree(out);
    3838        return NULL;
    3939    }
     
    4444        psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
    4545                type);
    46         psImageFree(out);
     46        psFree(out);
    4747        return NULL;
    4848    }
     
    5151        psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
    5252                type);
    53         psImageFree(out);
     53        psFree(out);
    5454        return NULL;
    5555
     
    7676    if (plan == NULL) {
    7777        psError(__func__,"Failed to create FFTW plan.");
    78         psImageFree(out);
     78        psFree(out);
    7979        return NULL;
    8080    }
     
    9898
    9999    if (in == NULL) {
    100         psImageFree(out);
     100        psFree(out);
    101101        return NULL;
    102102    }
     
    143143        psError(__func__,"Can not extract real component from given image type (%d).",
    144144                type);
    145         psImageFree(out);
     145        psFree(out);
    146146        return NULL;
    147147    }
     
    158158
    159159    if (in == NULL) {
    160         psImageFree(out);
     160        psFree(out);
    161161        return NULL;
    162162    }
     
    205205        psError(__func__,"Can not extract imaginary component from given image type (%d).",
    206206                type);
    207         psImageFree(out);
     207        psFree(out);
    208208        return NULL;
    209209    }
     
    220220
    221221    if (real == NULL || imag == NULL) {
    222         psImageFree(out);
     222        psFree(out);
    223223        return NULL;
    224224    }
     
    230230    if (imag->type.type != type) {
    231231        psError(__func__,"The inputs to psImageComplex must be the same type.");
    232         psImageFree(out);
     232        psFree(out);
    233233        return NULL;
    234234    }
     
    237237            imag->numRows != numRows) {
    238238        psError(__func__,"The inputs to psImageComplex must be the same dimensions.");
    239         psImageFree(out);
     239        psFree(out);
    240240        return NULL;
    241241    }
     
    243243    if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
    244244        psError(__func__,"The inputs to psImageComplex can not be complex.");
    245         psImageFree(out);
     245        psFree(out);
    246246        return NULL;
    247247    }
     
    249249    if (type != PS_TYPE_F32 && type != PS_TYPE_F64) {
    250250        psError(__func__,"The input type to psImageComplex must be a floating point.");
    251         psImageFree(out);
     251        psFree(out);
    252252        return NULL;
    253253    }
     
    287287        psError(__func__,"Can not merge real and imaginary portions for given image type (%d).",
    288288                type);
    289         psImageFree(out);
     289        psFree(out);
    290290        return NULL;
    291291    }
     
    302302
    303303    if (in == NULL) {
    304         psImageFree(out);
     304        psFree(out);
    305305        return NULL;
    306306    }
     
    347347        psError(__func__,"Can not compute complex conjugate for given image type (%d).",
    348348                type);
    349         psImageFree(out);
     349        psFree(out);
    350350        return NULL;
    351351    }
     
    362362
    363363    if (in == NULL) {
    364         psImageFree(out);
     364        psFree(out);
    365365        return NULL;
    366366    }
     
    374374    if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
    375375        psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
    376         psImageFree(out);
     376        psFree(out);
    377377        return NULL;
    378378    }
     
    417417        psError(__func__,"Can not power spectrum for given image type (%d).",
    418418                type);
    419         psImageFree(out);
     419        psFree(out);
    420420        return NULL;
    421421    }
     
    435435    /* got good image data? */
    436436    if (in==NULL) {
    437         psVectorFree(out);
     437        psFree(out);
    438438        return NULL;
    439439    }
     
    444444        psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
    445445                type);
    446         psVectorFree(out);
     446        psFree(out);
    447447        return NULL;
    448448    }
     
    451451        psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
    452452                type);
    453         psVectorFree(out);
     453        psFree(out);
    454454        return NULL;
    455455
     
    491491    if (plan == NULL) {
    492492        psError(__func__,"Failed to create FFTW plan.");
    493         psVectorFree(out);
     493        psFree(out);
    494494        return NULL;
    495495    }
     
    510510
    511511    if (in == NULL) {
    512         psVectorFree(out);
     512        psFree(out);
    513513        return NULL;
    514514    }
     
    542542        psError(__func__,"Can not extract real component from given vector type (%d).",
    543543                type);
    544         psVectorFree(out);
     544        psFree(out);
    545545        return NULL;
    546546    }
     
    556556
    557557    if (in == NULL) {
    558         psVectorFree(out);
     558        psFree(out);
    559559        return NULL;
    560560    }
     
    588588        psError(__func__,"Can not extract imaginary component from given vector type (%d).",
    589589                type);
    590         psVectorFree(out);
     590        psFree(out);
    591591        return NULL;
    592592    }
     
    602602
    603603    if (real == NULL || imag == NULL) {
    604         psVectorFree(out);
     604        psFree(out);
    605605        return NULL;
    606606    }
     
    615615    if (imag->type.type != type) {
    616616        psError(__func__,"The inputs to psVectorComplex must be the same type.");
    617         psVectorFree(out);
     617        psFree(out);
    618618        return NULL;
    619619    }
     
    621621    if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
    622622        psError(__func__,"The inputs to psVectorComplex can not be complex.");
    623         psVectorFree(out);
     623        psFree(out);
    624624        return NULL;
    625625    }
     
    640640        psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).",
    641641                type);
    642         psVectorFree(out);
     642        psFree(out);
    643643        return NULL;
    644644    }
     
    654654
    655655    if (in == NULL) {
    656         psVectorFree(out);
     656        psFree(out);
    657657        return NULL;
    658658    }
     
    687687        psError(__func__,"Can not compute complex conjugate for given vector type (%d).",
    688688                type);
    689         psVectorFree(out);
     689        psFree(out);
    690690        return NULL;
    691691    }
     
    703703
    704704    if (in == NULL) {
    705         psVectorFree(out);
     705        psFree(out);
    706706        return NULL;
    707707    }
     
    716716    if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
    717717        psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
    718         psVectorFree(out);
     718        psFree(out);
    719719        return NULL;
    720720    }
     
    747747        psError(__func__,"Can not power spectrum for given vector type (%d).",
    748748                type);
    749         psVectorFree(out);
    750         return NULL;
    751     }
    752 
    753     return out;
    754 
    755 }
     749        psFree(out);
     750        return NULL;
     751    }
     752
     753    return out;
     754
     755}
  • trunk/psLib/src/dataManip/psFunctions.c

    r1022 r1073  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-06-14 19:40:14 $
     9 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-06-23 23:00:15 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434#include <gsl/gsl_rng.h>
    3535#include <gsl/gsl_randist.h>
     36
     37static void polynomial1DFree(psPolynomial1D *myPoly);
     38static void polynomial2DFree(psPolynomial2D *myPoly);
     39static void polynomial3DFree(psPolynomial3D *myPoly);
     40static void polynomial4DFree(psPolynomial4D *myPoly);
     41static void dPolynomial1DFree(psDPolynomial1D *myPoly);
     42static void dPolynomial2DFree(psDPolynomial2D *myPoly);
     43static void dPolynomial3DFree(psDPolynomial3D *myPoly);
     44static void dPolynomial4DFree(psDPolynomial4D *myPoly);
     45
    3646/*****************************************************************************/
    3747/*  FUNCTION IMPLEMENTATION - PUBLIC                                         */
     
    108118
    109119    newPoly = (psPolynomial1D *) psAlloc(sizeof(psPolynomial1D));
     120    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial1DFree);
    110121    newPoly->n = n;
    111122    newPoly->coeff    = (float *) psAlloc(n * sizeof(float));
     
    128139
    129140    newPoly = (psPolynomial2D *) psAlloc(sizeof(psPolynomial2D));
     141    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial2DFree);
    130142    newPoly->nX = nX;
    131143    newPoly->nY = nY;
     
    158170
    159171    newPoly = (psPolynomial3D *) psAlloc(sizeof(psPolynomial3D));
     172    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial3DFree);
    160173    newPoly->nX = nX;
    161174    newPoly->nY = nY;
     
    197210
    198211    newPoly = (psPolynomial4D *) psAlloc(sizeof(psPolynomial4D));
     212    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial4DFree);
    199213    newPoly->nW = nW;
    200214    newPoly->nX = nX;
     
    235249}
    236250
    237 void psPolynomial1DFree(psPolynomial1D *myPoly)
     251static void polynomial1DFree(psPolynomial1D *myPoly)
    238252{
    239253    psFree(myPoly->coeff);
    240254    psFree(myPoly->coeffErr);
    241255    psFree(myPoly->mask);
    242     psFree(myPoly);
    243 }
    244 
    245 void psPolynomial2DFree(psPolynomial2D *myPoly)
     256}
     257
     258static void polynomial2DFree(psPolynomial2D *myPoly)
    246259{
    247260    int x = 0;
     
    255268    psFree(myPoly->coeffErr);
    256269    psFree(myPoly->mask);
    257 
    258     psFree(myPoly);
    259 }
    260 
    261 void psPolynomial3DFree(psPolynomial3D *myPoly)
     270}
     271
     272static void polynomial3DFree(psPolynomial3D *myPoly)
    262273{
    263274    int x = 0;
     
    278289    psFree(myPoly->coeffErr);
    279290    psFree(myPoly->mask);
    280     psFree(myPoly);
    281 }
    282 
    283 void psPolynomial4DFree(psPolynomial4D *myPoly)
     291}
     292
     293static void polynomial4DFree(psPolynomial4D *myPoly)
    284294{
    285295    int w = 0;
     
    306316    psFree(myPoly->coeffErr);
    307317    psFree(myPoly->mask);
    308     psFree(myPoly);
    309318}
    310319
     
    434443
    435444    newPoly = (psDPolynomial1D *) psAlloc(sizeof(psDPolynomial1D));
     445    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial1DFree);
    436446    newPoly->n = n;
    437447    newPoly->coeff    = (double *) psAlloc(n * sizeof(double));
     
    454464
    455465    newPoly = (psDPolynomial2D *) psAlloc(sizeof(psDPolynomial2D));
     466    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial2DFree);
    456467    newPoly->nX = nX;
    457468    newPoly->nY = nY;
     
    484495
    485496    newPoly = (psDPolynomial3D *) psAlloc(sizeof(psDPolynomial3D));
     497    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial3DFree);
    486498    newPoly->nX = nX;
    487499    newPoly->nY = nY;
     
    523535
    524536    newPoly = (psDPolynomial4D *) psAlloc(sizeof(psDPolynomial4D));
     537    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial4DFree);
    525538    newPoly->nW = nW;
    526539    newPoly->nX = nX;
     
    561574}
    562575
    563 void psDPolynomial1DFree(psDPolynomial1D *myPoly)
     576static void dPolynomial1DFree(psDPolynomial1D *myPoly)
    564577{
    565578    psFree(myPoly->coeff);
    566579    psFree(myPoly->coeffErr);
    567580    psFree(myPoly->mask);
    568     psFree(myPoly);
    569 }
    570 
    571 void psDPolynomial2DFree(psDPolynomial2D *myPoly)
     581}
     582
     583static void dPolynomial2DFree(psDPolynomial2D *myPoly)
    572584{
    573585    int x = 0;
     
    581593    psFree(myPoly->coeffErr);
    582594    psFree(myPoly->mask);
    583 
    584     psFree(myPoly);
    585 }
    586 
    587 void psDPolynomial3DFree(psDPolynomial3D *myPoly)
     595}
     596
     597static void dPolynomial3DFree(psDPolynomial3D *myPoly)
    588598{
    589599    int x = 0;
     
    604614    psFree(myPoly->coeffErr);
    605615    psFree(myPoly->mask);
    606     psFree(myPoly);
    607 }
    608 
    609 void psDPolynomial4DFree(psDPolynomial4D *myPoly)
     616}
     617
     618static void dPolynomial4DFree(psDPolynomial4D *myPoly)
    610619{
    611620    int w = 0;
     
    632641    psFree(myPoly->coeffErr);
    633642    psFree(myPoly->mask);
    634     psFree(myPoly);
    635643}
    636644
  • trunk/psLib/src/dataManip/psFunctions.h

    r1020 r1073  
    1212 *  @author George Gusciora, MHPCC
    1313 *
    14  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-06-14 19:32:42 $
     14 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-06-23 23:00:15 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    104104                                   );
    105105
    106 /** Destructor */
    107 void psPolynomial1DFree(psPolynomial1D *myPoly ///< Polynomial to destroy
    108                        );
    109 
    110 /** Destructor */
    111 void psPolynomial2DFree(psPolynomial2D *myPoly ///< Polynomial to destroy
    112                        );
    113 /** Destructor */
    114 void psPolynomial3DFree(psPolynomial3D *myPoly ///< Polynomial to destroy
    115                        );
    116 /** Destructor */
    117 void psPolynomial4DFree(psPolynomial4D *myPoly ///< Polynomial to destroy
    118                        );
    119 
    120 
    121106/** Evaluate 1D polynomial */
    122107float
     
    206191                                     );
    207192
    208 
    209 /** Destructor */
    210 void psDPolynomial1DFree(psDPolynomial1D *myPoly ///< Polynomial to destroy
    211                         );
    212 /** Destructor */
    213 void psDPolynomial2DFree(psDPolynomial2D *myPoly ///< Polynomial to destroy
    214                         );
    215 /** Destructor */
    216 void psDPolynomial3DFree(psDPolynomial3D *myPoly ///< Polynomial to destroy
    217                         );
    218 /** Destructor */
    219 void psDPolynomial4DFree(psDPolynomial4D *myPoly ///< Polynomial to destroy
    220                         );
    221 
    222 
    223193/** Evaluate 1D polynomial (double precision) */
    224194double
  • trunk/psLib/src/dataManip/psStats.c

    r1071 r1073  
    3232                           psStats *stats);
    3333#endif
     34
     35static void histogramFree(psHistogram *myHist);
    3436
    3537/******************************************************************************
     
    6870
    6971/******************************************************************************
    70     psStatsFree(): This routine must free the psStats data structure.
    71  *****************************************************************************/
    72 void psStatsFree(psStats *stats)
    73 {
    74     psFree(stats);
    75 }
    76 
    77 /******************************************************************************
    7872psHistogramAlloc(lower, upper, n): allocate a uniform histogram structure
    7973with the specifed upper and lower limits, and the specifed number of bins.
     
    108102    // bins, then there are N+1 bounds to those bins.
    109103    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
     104    p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree);
    110105    newHist->bounds = psVectorAlloc(n+1, PS_TYPE_F32);
    111106    newHist->bounds->n = newHist->bounds->nalloc;
     
    160155    // Allocate memory for the new histogram structure.
    161156    newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
     157    p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree);
    162158    newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
    163159    newHist->bounds->n = newHist->bounds->nalloc;
     
    182178}
    183179
    184 void psHistogramFree(psHistogram *myHist)
    185 {
    186     psVectorFree(myHist->bounds);
    187     psVectorFree(myHist->nums);
    188     psFree(myHist);
     180static void histogramFree(psHistogram *myHist)
     181{
     182    psFree(myHist->bounds);
     183    psFree(myHist->nums);
    189184}
    190185
     
    618613
    619614        // Free temporary data buffers.
    620         psStatsFree(stats2);
     615        psFree(stats2);
    621616
    622617        // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure.
     
    688683
    689684    // Free the temporary data structures.
    690     psVectorFree(unsortedVector);
    691     psVectorFree(sortedVector);
     685    psFree(unsortedVector);
     686    psFree(sortedVector);
    692687}
    693688
     
    775770
    776771        // Free temporary data buffers.
    777         psStatsFree(stats2);
     772        psFree(stats2);
    778773
    779774        // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure.
     
    840835
    841836    // Free the temporary data structures.
    842     psVectorFree(unsortedVector);
    843     psVectorFree(sortedVector);
     837    psFree(unsortedVector);
     838    psFree(sortedVector);
    844839    // NOTE: This is the
    845840}
     
    10431038    }
    10441039
    1045     psVectorFree(tmpMask);
     1040    psFree(tmpMask);
    10461041}
    10471042
     
    11251120            stats->robustLQ = stats->clippedMean;
    11261121        }
    1127         psStatsFree(tmpStats);
    1128         psHistogramFree(robustHistogram);
     1122        psFree(tmpStats);
     1123        psFree(robustHistogram);
    11291124        return;
    11301125    }
     
    12001195    stats->robustNfit = 0.0;
    12011196    stats->robustN50 = 0.0;
    1202     psStatsFree(tmpStats);
    1203     psHistogramFree(robustHistogram);
     1197    psFree(tmpStats);
     1198    psFree(robustHistogram);
    12041199}
    12051200
  • trunk/psLib/src/dataManip/psStats.h

    r1020 r1073  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-06-14 19:33:09 $
     11 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-06-23 23:00:15 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8888psStats *psStatsAlloc(psStatsOptions options); ///< Statistics to measure
    8989
    90 /** A destructor for the stats structure.*/
    91 void psStatsFree(psStats *restrict stats); ///< Stats structure to destroy
    92 
    9390/******************************************************************************
    9491    Histogram functions and data structures.
     
    116113psHistogram * psHistogramAllocGeneric(const psVector *restrict bounds); ///< Bounds for the bins
    117114
    118 
    119 /** Destructor \ingroup MathGroup **/
    120 void psHistogramFree(psHistogram *myHist);          ///< Histogram to destroy
    121 
    122 
    123115/** Calculate a histogram \ingroup MathGroup **/
    124116psHistogram *psHistogramVector (psHistogram *out,   ///< Histogram data
  • trunk/psLib/src/dataManip/psVectorFFT.c

    r1010 r1073  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-06-12 02:17:25 $
     7 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-06-23 23:00:15 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535    /* got good image data? */
    3636    if (in==NULL) {
    37         psImageFree(out);
     37        psFree(out);
    3838        return NULL;
    3939    }
     
    4444        psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
    4545                type);
    46         psImageFree(out);
     46        psFree(out);
    4747        return NULL;
    4848    }
     
    5151        psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
    5252                type);
    53         psImageFree(out);
     53        psFree(out);
    5454        return NULL;
    5555
     
    7676    if (plan == NULL) {
    7777        psError(__func__,"Failed to create FFTW plan.");
    78         psImageFree(out);
     78        psFree(out);
    7979        return NULL;
    8080    }
     
    9898
    9999    if (in == NULL) {
    100         psImageFree(out);
     100        psFree(out);
    101101        return NULL;
    102102    }
     
    143143        psError(__func__,"Can not extract real component from given image type (%d).",
    144144                type);
    145         psImageFree(out);
     145        psFree(out);
    146146        return NULL;
    147147    }
     
    158158
    159159    if (in == NULL) {
    160         psImageFree(out);
     160        psFree(out);
    161161        return NULL;
    162162    }
     
    205205        psError(__func__,"Can not extract imaginary component from given image type (%d).",
    206206                type);
    207         psImageFree(out);
     207        psFree(out);
    208208        return NULL;
    209209    }
     
    220220
    221221    if (real == NULL || imag == NULL) {
    222         psImageFree(out);
     222        psFree(out);
    223223        return NULL;
    224224    }
     
    230230    if (imag->type.type != type) {
    231231        psError(__func__,"The inputs to psImageComplex must be the same type.");
    232         psImageFree(out);
     232        psFree(out);
    233233        return NULL;
    234234    }
     
    237237            imag->numRows != numRows) {
    238238        psError(__func__,"The inputs to psImageComplex must be the same dimensions.");
    239         psImageFree(out);
     239        psFree(out);
    240240        return NULL;
    241241    }
     
    243243    if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
    244244        psError(__func__,"The inputs to psImageComplex can not be complex.");
    245         psImageFree(out);
     245        psFree(out);
    246246        return NULL;
    247247    }
     
    249249    if (type != PS_TYPE_F32 && type != PS_TYPE_F64) {
    250250        psError(__func__,"The input type to psImageComplex must be a floating point.");
    251         psImageFree(out);
     251        psFree(out);
    252252        return NULL;
    253253    }
     
    287287        psError(__func__,"Can not merge real and imaginary portions for given image type (%d).",
    288288                type);
    289         psImageFree(out);
     289        psFree(out);
    290290        return NULL;
    291291    }
     
    302302
    303303    if (in == NULL) {
    304         psImageFree(out);
     304        psFree(out);
    305305        return NULL;
    306306    }
     
    347347        psError(__func__,"Can not compute complex conjugate for given image type (%d).",
    348348                type);
    349         psImageFree(out);
     349        psFree(out);
    350350        return NULL;
    351351    }
     
    362362
    363363    if (in == NULL) {
    364         psImageFree(out);
     364        psFree(out);
    365365        return NULL;
    366366    }
     
    374374    if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
    375375        psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
    376         psImageFree(out);
     376        psFree(out);
    377377        return NULL;
    378378    }
     
    417417        psError(__func__,"Can not power spectrum for given image type (%d).",
    418418                type);
    419         psImageFree(out);
     419        psFree(out);
    420420        return NULL;
    421421    }
     
    435435    /* got good image data? */
    436436    if (in==NULL) {
    437         psVectorFree(out);
     437        psFree(out);
    438438        return NULL;
    439439    }
     
    444444        psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
    445445                type);
    446         psVectorFree(out);
     446        psFree(out);
    447447        return NULL;
    448448    }
     
    451451        psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
    452452                type);
    453         psVectorFree(out);
     453        psFree(out);
    454454        return NULL;
    455455
     
    491491    if (plan == NULL) {
    492492        psError(__func__,"Failed to create FFTW plan.");
    493         psVectorFree(out);
     493        psFree(out);
    494494        return NULL;
    495495    }
     
    510510
    511511    if (in == NULL) {
    512         psVectorFree(out);
     512        psFree(out);
    513513        return NULL;
    514514    }
     
    542542        psError(__func__,"Can not extract real component from given vector type (%d).",
    543543                type);
    544         psVectorFree(out);
     544        psFree(out);
    545545        return NULL;
    546546    }
     
    556556
    557557    if (in == NULL) {
    558         psVectorFree(out);
     558        psFree(out);
    559559        return NULL;
    560560    }
     
    588588        psError(__func__,"Can not extract imaginary component from given vector type (%d).",
    589589                type);
    590         psVectorFree(out);
     590        psFree(out);
    591591        return NULL;
    592592    }
     
    602602
    603603    if (real == NULL || imag == NULL) {
    604         psVectorFree(out);
     604        psFree(out);
    605605        return NULL;
    606606    }
     
    615615    if (imag->type.type != type) {
    616616        psError(__func__,"The inputs to psVectorComplex must be the same type.");
    617         psVectorFree(out);
     617        psFree(out);
    618618        return NULL;
    619619    }
     
    621621    if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
    622622        psError(__func__,"The inputs to psVectorComplex can not be complex.");
    623         psVectorFree(out);
     623        psFree(out);
    624624        return NULL;
    625625    }
     
    640640        psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).",
    641641                type);
    642         psVectorFree(out);
     642        psFree(out);
    643643        return NULL;
    644644    }
     
    654654
    655655    if (in == NULL) {
    656         psVectorFree(out);
     656        psFree(out);
    657657        return NULL;
    658658    }
     
    687687        psError(__func__,"Can not compute complex conjugate for given vector type (%d).",
    688688                type);
    689         psVectorFree(out);
     689        psFree(out);
    690690        return NULL;
    691691    }
     
    703703
    704704    if (in == NULL) {
    705         psVectorFree(out);
     705        psFree(out);
    706706        return NULL;
    707707    }
     
    716716    if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
    717717        psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
    718         psVectorFree(out);
     718        psFree(out);
    719719        return NULL;
    720720    }
     
    747747        psError(__func__,"Can not power spectrum for given vector type (%d).",
    748748                type);
    749         psVectorFree(out);
    750         return NULL;
    751     }
    752 
    753     return out;
    754 
    755 }
     749        psFree(out);
     750        return NULL;
     751    }
     752
     753    return out;
     754
     755}
Note: See TracChangeset for help on using the changeset viewer.