IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1073 for trunk/psLib/src


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
Files:
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psBitSet.c

    r1041 r1073  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-15 02:45:43 $
     12 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-23 23:00:15 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5555/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    5656/*****************************************************************************/
     57static void bitSetFree(psBitSet *restrict inBitSet);
     58
    5759
    5860/** Private function to create a mask.
     
    8890    numBytes = ceil(n/8.0);
    8991    newObj = psAlloc(sizeof(psBitSet));
     92    p_psMemSetDeallocator(newObj,(psFreeFcn)bitSetFree);
    9093    newObj->n = numBytes;
    9194
     
    98101}
    99102
    100 void psBitSetFree(psBitSet *restrict inBitSet)
     103static void bitSetFree(psBitSet *restrict inBitSet)
    101104{
    102105    if(inBitSet == NULL) {
     
    105108    }
    106109    psFree(inBitSet->bits);
    107     psFree(inBitSet);
    108110}
    109111
  • trunk/psLib/src/collections/psBitSet.h

    r974 r1073  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-06-10 01:58:06 $
     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
     
    5454psBitSet* psBitSetAlloc(
    5555    int n   /**< Number of bits in psBitSet array */
    56 );
    57 
    58 /** Free a psBitSet
    59  *
    60  *  Deletes a psBitSet array.
    61  */
    62 void psBitSetFree(
    63     psBitSet *restrict inMask  /**< Pointer to psBitSet to be deleted. */
    6456);
    6557
  • trunk/psLib/src/collections/psList.c

    r1024 r1073  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-14 19:45:46 $
     8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-23 23:00:15 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828
    2929// private functions.
    30 psListElem* listGetIterator(psList* list);
    31 int listGetIteratorIndex(psList* list);
    32 void listSetIterator(psList *list, int where, bool lockList);
     30static psListElem* listGetIterator(psList* list);
     31static int listGetIteratorIndex(psList* list);
     32static void listSetIterator(psList *list, int where, bool lockList);
     33static void listFree(psList *list);
    3334
    3435
     
    3637{
    3738    psList *list = psAlloc(sizeof(psList));
     39    p_psMemSetDeallocator(list,(psFreeFcn)listFree);
    3840
    3941    list->size = 0;
     
    4143    list->iter = ITER_INIT_HEAD;
    4244    list->iterIndex = PS_LIST_HEAD;
     45
    4346    pthread_mutex_init(&(list->lock),NULL)
    4447    ;
     
    5154}
    5255
    53 void psListFree(psList *list, psFreeFcn elemFree)
     56static void listFree(psList *list)
    5457{
    5558    if (list == NULL) {
     
    6366        psListElem *next = ptr->next;
    6467
    65         p_psCustomFree(elemFree, psMemDecrRefCounter(ptr->data));
     68        psFree(ptr->data);
    6669        psFree(ptr);
    6770
     
    7578    ;
    7679
    77     psFree(list);
    7880}
    7981
  • trunk/psLib/src/collections/psList.h

    r1017 r1073  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-12 22:15:39 $
     12 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-23 23:00:15 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7373)
    7474;
    75 
    76 #include "psMemory.h"
    77 /** Destroys a psList linked list object.  This also frees the elements of the
    78  *  list using the psFreeFcn given, if any.  If no psFreeFcn is specified,
    79  *  the elements are just dereferenced via psMemDecrRefCounter(...).
    80  *
    81  */
    82 void psListFree(
    83     psList* restrict list,              ///< list to destroy
    84     psFreeFcn elemFree                  ///< destructor for data on list
    85 );
    8675
    8776/** Adds an element to a psList at position given.
  • trunk/psLib/src/collections/psSort.c

    r989 r1073  
    1414 *  @author Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2004-06-10 23:15:08 $
     16 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2004-06-23 23:00:15 $
    1818 *
    1919 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3333#include "psSort.h"
    3434#include "psError.h"
     35#include "psMemory.h"
    3536
    3637/******************************************************************************/
     
    242243
    243244    // Free temp memory
    244     psVectorFree(tmpVector);
     245    psFree(tmpVector);
    245246
    246247    return outVector;
  • trunk/psLib/src/collections/psSort.d

    r986 r1073  
    1 psSort.o psSort.d : psSort.c psVector.h psType.h psSort.h ../sysUtils/psError.h
     1psSort.o psSort.d : psSort.c psVector.h psType.h psSort.h ../sysUtils/psError.h \
     2  ../sysUtils/psMemory.h
  • trunk/psLib/src/collections/psVector.c

    r1008 r1073  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-06-12 01:33:16 $
     10 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-06-23 23:00:15 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4949/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    5050/*****************************************************************************/
     51static void vectorFree(psVector *restrict psVec);
    5152
    5253/*****************************************************************************/
     
    6869    // Create vector struct
    6970    psVec = (psVector *)psAlloc(sizeof(psVector));
     71    p_psMemSetDeallocator(psVec,(psFreeFcn)vectorFree);
    7072
    7173    psVec->type.dimen = PS_DIMEN_VECTOR;
     
    132134    if(nalloc < 1) {
    133135        psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
    134         psVectorFree(in);
     136        psFree(in);
    135137        return NULL;
    136138    }
     
    154156}
    155157
    156 void psVectorFree(psVector *restrict psVec)
     158static void vectorFree(psVector *restrict psVec)
    157159{
    158160    if (psVec == NULL) {
     
    160162    }
    161163
     164    if (psVec->type.type == PS_TYPE_PTR) {
     165        for(int i = 0; i < psVec->n; i++) {
     166            psFree(psVec->data.PTR[i]);
     167            psVec->data.PTR[i] = NULL;
     168        }
     169    }
     170
    162171    psFree(psVec->data.V);
    163     psFree(psVec);
    164172}
    165173
    166 void psVectorElementFree(psVector *restrict psVec, void (*elemFree)(void *))
     174void psVectorElementFree(psVector *restrict psVec)
    167175{
    168176
     
    176184    }
    177185
    178     for(int i = 0; i < psVec->nalloc; i++) {
    179         if(elemFree == NULL) {
    180             psMemDecrRefCounter(psVec->data.PTR[i]);
    181         } else {
    182             elemFree(psMemDecrRefCounter(psVec->data.PTR[i]));
    183         }
     186    for(int i = 0; i < psVec->n; i++) {
     187        psFree(psVec->data.PTR[i]);
    184188        psVec->data.PTR[i] = NULL;
    185189    }
  • trunk/psLib/src/collections/psVector.h

    r974 r1073  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-06-10 01:58:06 $
     13 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-06-23 23:00:15 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    100100);
    101101
    102 /** Deallocate a vector.
    103  *
    104  * Uses psLib memory allocation functions to deallocate a vector collection of data. The vector is deallocated
    105  * according to the psType type member contained within the vector.
    106  *
    107  * @return psVector*: Pointer to psVector.
    108  *
    109  */
    110 void psVectorFree(
    111     psVector *restrict psVec  ///< Vector to free.
    112 );
    113 
    114 
    115102/** Deallocate/Dereference elements of a void pointer vector.
    116103 *
     
    122109 */
    123110void psVectorElementFree(
    124     psVector *restrict psVec,   ///< Void pointer vector to destroy.
    125     void (*elemFree)(void *)    ///< Optional callback function to remove vector elements.
     111    psVector *restrict psVec    ///< Void pointer vector to destroy.
    126112);
    127113
  • 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}
  • trunk/psLib/src/fft/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}
  • trunk/psLib/src/image/psImage.c

    r996 r1073  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-06-11 02:02:53 $
     11 *  @version $Revision: 1.29 $ $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
     
    2828#include "psImage.h"
    2929
     30static void imageFree(psImage* image);
    3031
    3132/*****************************************************************************/
     
    4950
    5051    psImage *image = (psImage *)psAlloc(sizeof(psImage));
     52    p_psMemSetDeallocator(image,(psFreeFcn)imageFree);
    5153
    5254    image->data.V = psAlloc(sizeof(void*)*numRows);
     
    7173}
    7274
    73 void psImageFree(psImage *image)
     75static void imageFree(psImage* image)
    7476{
    7577    if (image == NULL) {
     
    9698    psFree(image->data.V);
    9799    image->data.V = NULL;
    98 
    99     psFree(image);
    100100}
    101101
     
    237237        if (children[i] != NULL) {
    238238            numFreed++;
    239             psImageFree(children[i]);
     239            psFree(children[i]);
    240240        }
    241241    }
     
    341341    case PS_TYPE_PTR: \
    342342        psError(__func__,"Can't copy image from a matrix of pointers."); \
    343         psImageFree(output); \
     343        psFree(output); \
    344344        return NULL; \
    345345    default: \
     
    391391    case PS_TYPE_PTR:
    392392        psError(__func__,"Can't copy image into a matrix of pointers.");
    393         psImageFree(output);
     393        psFree(output);
    394394        return NULL;
    395395    }
     
    534534        case PS_TYPE_PTR:
    535535            psError (__func__, "Can't copy image from a matrix of pointers.");
    536             psImageFree (output);
     536            psFree (output);
    537537            return ((void *) 0);
    538538        default:
     
    676676        case PS_TYPE_PTR:
    677677            psError (__func__, "Can't copy image from a matrix of pointers.");
    678             psImageFree (output);
     678            psFree (output);
    679679            return ((void *) 0);
    680680        default:
     
    818818        case PS_TYPE_PTR:
    819819            psError (__func__, "Can't copy image from a matrix of pointers.");
    820             psImageFree (output);
     820            psFree (output);
    821821            return ((void *) 0);
    822822        default:
     
    960960        case PS_TYPE_PTR:
    961961            psError (__func__, "Can't copy image from a matrix of pointers.");
    962             psImageFree (output);
     962            psFree (output);
    963963            return ((void *) 0);
    964964        default:
     
    11021102        case PS_TYPE_PTR:
    11031103            psError (__func__, "Can't copy image from a matrix of pointers.");
    1104             psImageFree (output);
     1104            psFree (output);
    11051105            return ((void *) 0);
    11061106        default:
     
    12441244        case PS_TYPE_PTR:
    12451245            psError (__func__, "Can't copy image from a matrix of pointers.");
    1246             psImageFree (output);
     1246            psFree (output);
    12471247            return ((void *) 0);
    12481248        default:
     
    13861386        case PS_TYPE_PTR:
    13871387            psError (__func__, "Can't copy image from a matrix of pointers.");
    1388             psImageFree (output);
     1388            psFree (output);
    13891389            return ((void *) 0);
    13901390        default:
     
    15281528        case PS_TYPE_PTR:
    15291529            psError (__func__, "Can't copy image from a matrix of pointers.");
    1530             psImageFree (output);
     1530            psFree (output);
    15311531            return ((void *) 0);
    15321532        default:
     
    16701670        case PS_TYPE_PTR:
    16711671            psError (__func__, "Can't copy image from a matrix of pointers.");
    1672             psImageFree (output);
     1672            psFree (output);
    16731673            return ((void *) 0);
    16741674        default:
     
    18121812        case PS_TYPE_PTR:
    18131813            psError (__func__, "Can't copy image from a matrix of pointers.");
    1814             psImageFree (output);
     1814            psFree (output);
    18151815            return ((void *) 0);
    18161816        default:
     
    19541954        case PS_TYPE_PTR:
    19551955            psError (__func__, "Can't copy image from a matrix of pointers.");
    1956             psImageFree (output);
     1956            psFree (output);
    19571957            return ((void *) 0);
    19581958        default:
     
    20962096        case PS_TYPE_PTR:
    20972097            psError (__func__, "Can't copy image from a matrix of pointers.");
    2098             psImageFree (output);
     2098            psFree (output);
    20992099            return ((void *) 0);
    21002100        default:
     
    21042104    case PS_TYPE_PTR:
    21052105        psError (__func__, "Can't copy image into a matrix of pointers.");
    2106         psImageFree (output);
     2106        psFree (output);
    21072107        return ((void *) 0);
    21082108    }
  • trunk/psLib/src/image/psImage.h

    r974 r1073  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-06-10 01:58:06 $
     13 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-06-23 23:00:15 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    110110);
    111111
    112 /** Destroy the specified image.
    113  *
    114  *  Uses psLib memory deallocation functions to free an image and any existing
    115  *  children.
    116  *
    117  */
    118 void psImageFree(
    119     psImage *restrict image             ///< Free psImage
    120 );
    121 
    122112/** Frees all children of a psImage.
    123113 *
  • trunk/psLib/src/image/psImageIO.c

    r997 r1073  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-06-11 03:45:07 $
     9 *  @version $Revision: 1.4 $ $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
     
    1919#include "psImageIO.h"
    2020#include "psError.h"
     21#include "psMemory.h"
    2122
    2223psImage* psImageReadSection(psImage* output, int col, int row, int numCols,
     
    3940    if (filename == NULL) {
    4041        psError(__func__,"Must specify filename; it can not be NULL.");
    41         psImageFree(output);
     42        psFree(output);
    4243        return NULL;
    4344    }
     
    4950        psError(__func__,"Could not open file '%s'. (%s)",
    5051                filename, fitsErr);
    51         psImageFree(output);
     52        psFree(output);
    5253        return NULL;
    5354    }
     
    6162            psError(__func__,"Could not index to '%s' HDU for file %s. (%s)",
    6263                    extname, filename, fitsErr);
    63             psImageFree(output);
     64            psFree(output);
    6465            return NULL;
    6566        }
     
    7172            psError(__func__,"Could not index to HDU #%d for file %s. (%s)",
    7273                    extnum, filename, fitsErr);
    73             psImageFree(output);
     74            psFree(output);
    7475            return NULL;
    7576        }
     
    8384        psError("Could not determine image data type of '%s'. (%s)",
    8485                filename, fitsErr);
    85         psImageFree(output);
     86        psFree(output);
    8687        return NULL;
    8788    }
     
    9495        psError("Could not determine dimensions of '%s'. (%s)",
    9596                filename,fitsErr);
    96         psImageFree(output);
     97        psFree(output);
    9798        return NULL;
    9899    }
     
    104105        psError("Dimensions of '%s' are not supported (NAXIS=%i).",
    105106                filename, nAxis);
    106         psImageFree(output);
     107        psFree(output);
    107108        return NULL;
    108109    }
     
    115116        psError("Could not determine image size of '%s'. (%s)",
    116117                filename,fitsErr);
    117         psImageFree(output);
     118        psFree(output);
    118119        return NULL;
    119120    }
     
    181182        psError(__func__,"Unsupported bitpix value (%d) in FITS file %s.",
    182183                bitPix,filename);
    183         psImageFree(output);
     184        psFree(output);
    184185        return NULL;
    185186    }
     
    187188    if (fits_read_subset(fptr, fitsDatatype, firstPixel, lastPixel, increment,
    188189                         NULL, output->data.V[0], &anynull, &status) != 0) {
    189         psImageFree(output);
     190        psFree(output);
    190191        (void)fits_get_errstatus(status, fitsErr);
    191192        status = 0;
  • trunk/psLib/src/image/psImageIO.d

    r986 r1073  
    11psImageIO.o psImageIO.d : psImageIO.c psImageIO.h ../collections/psImage.h \
    2   ../collections/psType.h ../sysUtils/psError.h
     2  ../collections/psType.h ../sysUtils/psError.h ../sysUtils/psMemory.h
  • trunk/psLib/src/image/psImageStats.c

    r1072 r1073  
    6767
    6868        stats = psVectorStats(stats, junkData, junkMask, maskVal);
    69         psVectorFree(junkMask);
     69        psFree(junkMask);
    7070    } else {
    7171        stats = psVectorStats(stats, junkData, NULL, 0);
    7272    }
    73     psVectorFree(junkData);
     73    psFree(junkData);
    7474    return(stats);
    7575}
     
    129129        }
    130130        out = psHistogramVector(out, junkData, junkMask, maskVal);
    131         psVectorFree(junkMask);
     131        psFree(junkMask);
    132132    } else {
    133133        out = psHistogramVector(out, junkData, NULL, 0);
    134134    }
    135     psVectorFree(junkData);
     135    psFree(junkData);
    136136
    137137    return(out);
     
    339339    // Free the Chebyshev polynomials that were created in this routine.
    340340    for (i=0;i<maxChebyPoly;i++) {
    341         psPolynomial1DFree(chebPolys[i]);
     341        psFree(chebPolys[i]);
    342342    }
    343343    psFree(chebPolys);
     
    413413    // Free the Chebyshev polynomials that were created in this routine.
    414414    for (i=0;i<maxChebyPoly;i++) {
    415         psPolynomial1DFree(chebPolys[i]);
     415        psFree(chebPolys[i]);
    416416    }
    417417    psFree(chebPolys);
  • trunk/psLib/src/imageops/psImageStats.c

    r1072 r1073  
    6767
    6868        stats = psVectorStats(stats, junkData, junkMask, maskVal);
    69         psVectorFree(junkMask);
     69        psFree(junkMask);
    7070    } else {
    7171        stats = psVectorStats(stats, junkData, NULL, 0);
    7272    }
    73     psVectorFree(junkData);
     73    psFree(junkData);
    7474    return(stats);
    7575}
     
    129129        }
    130130        out = psHistogramVector(out, junkData, junkMask, maskVal);
    131         psVectorFree(junkMask);
     131        psFree(junkMask);
    132132    } else {
    133133        out = psHistogramVector(out, junkData, NULL, 0);
    134134    }
    135     psVectorFree(junkData);
     135    psFree(junkData);
    136136
    137137    return(out);
     
    339339    // Free the Chebyshev polynomials that were created in this routine.
    340340    for (i=0;i<maxChebyPoly;i++) {
    341         psPolynomial1DFree(chebPolys[i]);
     341        psFree(chebPolys[i]);
    342342    }
    343343    psFree(chebPolys);
     
    413413    // Free the Chebyshev polynomials that were created in this routine.
    414414    for (i=0;i<maxChebyPoly;i++) {
    415         psPolynomial1DFree(chebPolys[i]);
     415        psFree(chebPolys[i]);
    416416    }
    417417    psFree(chebPolys);
  • trunk/psLib/src/math/psPolynomial.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/math/psPolynomial.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/math/psSpline.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/math/psSpline.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/math/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/math/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/mathtypes/psImage.c

    r996 r1073  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-06-11 02:02:53 $
     11 *  @version $Revision: 1.29 $ $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
     
    2828#include "psImage.h"
    2929
     30static void imageFree(psImage* image);
    3031
    3132/*****************************************************************************/
     
    4950
    5051    psImage *image = (psImage *)psAlloc(sizeof(psImage));
     52    p_psMemSetDeallocator(image,(psFreeFcn)imageFree);
    5153
    5254    image->data.V = psAlloc(sizeof(void*)*numRows);
     
    7173}
    7274
    73 void psImageFree(psImage *image)
     75static void imageFree(psImage* image)
    7476{
    7577    if (image == NULL) {
     
    9698    psFree(image->data.V);
    9799    image->data.V = NULL;
    98 
    99     psFree(image);
    100100}
    101101
     
    237237        if (children[i] != NULL) {
    238238            numFreed++;
    239             psImageFree(children[i]);
     239            psFree(children[i]);
    240240        }
    241241    }
     
    341341    case PS_TYPE_PTR: \
    342342        psError(__func__,"Can't copy image from a matrix of pointers."); \
    343         psImageFree(output); \
     343        psFree(output); \
    344344        return NULL; \
    345345    default: \
     
    391391    case PS_TYPE_PTR:
    392392        psError(__func__,"Can't copy image into a matrix of pointers.");
    393         psImageFree(output);
     393        psFree(output);
    394394        return NULL;
    395395    }
     
    534534        case PS_TYPE_PTR:
    535535            psError (__func__, "Can't copy image from a matrix of pointers.");
    536             psImageFree (output);
     536            psFree (output);
    537537            return ((void *) 0);
    538538        default:
     
    676676        case PS_TYPE_PTR:
    677677            psError (__func__, "Can't copy image from a matrix of pointers.");
    678             psImageFree (output);
     678            psFree (output);
    679679            return ((void *) 0);
    680680        default:
     
    818818        case PS_TYPE_PTR:
    819819            psError (__func__, "Can't copy image from a matrix of pointers.");
    820             psImageFree (output);
     820            psFree (output);
    821821            return ((void *) 0);
    822822        default:
     
    960960        case PS_TYPE_PTR:
    961961            psError (__func__, "Can't copy image from a matrix of pointers.");
    962             psImageFree (output);
     962            psFree (output);
    963963            return ((void *) 0);
    964964        default:
     
    11021102        case PS_TYPE_PTR:
    11031103            psError (__func__, "Can't copy image from a matrix of pointers.");
    1104             psImageFree (output);
     1104            psFree (output);
    11051105            return ((void *) 0);
    11061106        default:
     
    12441244        case PS_TYPE_PTR:
    12451245            psError (__func__, "Can't copy image from a matrix of pointers.");
    1246             psImageFree (output);
     1246            psFree (output);
    12471247            return ((void *) 0);
    12481248        default:
     
    13861386        case PS_TYPE_PTR:
    13871387            psError (__func__, "Can't copy image from a matrix of pointers.");
    1388             psImageFree (output);
     1388            psFree (output);
    13891389            return ((void *) 0);
    13901390        default:
     
    15281528        case PS_TYPE_PTR:
    15291529            psError (__func__, "Can't copy image from a matrix of pointers.");
    1530             psImageFree (output);
     1530            psFree (output);
    15311531            return ((void *) 0);
    15321532        default:
     
    16701670        case PS_TYPE_PTR:
    16711671            psError (__func__, "Can't copy image from a matrix of pointers.");
    1672             psImageFree (output);
     1672            psFree (output);
    16731673            return ((void *) 0);
    16741674        default:
     
    18121812        case PS_TYPE_PTR:
    18131813            psError (__func__, "Can't copy image from a matrix of pointers.");
    1814             psImageFree (output);
     1814            psFree (output);
    18151815            return ((void *) 0);
    18161816        default:
     
    19541954        case PS_TYPE_PTR:
    19551955            psError (__func__, "Can't copy image from a matrix of pointers.");
    1956             psImageFree (output);
     1956            psFree (output);
    19571957            return ((void *) 0);
    19581958        default:
     
    20962096        case PS_TYPE_PTR:
    20972097            psError (__func__, "Can't copy image from a matrix of pointers.");
    2098             psImageFree (output);
     2098            psFree (output);
    20992099            return ((void *) 0);
    21002100        default:
     
    21042104    case PS_TYPE_PTR:
    21052105        psError (__func__, "Can't copy image into a matrix of pointers.");
    2106         psImageFree (output);
     2106        psFree (output);
    21072107        return ((void *) 0);
    21082108    }
  • trunk/psLib/src/mathtypes/psImage.h

    r974 r1073  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-06-10 01:58:06 $
     13 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-06-23 23:00:15 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    110110);
    111111
    112 /** Destroy the specified image.
    113  *
    114  *  Uses psLib memory deallocation functions to free an image and any existing
    115  *  children.
    116  *
    117  */
    118 void psImageFree(
    119     psImage *restrict image             ///< Free psImage
    120 );
    121 
    122112/** Frees all children of a psImage.
    123113 *
  • trunk/psLib/src/mathtypes/psVector.c

    r1008 r1073  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-06-12 01:33:16 $
     10 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-06-23 23:00:15 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4949/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    5050/*****************************************************************************/
     51static void vectorFree(psVector *restrict psVec);
    5152
    5253/*****************************************************************************/
     
    6869    // Create vector struct
    6970    psVec = (psVector *)psAlloc(sizeof(psVector));
     71    p_psMemSetDeallocator(psVec,(psFreeFcn)vectorFree);
    7072
    7173    psVec->type.dimen = PS_DIMEN_VECTOR;
     
    132134    if(nalloc < 1) {
    133135        psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
    134         psVectorFree(in);
     136        psFree(in);
    135137        return NULL;
    136138    }
     
    154156}
    155157
    156 void psVectorFree(psVector *restrict psVec)
     158static void vectorFree(psVector *restrict psVec)
    157159{
    158160    if (psVec == NULL) {
     
    160162    }
    161163
     164    if (psVec->type.type == PS_TYPE_PTR) {
     165        for(int i = 0; i < psVec->n; i++) {
     166            psFree(psVec->data.PTR[i]);
     167            psVec->data.PTR[i] = NULL;
     168        }
     169    }
     170
    162171    psFree(psVec->data.V);
    163     psFree(psVec);
    164172}
    165173
    166 void psVectorElementFree(psVector *restrict psVec, void (*elemFree)(void *))
     174void psVectorElementFree(psVector *restrict psVec)
    167175{
    168176
     
    176184    }
    177185
    178     for(int i = 0; i < psVec->nalloc; i++) {
    179         if(elemFree == NULL) {
    180             psMemDecrRefCounter(psVec->data.PTR[i]);
    181         } else {
    182             elemFree(psMemDecrRefCounter(psVec->data.PTR[i]));
    183         }
     186    for(int i = 0; i < psVec->n; i++) {
     187        psFree(psVec->data.PTR[i]);
    184188        psVec->data.PTR[i] = NULL;
    185189    }
  • trunk/psLib/src/mathtypes/psVector.h

    r974 r1073  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-06-10 01:58:06 $
     13 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-06-23 23:00:15 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    100100);
    101101
    102 /** Deallocate a vector.
    103  *
    104  * Uses psLib memory allocation functions to deallocate a vector collection of data. The vector is deallocated
    105  * according to the psType type member contained within the vector.
    106  *
    107  * @return psVector*: Pointer to psVector.
    108  *
    109  */
    110 void psVectorFree(
    111     psVector *restrict psVec  ///< Vector to free.
    112 );
    113 
    114 
    115102/** Deallocate/Dereference elements of a void pointer vector.
    116103 *
     
    122109 */
    123110void psVectorElementFree(
    124     psVector *restrict psVec,   ///< Void pointer vector to destroy.
    125     void (*elemFree)(void *)    ///< Optional callback function to remove vector elements.
     111    psVector *restrict psVec    ///< Void pointer vector to destroy.
    126112);
    127113
  • trunk/psLib/src/sys/psMemory.c

    r876 r1073  
    88 *  @author Robert Lupton, Princeton University
    99 *
    10  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-06-04 23:46:48 $
     10 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-06-23 23:00:15 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030static int checkMemBlock(const psMemBlock *m, const char* funcName);
    3131static psMemBlock *lastMemBlockAllocated = NULL;
    32 pthread_mutex_t  memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
    33 pthread_mutex_t  memIdMutex = PTHREAD_MUTEX_INITIALIZER;
     32static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
     33static pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER;
    3434
    3535/**
     
    9696psMemoryId p_psMemFreeID = 0;   // notify user this block is freed
    9797
    98 psMemoryId psMemAllocateCallbackSetID(psMemoryId id) // set p_psMemAllocateID to id
     98psMemoryId psMemAllocateCallbackSetID(psMemoryId id)
    9999{
    100100    psMemoryId old = p_psMemAllocateID;
     
    104104}
    105105
    106 psMemoryId psMemFreeCallbackSetID(psMemoryId id)  // set p_psMemFreeID to id
     106psMemoryId psMemFreeCallbackSetID(psMemoryId id)
    107107{
    108108    psMemoryId old = p_psMemFreeID;
     
    184184#define ALIGNED(P) ((void *)((long)(P) & ~03) == (P))
    185185
    186 static int
    187 checkMemBlock(const psMemBlock *m,
    188               const char* funcName)
     186static int checkMemBlock(const psMemBlock *m, const char* funcName)
    189187{
    190188    // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked,
     
    260258
    261259    ptr->file = file;
     260    ptr->freeFcn = NULL;
    262261    *(unsigned int*)&ptr->lineno = lineno;
    263262    ptr->startblock = P_PS_MEMMAGIC;
     
    346345    if (checkMemBlock(ptr, __func__) != 0) {
    347346        memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
    348     }
    349 
    350     psMemDecrRefCounter(vptr);          // this handles the free, if required.
     347        return;
     348    }
     349
     350    (void)psMemDecrRefCounter(vptr);   // this handles the free, if required.
    351351}
    352352
     
    354354 * Check for memory leaks. Not production quality code
    355355 */
    356 int psMemCheckLeaks(
    357     psMemoryId id0,                     // don't list blocks with id < id0
    358     psMemBlock ***arr,                  // pointer to array of pointers to leaked blocks, or NULL
    359     FILE *fd)                           // print list of leaks to fd (or NULL)
     356int psMemCheckLeaks(psMemoryId id0,psMemBlock ***arr,FILE *fd)
    360357{
    361358    int nleak = 0;
     
    365362    pthread_mutex_lock(&memBlockListMutex);
    366363
    367     for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
    368     {
     364    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
    369365        if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
    370366            nleak++;
     
    382378    pthread_mutex_unlock(&memBlockListMutex);
    383379
    384     if (nleak == 0 || arr == NULL)
    385     {
     380    if (nleak == 0 || arr == NULL) {
    386381        return nleak;
    387382    }
     
    390385    pthread_mutex_lock(&memBlockListMutex);
    391386
    392     for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
    393     {
     387    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
    394388        if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
    395389            (*arr)[j++] = iter;
     
    408402 * Reference counting APIs
    409403 */
    410 psReferenceCount psMemGetRefCounter(void *vptr) // return refCounter
     404// return refCounter
     405psReferenceCount psMemGetRefCounter(void *vptr)
    411406{
    412407    psMemBlock *ptr;
    413408    unsigned int refCount;
    414409
    415     if (vptr == NULL)
    416     {
     410    if (vptr == NULL) {
    417411        return 0;
    418412    }
     
    420414    ptr = ((psMemBlock *)vptr) - 1;
    421415
    422     if (checkMemBlock(ptr, __func__) != 0)
    423     {
     416    if (checkMemBlock(ptr, __func__) != 0) {
    424417        memProblemCallback(ptr, __func__, __LINE__);
    425418    }
     
    431424    return refCount;
    432425}
    433 
    434 void *psMemIncrRefCounter(void *vptr) // increment and return refCounter
     426// increment and return refCounter
     427void *psMemIncrRefCounter(void *vptr)
    435428{
    436429    psMemBlock *ptr;
    437430
    438     if (vptr == NULL)
    439     {
     431    if (vptr == NULL) {
    440432        return vptr;
    441433    }
     
    443435    ptr = ((psMemBlock *)vptr) - 1;
    444436
    445     if (checkMemBlock(ptr, __func__))
    446     {
     437    if (checkMemBlock(ptr, __func__)) {
    447438        memProblemCallback(ptr, __func__, __LINE__);
    448439    }
     
    455446}
    456447
    457 void *psMemDecrRefCounter(void *vptr) // decrement and return refCounter
    458 {
    459     if (vptr == NULL)
    460     {
     448// decrement and return refCounter
     449void *psMemDecrRefCounter(void *vptr)
     450{
     451    if (vptr == NULL) {
    461452        return NULL;
    462453    }
     
    467458    pthread_mutex_lock(&ptr->refCounterMutex);
    468459
    469     if (ptr->refCounter > 1)
    470     {
     460    if (ptr->refCounter > 1) {
    471461        /// XXX - Probably should have another mutex here.
    472462        ptr->refCounter--;          // multiple references, just decrement the count.
    473463        pthread_mutex_unlock(&ptr->refCounterMutex);
    474464
    475     } else
    476     {
     465    } else {
    477466        pthread_mutex_unlock(&ptr->refCounterMutex);
    478467
     
    482471        }
    483472
     473        if (ptr->freeFcn != NULL) {
     474            ptr->freeFcn(vptr);
     475        }
     476
    484477        pthread_mutex_lock(&memBlockListMutex);
    485478
     
    507500}
    508501
    509 void p_psCustomFree(psFreeFcn fcn, void* ptr)
    510 {
    511 
    512     if (fcn == NULL) {
     502void p_psMemSetDeallocator(void* vptr, psFreeFcn freeFcn)
     503{
     504    if (vptr == NULL) {
    513505        return;
    514     } else {
    515         if (fcn == PS_FREE) {
    516             psFree(ptr);
    517         } else {
    518             fcn(ptr);
    519         }
    520     }
    521 }
     506    }
     507
     508    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
     509
     510    ptr->freeFcn = freeFcn;
     511
     512}
     513psFreeFcn p_psMemGetDeallocator(void* vptr)
     514{
     515    if (vptr == NULL) {
     516        return NULL;
     517    }
     518
     519    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
     520
     521    return ptr->freeFcn;
     522}
  • trunk/psLib/src/sys/psMemory.h

    r978 r1073  
    1414 *  @ingroup MemoryManagement
    1515 *
    16  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2004-06-10 02:09:57 $
     16 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2004-06-23 23:00:15 $
    1818 *
    1919 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050/// typedef for a memory block's reference count. Guaranteed to be some variety of integer.
    5151typedef unsigned long psReferenceCount;
     52
     53/// typedef for deallocator.
     54typedef void (*psFreeFcn)(void* ptr);
    5255
    5356/** Book-keeping data for storage allocator.
     
    5861typedef struct psMemBlock
    5962{
    60     const void* startblock;             ///< initialised to p_psMEMMAGIC
    61     struct psMemBlock* previousBlock;   ///< previous block in allocation list
    62     struct psMemBlock* nextBlock;       ///< next block allocation list
    63     size_t  userMemorySize;             ///< the size of the user-portion of the memory block
    64     const psMemoryId id;                ///< a unique ID for this allocation
    65     const char* file;                   ///< set from __FILE__ in e.g. p_psAlloc
    66     const int lineno;                   ///< set from __LINE__ in e.g. p_psAlloc
    67     pthread_mutex_t   refCounterMutex;  ///< mutex to ensure exclusive access to reference counter
    68     psReferenceCount refCounter;        ///< how many times pointer is referenced
    69     const void* endblock;               ///< initialised to p_psMEMMAGIC
     63    const void* startblock;            ///< initialised to p_psMEMMAGIC
     64    struct psMemBlock* previousBlock;  ///< previous block in allocation list
     65    struct psMemBlock* nextBlock;      ///< next block allocation list
     66    psFreeFcn freeFcn;                 ///< deallocator.  If NULL, use generic deallocation.
     67    size_t  userMemorySize;            ///< the size of the user-portion of the memory block
     68    const psMemoryId id;               ///< a unique ID for this allocation
     69    const char* file;                  ///< set from __FILE__ in e.g. p_psAlloc
     70    const int lineno;                  ///< set from __LINE__ in e.g. p_psAlloc
     71    pthread_mutex_t   refCounterMutex; ///< mutex to ensure exclusive access to reference counter
     72    psReferenceCount refCounter;       ///< how many times pointer is referenced
     73    const void* endblock;              ///< initialised to p_psMEMMAGIC
    7074}
    7175psMemBlock;
     
    114118);
    115119
    116 typedef void (*psFreeFcn)(void* ptr);
    117 
    118120/** Memory allocation.  This operates much like malloc(), but is guaranteed to return a non-NULL value.
    119121 *
    120122 *  @return void* pointer to the allocated buffer. This will not be NULL.
    121  *  @see psFree
     123 *  @see psFree 
    122124 */
    123125#ifdef DOXYGEN
     
    131133    int lineno                      ///< Line number of call
    132134);
     135
     136void p_psMemSetDeallocator(void* ptr, psFreeFcn freeFcn);
     137psFreeFcn p_psMemGetDeallocator(void* ptr);
     138
    133139/// Memory allocation. psAlloc sends file and line number to p_psAlloc.
    134140#define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__)
     
    282288);
    283289
    284 #define PS_FREE     (void*)1
    285 
    286290//@} End of Memory Management Functions
    287291
    288 
    289292#ifndef DOXYGEN
    290 
    291 void p_psCustomFree(psFreeFcn fcn,void* ptr);
    292293
    293294/*
  • trunk/psLib/src/sysUtils/psHash.c

    r964 r1073  
    1010 *  @author George Gusciora, MHPCC
    1111 *   
    12  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-10 00:09:55 $
     12 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-23 23:00:15 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818#include <stdio.h>
    1919#include <string.h>
     20#include <stdbool.h>
    2021#include "psHash.h"
    2122#include "psMemory.h"
     
    2425#include "psAbort.h"
    2526
     27static psHashBucket *hashBucketAlloc(const char *key,void *data,psHashBucket *next);
     28static void hashBucketFree(psHashBucket *bucket);
     29static void *doHashWork(psHash* table, const char* key, void* data, bool remove
     30                           );
     31static void hashFree(psHash *table);
    2632
    2733/******************************************************************************
     
    8793    // Allocate memory for the new hash bucket.
    8894    psHashBucket *bucket = psAlloc(sizeof(psHashBucket));
     95    p_psMemSetDeallocator(bucket,(psFreeFcn)hashBucketFree);
    8996
    9097    // Initialize the bucket.
     
    105112
    106113/******************************************************************************
    107 hashBucketFree(bucket, itemFree): This procedure deallocates the specified
    108 hash bucket.  If "itemFree" is NULL, then we simply free the data with the
    109 standard psFree() function.  If "itemFree" is not NULL, then it must be a
    110 function pointer which takes the hash bucket as a parameter, and frees the
    111 data in that hash bucket.
     114hashBucketFree(bucket): This procedure deallocates the specified
     115hash bucket. 
    112116Inputs:
    113117    bucket: the hash bucket to be freed.
    114     itemFree: a function pointer, possibly NULL.
    115118Return:
    116119    NONE
    117120 *****************************************************************************/
    118 static void hashBucketFree(psHashBucket *bucket,   // bucket to free
    119                            void (*itemFree)(void *item)) // how to free data;
    120 {
    121     if (bucket == NULL)
    122     {
     121static void hashBucketFree(psHashBucket *bucket)
     122{
     123    if (bucket == NULL) {
    123124        return;
    124125    }
     
    126127    // A bucket is actually a linked list of buckets.  We recursively step
    127128    // through that linked list, free each bucket.
    128     if (bucket->next != NULL)
    129     {
    130         hashBucketFree(bucket, itemFree);
    131     }
     129    psFree(bucket->next);
    132130
    133131    psFree(bucket->key);
    134     psMemDecrRefCounter(bucket->data);
    135 
    136     if (itemFree != NULL)
    137     {
    138         itemFree(bucket->data);
    139     } else
    140     {
    141         psFree(bucket->data);
    142     }
    143 
    144     psFree(bucket);
     132
     133    psFree(bucket->data);
    145134}
    146135
     
    159148    // Create the new hash table.
    160149    psHash *table = psAlloc(sizeof(psHash));
     150    p_psMemSetDeallocator(table,(psFreeFcn)hashFree);
    161151
    162152    // Allocate memory for the buckets.
     
    185175Inputs:
    186176    table: a hash table
    187     itemFree: a function pointer, possibly NULL.
    188177Return:
    189178    NONE
    190179 *****************************************************************************/
    191 void psHashFree(psHash *table,  // hash table to be freed
    192                 void (*itemFree)(void *item)) // how to free hashed data; or NULL
     180static void hashFree(psHash *table)
    193181{
    194182    psHashBucket *tmp = NULL;           // Used to step through linked list.
     
    196184    int i = 0;                          // Loop index variable.
    197185
    198     if (table == NULL)
    199     {
     186    if (table == NULL) {
    200187        return;
    201188    }
     
    204191    // NULL, then free the bucket via a function call to hashBucketFree();
    205192
    206     for (i = 0; i < table->nbucket; i++)
    207     {
     193    for (i = 0; i < table->nbucket; i++) {
    208194        // A bucket is composed of a linked list of buckets.  We use the
    209195        // "tmp" and "ptr" pointers to step through that list and free each
     
    214200            while (ptr != NULL) {
    215201                tmp = ptr->next;
    216                 hashBucketFree(ptr, itemFree);
     202                psFree(ptr);
    217203                ptr = tmp;
    218204            }
     
    222208    // Free the bucket structure, then the hash table.
    223209    psFree(table->buckets);
    224     psFree(table);
    225 }
    226 
    227 /******************************************************************************
    228 doHashWork(table, key, data, remove, itemFree): This is an internal
     210}
     211
     212/******************************************************************************
     213doHashWork(table, key, data, remove): This is an internal
    229214procedure which does the bulk of the work in using the hash table.  Depending
    230215upon the input parameters, it will either insert a new key/data into the hash
    231216table, retrieve the data for a specified key, or remove a key/data item.  If
    232 we try to insert a key that already exists in the hash table, then we call
    233 the user-supplied function itemfree (or psFree if that is NULL), to free the
    234 existing data/key item.
     217we try to insert a key that already exists in the hash table, then we deallocate
     218the existing data/key item.
    235219Inputs:
    236220    table: a hash table
     
    238222    data: the data to insert, if not NULL
    239223    remove: set to non-zero if the key/data should be removed from the table.
    240     itemFree: function pointer
    241224Return:
    242225    NONE
     
    246229there is little common code between those functions.
    247230  *****************************************************************************/
    248 static void *doHashWork(psHash     *table,   // table to insert in
    249                         const char *key,     // key to use
    250                         void       *data,    // data to insert, or (if NULL) retrieve/remove
    251                         int remove
    252                             ,          // remove the item from the list?
    253                             void (*itemFree)(void *item)) // how to free hashed data
     231static void *doHashWork(psHash *table, const char *key, void *data, bool remove
     232                           )
    254233{
    255234    long int hash = 1;                  // This will contain an integer value
     
    313292                    }
    314293
    315                     psFree(ptr->key);
    316294                    psFree(ptr);
    317295
    318296                    // By definition, the data associated with that key
    319297                    // must be returned, not freed.
    320                     return psMemDecrRefCounter(data);
     298                    return data;
    321299                }
    322300                optr = ptr;
     
    354332                // the new data was not inserted into the hash table.
    355333
    356                 if (itemFree == NULL) {
    357                     psFree(psMemDecrRefCounter(ptr->data));
    358                 } else {
    359                     itemFree(psMemDecrRefCounter(ptr->data));
    360                 }
     334                psFree(ptr->data);
    361335
    362336                ptr->data = psMemIncrRefCounter(data);
     
    385359    NONE
    386360 *****************************************************************************/
    387 void *psHashInsert(psHash *table,   // table to insert in
    388                    const char *key, // key to use
    389                    void *data,      // data to insert
    390                    void (*itemFree)(void *item)) // how to free hashed data;
     361void *psHashInsert(psHash *table, const char *key, void *data)
    391362{
    392363    if (table == NULL) {
     
    400371    }
    401372
    402     return doHashWork(table, key, data, 0, itemFree);
     373    return doHashWork(table, key, data, 0);
    403374}
    404375
     
    425396
    426397
    427     return doHashWork(table, key, NULL, 0, NULL);
     398    return doHashWork(table, key, NULL, 0);
    428399}
    429400
     
    438409    The data that was associated with that key.
    439410 *****************************************************************************/
    440 void *psHashRemove(psHash *table,   // table to lookup key in
    441                    const char *key, // key to lookup
    442                    void (*itemFree)(void *item)) // how to free hashed data;
     411void *psHashRemove(psHash *table, const char *key)
    443412{
    444413    if (table == NULL) {
     
    449418    }
    450419
    451     return doHashWork(table, key, NULL, 1, itemFree);
    452 }
     420    return doHashWork(table, key, NULL, 1);
     421}
  • trunk/psLib/src/sysUtils/psHash.d

    r1041 r1073  
    11psHash.o psHash.d : psHash.c psHash.h ../collections/psList.h \
    2   ../collections/psVector.h ../collections/psType.h \
    3   ../sysUtils/psMemory.h psString.h psTrace.h psAbort.h
     2  ../collections/psVector.h ../collections/psType.h psMemory.h psString.h \
     3  psTrace.h psAbort.h
  • trunk/psLib/src/sysUtils/psHash.h

    r1013 r1073  
    1010 *  @author George Gusciora, MHPCC
    1111 *   
    12  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-12 05:50:01 $
     12 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-23 23:00:15 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4545                   );
    4646
    47 /// Free hash buckets from table.
    48 void psHashFree(psHash *table,               ///< hash table to be freed
    49                 void (*itemFree)(void *item) ///< how to free hashed data; or NULL
    50                );
    51 
    5247/// Insert entry into table.
    5348void *psHashInsert(psHash *table,               ///< table to insert in
    5449                   const char *key,             ///< key to use
    55                    void *data,                  ///< data to insert
    56                    void (*itemFree)(void *item) ///< how to free hashed data; or NULL
     50                   void *data                   ///< data to insert
    5751                  );
    5852
    5953/// Lookup key in table.
    60 void *psHashLookup(psHash *table, ///< table to lookup key in
    61                    const char *key ///< key to lookup
     54void *psHashLookup(psHash *table,      ///< table to lookup key in
     55                   const char *key     ///< key to lookup
    6256                  );
    6357
    6458/// Remove key from table.
    65 void *psHashRemove(psHash *table, ///< table to lookup key in
    66                    const char *key, ///< key to lookup
    67                    void (*itemFree)(void *item) ///< how to free hashed data; or NULL
     59void *psHashRemove(psHash *table,      ///< table to lookup key in
     60                   const char *key     ///< key to lookup
    6861                  );
    6962
  • trunk/psLib/src/sysUtils/psMemory.c

    r876 r1073  
    88 *  @author Robert Lupton, Princeton University
    99 *
    10  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-06-04 23:46:48 $
     10 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-06-23 23:00:15 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030static int checkMemBlock(const psMemBlock *m, const char* funcName);
    3131static psMemBlock *lastMemBlockAllocated = NULL;
    32 pthread_mutex_t  memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
    33 pthread_mutex_t  memIdMutex = PTHREAD_MUTEX_INITIALIZER;
     32static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
     33static pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER;
    3434
    3535/**
     
    9696psMemoryId p_psMemFreeID = 0;   // notify user this block is freed
    9797
    98 psMemoryId psMemAllocateCallbackSetID(psMemoryId id) // set p_psMemAllocateID to id
     98psMemoryId psMemAllocateCallbackSetID(psMemoryId id)
    9999{
    100100    psMemoryId old = p_psMemAllocateID;
     
    104104}
    105105
    106 psMemoryId psMemFreeCallbackSetID(psMemoryId id)  // set p_psMemFreeID to id
     106psMemoryId psMemFreeCallbackSetID(psMemoryId id)
    107107{
    108108    psMemoryId old = p_psMemFreeID;
     
    184184#define ALIGNED(P) ((void *)((long)(P) & ~03) == (P))
    185185
    186 static int
    187 checkMemBlock(const psMemBlock *m,
    188               const char* funcName)
     186static int checkMemBlock(const psMemBlock *m, const char* funcName)
    189187{
    190188    // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked,
     
    260258
    261259    ptr->file = file;
     260    ptr->freeFcn = NULL;
    262261    *(unsigned int*)&ptr->lineno = lineno;
    263262    ptr->startblock = P_PS_MEMMAGIC;
     
    346345    if (checkMemBlock(ptr, __func__) != 0) {
    347346        memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
    348     }
    349 
    350     psMemDecrRefCounter(vptr);          // this handles the free, if required.
     347        return;
     348    }
     349
     350    (void)psMemDecrRefCounter(vptr);   // this handles the free, if required.
    351351}
    352352
     
    354354 * Check for memory leaks. Not production quality code
    355355 */
    356 int psMemCheckLeaks(
    357     psMemoryId id0,                     // don't list blocks with id < id0
    358     psMemBlock ***arr,                  // pointer to array of pointers to leaked blocks, or NULL
    359     FILE *fd)                           // print list of leaks to fd (or NULL)
     356int psMemCheckLeaks(psMemoryId id0,psMemBlock ***arr,FILE *fd)
    360357{
    361358    int nleak = 0;
     
    365362    pthread_mutex_lock(&memBlockListMutex);
    366363
    367     for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
    368     {
     364    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
    369365        if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
    370366            nleak++;
     
    382378    pthread_mutex_unlock(&memBlockListMutex);
    383379
    384     if (nleak == 0 || arr == NULL)
    385     {
     380    if (nleak == 0 || arr == NULL) {
    386381        return nleak;
    387382    }
     
    390385    pthread_mutex_lock(&memBlockListMutex);
    391386
    392     for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
    393     {
     387    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
    394388        if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
    395389            (*arr)[j++] = iter;
     
    408402 * Reference counting APIs
    409403 */
    410 psReferenceCount psMemGetRefCounter(void *vptr) // return refCounter
     404// return refCounter
     405psReferenceCount psMemGetRefCounter(void *vptr)
    411406{
    412407    psMemBlock *ptr;
    413408    unsigned int refCount;
    414409
    415     if (vptr == NULL)
    416     {
     410    if (vptr == NULL) {
    417411        return 0;
    418412    }
     
    420414    ptr = ((psMemBlock *)vptr) - 1;
    421415
    422     if (checkMemBlock(ptr, __func__) != 0)
    423     {
     416    if (checkMemBlock(ptr, __func__) != 0) {
    424417        memProblemCallback(ptr, __func__, __LINE__);
    425418    }
     
    431424    return refCount;
    432425}
    433 
    434 void *psMemIncrRefCounter(void *vptr) // increment and return refCounter
     426// increment and return refCounter
     427void *psMemIncrRefCounter(void *vptr)
    435428{
    436429    psMemBlock *ptr;
    437430
    438     if (vptr == NULL)
    439     {
     431    if (vptr == NULL) {
    440432        return vptr;
    441433    }
     
    443435    ptr = ((psMemBlock *)vptr) - 1;
    444436
    445     if (checkMemBlock(ptr, __func__))
    446     {
     437    if (checkMemBlock(ptr, __func__)) {
    447438        memProblemCallback(ptr, __func__, __LINE__);
    448439    }
     
    455446}
    456447
    457 void *psMemDecrRefCounter(void *vptr) // decrement and return refCounter
    458 {
    459     if (vptr == NULL)
    460     {
     448// decrement and return refCounter
     449void *psMemDecrRefCounter(void *vptr)
     450{
     451    if (vptr == NULL) {
    461452        return NULL;
    462453    }
     
    467458    pthread_mutex_lock(&ptr->refCounterMutex);
    468459
    469     if (ptr->refCounter > 1)
    470     {
     460    if (ptr->refCounter > 1) {
    471461        /// XXX - Probably should have another mutex here.
    472462        ptr->refCounter--;          // multiple references, just decrement the count.
    473463        pthread_mutex_unlock(&ptr->refCounterMutex);
    474464
    475     } else
    476     {
     465    } else {
    477466        pthread_mutex_unlock(&ptr->refCounterMutex);
    478467
     
    482471        }
    483472
     473        if (ptr->freeFcn != NULL) {
     474            ptr->freeFcn(vptr);
     475        }
     476
    484477        pthread_mutex_lock(&memBlockListMutex);
    485478
     
    507500}
    508501
    509 void p_psCustomFree(psFreeFcn fcn, void* ptr)
    510 {
    511 
    512     if (fcn == NULL) {
     502void p_psMemSetDeallocator(void* vptr, psFreeFcn freeFcn)
     503{
     504    if (vptr == NULL) {
    513505        return;
    514     } else {
    515         if (fcn == PS_FREE) {
    516             psFree(ptr);
    517         } else {
    518             fcn(ptr);
    519         }
    520     }
    521 }
     506    }
     507
     508    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
     509
     510    ptr->freeFcn = freeFcn;
     511
     512}
     513psFreeFcn p_psMemGetDeallocator(void* vptr)
     514{
     515    if (vptr == NULL) {
     516        return NULL;
     517    }
     518
     519    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
     520
     521    return ptr->freeFcn;
     522}
  • trunk/psLib/src/sysUtils/psMemory.h

    r978 r1073  
    1414 *  @ingroup MemoryManagement
    1515 *
    16  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2004-06-10 02:09:57 $
     16 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2004-06-23 23:00:15 $
    1818 *
    1919 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050/// typedef for a memory block's reference count. Guaranteed to be some variety of integer.
    5151typedef unsigned long psReferenceCount;
     52
     53/// typedef for deallocator.
     54typedef void (*psFreeFcn)(void* ptr);
    5255
    5356/** Book-keeping data for storage allocator.
     
    5861typedef struct psMemBlock
    5962{
    60     const void* startblock;             ///< initialised to p_psMEMMAGIC
    61     struct psMemBlock* previousBlock;   ///< previous block in allocation list
    62     struct psMemBlock* nextBlock;       ///< next block allocation list
    63     size_t  userMemorySize;             ///< the size of the user-portion of the memory block
    64     const psMemoryId id;                ///< a unique ID for this allocation
    65     const char* file;                   ///< set from __FILE__ in e.g. p_psAlloc
    66     const int lineno;                   ///< set from __LINE__ in e.g. p_psAlloc
    67     pthread_mutex_t   refCounterMutex;  ///< mutex to ensure exclusive access to reference counter
    68     psReferenceCount refCounter;        ///< how many times pointer is referenced
    69     const void* endblock;               ///< initialised to p_psMEMMAGIC
     63    const void* startblock;            ///< initialised to p_psMEMMAGIC
     64    struct psMemBlock* previousBlock;  ///< previous block in allocation list
     65    struct psMemBlock* nextBlock;      ///< next block allocation list
     66    psFreeFcn freeFcn;                 ///< deallocator.  If NULL, use generic deallocation.
     67    size_t  userMemorySize;            ///< the size of the user-portion of the memory block
     68    const psMemoryId id;               ///< a unique ID for this allocation
     69    const char* file;                  ///< set from __FILE__ in e.g. p_psAlloc
     70    const int lineno;                  ///< set from __LINE__ in e.g. p_psAlloc
     71    pthread_mutex_t   refCounterMutex; ///< mutex to ensure exclusive access to reference counter
     72    psReferenceCount refCounter;       ///< how many times pointer is referenced
     73    const void* endblock;              ///< initialised to p_psMEMMAGIC
    7074}
    7175psMemBlock;
     
    114118);
    115119
    116 typedef void (*psFreeFcn)(void* ptr);
    117 
    118120/** Memory allocation.  This operates much like malloc(), but is guaranteed to return a non-NULL value.
    119121 *
    120122 *  @return void* pointer to the allocated buffer. This will not be NULL.
    121  *  @see psFree
     123 *  @see psFree 
    122124 */
    123125#ifdef DOXYGEN
     
    131133    int lineno                      ///< Line number of call
    132134);
     135
     136void p_psMemSetDeallocator(void* ptr, psFreeFcn freeFcn);
     137psFreeFcn p_psMemGetDeallocator(void* ptr);
     138
    133139/// Memory allocation. psAlloc sends file and line number to p_psAlloc.
    134140#define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__)
     
    282288);
    283289
    284 #define PS_FREE     (void*)1
    285 
    286290//@} End of Memory Management Functions
    287291
    288 
    289292#ifndef DOXYGEN
    290 
    291 void p_psCustomFree(psFreeFcn fcn,void* ptr);
    292293
    293294/*
  • trunk/psLib/src/types/psBitSet.c

    r1041 r1073  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-15 02:45:43 $
     12 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-23 23:00:15 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5555/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
    5656/*****************************************************************************/
     57static void bitSetFree(psBitSet *restrict inBitSet);
     58
    5759
    5860/** Private function to create a mask.
     
    8890    numBytes = ceil(n/8.0);
    8991    newObj = psAlloc(sizeof(psBitSet));
     92    p_psMemSetDeallocator(newObj,(psFreeFcn)bitSetFree);
    9093    newObj->n = numBytes;
    9194
     
    98101}
    99102
    100 void psBitSetFree(psBitSet *restrict inBitSet)
     103static void bitSetFree(psBitSet *restrict inBitSet)
    101104{
    102105    if(inBitSet == NULL) {
     
    105108    }
    106109    psFree(inBitSet->bits);
    107     psFree(inBitSet);
    108110}
    109111
  • trunk/psLib/src/types/psBitSet.h

    r974 r1073  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-06-10 01:58:06 $
     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
     
    5454psBitSet* psBitSetAlloc(
    5555    int n   /**< Number of bits in psBitSet array */
    56 );
    57 
    58 /** Free a psBitSet
    59  *
    60  *  Deletes a psBitSet array.
    61  */
    62 void psBitSetFree(
    63     psBitSet *restrict inMask  /**< Pointer to psBitSet to be deleted. */
    6456);
    6557
  • trunk/psLib/src/types/psList.c

    r1024 r1073  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-14 19:45:46 $
     8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-23 23:00:15 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828
    2929// private functions.
    30 psListElem* listGetIterator(psList* list);
    31 int listGetIteratorIndex(psList* list);
    32 void listSetIterator(psList *list, int where, bool lockList);
     30static psListElem* listGetIterator(psList* list);
     31static int listGetIteratorIndex(psList* list);
     32static void listSetIterator(psList *list, int where, bool lockList);
     33static void listFree(psList *list);
    3334
    3435
     
    3637{
    3738    psList *list = psAlloc(sizeof(psList));
     39    p_psMemSetDeallocator(list,(psFreeFcn)listFree);
    3840
    3941    list->size = 0;
     
    4143    list->iter = ITER_INIT_HEAD;
    4244    list->iterIndex = PS_LIST_HEAD;
     45
    4346    pthread_mutex_init(&(list->lock),NULL)
    4447    ;
     
    5154}
    5255
    53 void psListFree(psList *list, psFreeFcn elemFree)
     56static void listFree(psList *list)
    5457{
    5558    if (list == NULL) {
     
    6366        psListElem *next = ptr->next;
    6467
    65         p_psCustomFree(elemFree, psMemDecrRefCounter(ptr->data));
     68        psFree(ptr->data);
    6669        psFree(ptr);
    6770
     
    7578    ;
    7679
    77     psFree(list);
    7880}
    7981
  • trunk/psLib/src/types/psList.h

    r1017 r1073  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-12 22:15:39 $
     12 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-23 23:00:15 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7373)
    7474;
    75 
    76 #include "psMemory.h"
    77 /** Destroys a psList linked list object.  This also frees the elements of the
    78  *  list using the psFreeFcn given, if any.  If no psFreeFcn is specified,
    79  *  the elements are just dereferenced via psMemDecrRefCounter(...).
    80  *
    81  */
    82 void psListFree(
    83     psList* restrict list,              ///< list to destroy
    84     psFreeFcn elemFree                  ///< destructor for data on list
    85 );
    8675
    8776/** Adds an element to a psList at position given.
Note: See TracChangeset for help on using the changeset viewer.