Index: trunk/psLib/src/collections/psBitSet.c
===================================================================
--- trunk/psLib/src/collections/psBitSet.c	(revision 1072)
+++ trunk/psLib/src/collections/psBitSet.c	(revision 1073)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-15 02:45:43 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -55,4 +55,6 @@
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
+static void bitSetFree(psBitSet *restrict inBitSet);
+
 
 /** Private function to create a mask.
@@ -88,4 +90,5 @@
     numBytes = ceil(n/8.0);
     newObj = psAlloc(sizeof(psBitSet));
+    p_psMemSetDeallocator(newObj,(psFreeFcn)bitSetFree);
     newObj->n = numBytes;
 
@@ -98,5 +101,5 @@
 }
 
-void psBitSetFree(psBitSet *restrict inBitSet)
+static void bitSetFree(psBitSet *restrict inBitSet)
 {
     if(inBitSet == NULL) {
@@ -105,5 +108,4 @@
     }
     psFree(inBitSet->bits);
-    psFree(inBitSet);
 }
 
Index: trunk/psLib/src/collections/psBitSet.h
===================================================================
--- trunk/psLib/src/collections/psBitSet.h	(revision 1072)
+++ trunk/psLib/src/collections/psBitSet.h	(revision 1073)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 01:58:06 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -54,12 +54,4 @@
 psBitSet* psBitSetAlloc(
     int n   /**< Number of bits in psBitSet array */
-);
-
-/** Free a psBitSet
- *
- *  Deletes a psBitSet array.
- */
-void psBitSetFree(
-    psBitSet *restrict inMask  /**< Pointer to psBitSet to be deleted. */
 );
 
Index: trunk/psLib/src/collections/psList.c
===================================================================
--- trunk/psLib/src/collections/psList.c	(revision 1072)
+++ trunk/psLib/src/collections/psList.c	(revision 1073)
@@ -6,6 +6,6 @@
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:45:46 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -28,7 +28,8 @@
 
 // private functions.
-psListElem* listGetIterator(psList* list);
-int listGetIteratorIndex(psList* list);
-void listSetIterator(psList *list, int where, bool lockList);
+static psListElem* listGetIterator(psList* list);
+static int listGetIteratorIndex(psList* list);
+static void listSetIterator(psList *list, int where, bool lockList);
+static void listFree(psList *list);
 
 
@@ -36,4 +37,5 @@
 {
     psList *list = psAlloc(sizeof(psList));
+    p_psMemSetDeallocator(list,(psFreeFcn)listFree);
 
     list->size = 0;
@@ -41,4 +43,5 @@
     list->iter = ITER_INIT_HEAD;
     list->iterIndex = PS_LIST_HEAD;
+
     pthread_mutex_init(&(list->lock),NULL)
     ;
@@ -51,5 +54,5 @@
 }
 
-void psListFree(psList *list, psFreeFcn elemFree)
+static void listFree(psList *list)
 {
     if (list == NULL) {
@@ -63,5 +66,5 @@
         psListElem *next = ptr->next;
 
-        p_psCustomFree(elemFree, psMemDecrRefCounter(ptr->data));
+        psFree(ptr->data);
         psFree(ptr);
 
@@ -75,5 +78,4 @@
     ;
 
-    psFree(list);
 }
 
Index: trunk/psLib/src/collections/psList.h
===================================================================
--- trunk/psLib/src/collections/psList.h	(revision 1072)
+++ trunk/psLib/src/collections/psList.h	(revision 1073)
@@ -10,6 +10,6 @@
  *  @ingroup LinkedList
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 22:15:39 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -73,15 +73,4 @@
 )
 ;
-
-#include "psMemory.h"
-/** Destroys a psList linked list object.  This also frees the elements of the
- *  list using the psFreeFcn given, if any.  If no psFreeFcn is specified,
- *  the elements are just dereferenced via psMemDecrRefCounter(...).
- *
- */
-void psListFree(
-    psList* restrict list,              ///< list to destroy
-    psFreeFcn elemFree                  ///< destructor for data on list
-);
 
 /** Adds an element to a psList at position given.
Index: trunk/psLib/src/collections/psSort.c
===================================================================
--- trunk/psLib/src/collections/psSort.c	(revision 1072)
+++ trunk/psLib/src/collections/psSort.c	(revision 1073)
@@ -14,6 +14,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 23:15:08 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -33,4 +33,5 @@
 #include "psSort.h"
 #include "psError.h"
+#include "psMemory.h"
 
 /******************************************************************************/
@@ -242,5 +243,5 @@
 
     // Free temp memory
-    psVectorFree(tmpVector);
+    psFree(tmpVector);
 
     return outVector;
Index: trunk/psLib/src/collections/psSort.d
===================================================================
--- trunk/psLib/src/collections/psSort.d	(revision 1072)
+++ trunk/psLib/src/collections/psSort.d	(revision 1073)
@@ -1,1 +1,2 @@
-psSort.o psSort.d : psSort.c psVector.h psType.h psSort.h ../sysUtils/psError.h
+psSort.o psSort.d : psSort.c psVector.h psType.h psSort.h ../sysUtils/psError.h \
+  ../sysUtils/psMemory.h
Index: trunk/psLib/src/collections/psVector.c
===================================================================
--- trunk/psLib/src/collections/psVector.c	(revision 1072)
+++ trunk/psLib/src/collections/psVector.c	(revision 1073)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 01:33:16 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -49,4 +49,5 @@
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
+static void vectorFree(psVector *restrict psVec);
 
 /*****************************************************************************/
@@ -68,4 +69,5 @@
     // Create vector struct
     psVec = (psVector *)psAlloc(sizeof(psVector));
+    p_psMemSetDeallocator(psVec,(psFreeFcn)vectorFree);
 
     psVec->type.dimen = PS_DIMEN_VECTOR;
@@ -132,5 +134,5 @@
     if(nalloc < 1) {
         psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
-        psVectorFree(in);
+        psFree(in);
         return NULL;
     }
@@ -154,5 +156,5 @@
 }
 
-void psVectorFree(psVector *restrict psVec)
+static void vectorFree(psVector *restrict psVec)
 {
     if (psVec == NULL) {
@@ -160,9 +162,15 @@
     }
 
+    if (psVec->type.type == PS_TYPE_PTR) {
+        for(int i = 0; i < psVec->n; i++) {
+            psFree(psVec->data.PTR[i]);
+            psVec->data.PTR[i] = NULL;
+        }
+    }
+
     psFree(psVec->data.V);
-    psFree(psVec);
 }
 
-void psVectorElementFree(psVector *restrict psVec, void (*elemFree)(void *))
+void psVectorElementFree(psVector *restrict psVec)
 {
 
@@ -176,10 +184,6 @@
     }
 
-    for(int i = 0; i < psVec->nalloc; i++) {
-        if(elemFree == NULL) {
-            psMemDecrRefCounter(psVec->data.PTR[i]);
-        } else {
-            elemFree(psMemDecrRefCounter(psVec->data.PTR[i]));
-        }
+    for(int i = 0; i < psVec->n; i++) {
+        psFree(psVec->data.PTR[i]);
         psVec->data.PTR[i] = NULL;
     }
Index: trunk/psLib/src/collections/psVector.h
===================================================================
--- trunk/psLib/src/collections/psVector.h	(revision 1072)
+++ trunk/psLib/src/collections/psVector.h	(revision 1073)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 01:58:06 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -100,17 +100,4 @@
 );
 
-/** Deallocate a vector.
- *
- * Uses psLib memory allocation functions to deallocate a vector collection of data. The vector is deallocated
- * according to the psType type member contained within the vector.
- *
- * @return psVector*: Pointer to psVector.
- *
- */
-void psVectorFree(
-    psVector *restrict psVec  ///< Vector to free.
-);
-
-
 /** Deallocate/Dereference elements of a void pointer vector.
  *
@@ -122,6 +109,5 @@
  */
 void psVectorElementFree(
-    psVector *restrict psVec,   ///< Void pointer vector to destroy.
-    void (*elemFree)(void *)    ///< Optional callback function to remove vector elements.
+    psVector *restrict psVec    ///< Void pointer vector to destroy.
 );
 
Index: trunk/psLib/src/dataManip/psFFT.c
===================================================================
--- trunk/psLib/src/dataManip/psFFT.c	(revision 1072)
+++ trunk/psLib/src/dataManip/psFFT.c	(revision 1073)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 02:17:25 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,5 +35,5 @@
     /* got good image data? */
     if (in==NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -44,5 +44,5 @@
         psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -51,5 +51,5 @@
         psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
 
@@ -76,5 +76,5 @@
     if (plan == NULL) {
         psError(__func__,"Failed to create FFTW plan.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -98,5 +98,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -143,5 +143,5 @@
         psError(__func__,"Can not extract real component from given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -158,5 +158,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -205,5 +205,5 @@
         psError(__func__,"Can not extract imaginary component from given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -220,5 +220,5 @@
 
     if (real == NULL || imag == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -230,5 +230,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psImageComplex must be the same type.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -237,5 +237,5 @@
             imag->numRows != numRows) {
         psError(__func__,"The inputs to psImageComplex must be the same dimensions.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -243,5 +243,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psImageComplex can not be complex.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -249,5 +249,5 @@
     if (type != PS_TYPE_F32 && type != PS_TYPE_F64) {
         psError(__func__,"The input type to psImageComplex must be a floating point.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -287,5 +287,5 @@
         psError(__func__,"Can not merge real and imaginary portions for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -302,5 +302,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -347,5 +347,5 @@
         psError(__func__,"Can not compute complex conjugate for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -362,5 +362,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -374,5 +374,5 @@
     if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -417,5 +417,5 @@
         psError(__func__,"Can not power spectrum for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -435,5 +435,5 @@
     /* got good image data? */
     if (in==NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -444,5 +444,5 @@
         psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -451,5 +451,5 @@
         psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
 
@@ -491,5 +491,5 @@
     if (plan == NULL) {
         psError(__func__,"Failed to create FFTW plan.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -510,5 +510,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -542,5 +542,5 @@
         psError(__func__,"Can not extract real component from given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -556,5 +556,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -588,5 +588,5 @@
         psError(__func__,"Can not extract imaginary component from given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -602,5 +602,5 @@
 
     if (real == NULL || imag == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -615,5 +615,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psVectorComplex must be the same type.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -621,5 +621,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psVectorComplex can not be complex.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -640,5 +640,5 @@
         psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -654,5 +654,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -687,5 +687,5 @@
         psError(__func__,"Can not compute complex conjugate for given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -703,5 +703,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -716,5 +716,5 @@
     if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -747,9 +747,9 @@
         psError(__func__,"Can not power spectrum for given vector type (%d).",
                 type);
-        psVectorFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
Index: trunk/psLib/src/dataManip/psFunctions.c
===================================================================
--- trunk/psLib/src/dataManip/psFunctions.c	(revision 1072)
+++ trunk/psLib/src/dataManip/psFunctions.c	(revision 1073)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:40:14 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,14 @@
 #include <gsl/gsl_rng.h>
 #include <gsl/gsl_randist.h>
+
+static void polynomial1DFree(psPolynomial1D *myPoly);
+static void polynomial2DFree(psPolynomial2D *myPoly);
+static void polynomial3DFree(psPolynomial3D *myPoly);
+static void polynomial4DFree(psPolynomial4D *myPoly);
+static void dPolynomial1DFree(psDPolynomial1D *myPoly);
+static void dPolynomial2DFree(psDPolynomial2D *myPoly);
+static void dPolynomial3DFree(psDPolynomial3D *myPoly);
+static void dPolynomial4DFree(psDPolynomial4D *myPoly);
+
 /*****************************************************************************/
 /*  FUNCTION IMPLEMENTATION - PUBLIC                                         */
@@ -108,4 +118,5 @@
 
     newPoly = (psPolynomial1D *) psAlloc(sizeof(psPolynomial1D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial1DFree);
     newPoly->n = n;
     newPoly->coeff    = (float *) psAlloc(n * sizeof(float));
@@ -128,4 +139,5 @@
 
     newPoly = (psPolynomial2D *) psAlloc(sizeof(psPolynomial2D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial2DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -158,4 +170,5 @@
 
     newPoly = (psPolynomial3D *) psAlloc(sizeof(psPolynomial3D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial3DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -197,4 +210,5 @@
 
     newPoly = (psPolynomial4D *) psAlloc(sizeof(psPolynomial4D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial4DFree);
     newPoly->nW = nW;
     newPoly->nX = nX;
@@ -235,13 +249,12 @@
 }
 
-void psPolynomial1DFree(psPolynomial1D *myPoly)
+static void polynomial1DFree(psPolynomial1D *myPoly)
 {
     psFree(myPoly->coeff);
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psPolynomial2DFree(psPolynomial2D *myPoly)
+}
+
+static void polynomial2DFree(psPolynomial2D *myPoly)
 {
     int x = 0;
@@ -255,9 +268,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-
-    psFree(myPoly);
-}
-
-void psPolynomial3DFree(psPolynomial3D *myPoly)
+}
+
+static void polynomial3DFree(psPolynomial3D *myPoly)
 {
     int x = 0;
@@ -278,8 +289,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psPolynomial4DFree(psPolynomial4D *myPoly)
+}
+
+static void polynomial4DFree(psPolynomial4D *myPoly)
 {
     int w = 0;
@@ -306,5 +316,4 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
 }
 
@@ -434,4 +443,5 @@
 
     newPoly = (psDPolynomial1D *) psAlloc(sizeof(psDPolynomial1D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial1DFree);
     newPoly->n = n;
     newPoly->coeff    = (double *) psAlloc(n * sizeof(double));
@@ -454,4 +464,5 @@
 
     newPoly = (psDPolynomial2D *) psAlloc(sizeof(psDPolynomial2D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial2DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -484,4 +495,5 @@
 
     newPoly = (psDPolynomial3D *) psAlloc(sizeof(psDPolynomial3D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial3DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -523,4 +535,5 @@
 
     newPoly = (psDPolynomial4D *) psAlloc(sizeof(psDPolynomial4D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial4DFree);
     newPoly->nW = nW;
     newPoly->nX = nX;
@@ -561,13 +574,12 @@
 }
 
-void psDPolynomial1DFree(psDPolynomial1D *myPoly)
+static void dPolynomial1DFree(psDPolynomial1D *myPoly)
 {
     psFree(myPoly->coeff);
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psDPolynomial2DFree(psDPolynomial2D *myPoly)
+}
+
+static void dPolynomial2DFree(psDPolynomial2D *myPoly)
 {
     int x = 0;
@@ -581,9 +593,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-
-    psFree(myPoly);
-}
-
-void psDPolynomial3DFree(psDPolynomial3D *myPoly)
+}
+
+static void dPolynomial3DFree(psDPolynomial3D *myPoly)
 {
     int x = 0;
@@ -604,8 +614,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psDPolynomial4DFree(psDPolynomial4D *myPoly)
+}
+
+static void dPolynomial4DFree(psDPolynomial4D *myPoly)
 {
     int w = 0;
@@ -632,5 +641,4 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
 }
 
Index: trunk/psLib/src/dataManip/psFunctions.h
===================================================================
--- trunk/psLib/src/dataManip/psFunctions.h	(revision 1072)
+++ trunk/psLib/src/dataManip/psFunctions.h	(revision 1073)
@@ -12,6 +12,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:32:42 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -104,19 +104,4 @@
                                    );
 
-/** Destructor */
-void psPolynomial1DFree(psPolynomial1D *myPoly ///< Polynomial to destroy
-                       );
-
-/** Destructor */
-void psPolynomial2DFree(psPolynomial2D *myPoly ///< Polynomial to destroy
-                       );
-/** Destructor */
-void psPolynomial3DFree(psPolynomial3D *myPoly ///< Polynomial to destroy
-                       );
-/** Destructor */
-void psPolynomial4DFree(psPolynomial4D *myPoly ///< Polynomial to destroy
-                       );
-
-
 /** Evaluate 1D polynomial */
 float
@@ -206,19 +191,4 @@
                                      );
 
-
-/** Destructor */
-void psDPolynomial1DFree(psDPolynomial1D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial2DFree(psDPolynomial2D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial3DFree(psDPolynomial3D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial4DFree(psDPolynomial4D *myPoly ///< Polynomial to destroy
-                        );
-
-
 /** Evaluate 1D polynomial (double precision) */
 double
Index: trunk/psLib/src/dataManip/psStats.c
===================================================================
--- trunk/psLib/src/dataManip/psStats.c	(revision 1072)
+++ trunk/psLib/src/dataManip/psStats.c	(revision 1073)
@@ -32,4 +32,6 @@
                            psStats *stats);
 #endif
+
+static void histogramFree(psHistogram *myHist);
 
 /******************************************************************************
@@ -68,12 +70,4 @@
 
 /******************************************************************************
-    psStatsFree(): This routine must free the psStats data structure.
- *****************************************************************************/
-void psStatsFree(psStats *stats)
-{
-    psFree(stats);
-}
-
-/******************************************************************************
 psHistogramAlloc(lower, upper, n): allocate a uniform histogram structure
 with the specifed upper and lower limits, and the specifed number of bins.
@@ -108,4 +102,5 @@
     // bins, then there are N+1 bounds to those bins.
     newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
+    p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree);
     newHist->bounds = psVectorAlloc(n+1, PS_TYPE_F32);
     newHist->bounds->n = newHist->bounds->nalloc;
@@ -160,4 +155,5 @@
     // Allocate memory for the new histogram structure.
     newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
+    p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree);
     newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
     newHist->bounds->n = newHist->bounds->nalloc;
@@ -182,9 +178,8 @@
 }
 
-void psHistogramFree(psHistogram *myHist)
-{
-    psVectorFree(myHist->bounds);
-    psVectorFree(myHist->nums);
-    psFree(myHist);
+static void histogramFree(psHistogram *myHist)
+{
+    psFree(myHist->bounds);
+    psFree(myHist->nums);
 }
 
@@ -618,5 +613,5 @@
 
         // Free temporary data buffers.
-        psStatsFree(stats2);
+        psFree(stats2);
 
         // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure.
@@ -688,6 +683,6 @@
 
     // Free the temporary data structures.
-    psVectorFree(unsortedVector);
-    psVectorFree(sortedVector);
+    psFree(unsortedVector);
+    psFree(sortedVector);
 }
 
@@ -775,5 +770,5 @@
 
         // Free temporary data buffers.
-        psStatsFree(stats2);
+        psFree(stats2);
 
         // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure.
@@ -840,6 +835,6 @@
 
     // Free the temporary data structures.
-    psVectorFree(unsortedVector);
-    psVectorFree(sortedVector);
+    psFree(unsortedVector);
+    psFree(sortedVector);
     // NOTE: This is the
 }
@@ -1043,5 +1038,5 @@
     }
 
-    psVectorFree(tmpMask);
+    psFree(tmpMask);
 }
 
@@ -1125,6 +1120,6 @@
             stats->robustLQ = stats->clippedMean;
         }
-        psStatsFree(tmpStats);
-        psHistogramFree(robustHistogram);
+        psFree(tmpStats);
+        psFree(robustHistogram);
         return;
     }
@@ -1200,6 +1195,6 @@
     stats->robustNfit = 0.0;
     stats->robustN50 = 0.0;
-    psStatsFree(tmpStats);
-    psHistogramFree(robustHistogram);
+    psFree(tmpStats);
+    psFree(robustHistogram);
 }
 
Index: trunk/psLib/src/dataManip/psStats.h
===================================================================
--- trunk/psLib/src/dataManip/psStats.h	(revision 1072)
+++ trunk/psLib/src/dataManip/psStats.h	(revision 1073)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:33:09 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,7 +88,4 @@
 psStats *psStatsAlloc(psStatsOptions options); ///< Statistics to measure
 
-/** A destructor for the stats structure.*/
-void psStatsFree(psStats *restrict stats); ///< Stats structure to destroy
-
 /******************************************************************************
     Histogram functions and data structures.
@@ -116,9 +113,4 @@
 psHistogram * psHistogramAllocGeneric(const psVector *restrict bounds); ///< Bounds for the bins
 
-
-/** Destructor \ingroup MathGroup **/
-void psHistogramFree(psHistogram *myHist);          ///< Histogram to destroy
-
-
 /** Calculate a histogram \ingroup MathGroup **/
 psHistogram *psHistogramVector (psHistogram *out,   ///< Histogram data
Index: trunk/psLib/src/dataManip/psVectorFFT.c
===================================================================
--- trunk/psLib/src/dataManip/psVectorFFT.c	(revision 1072)
+++ trunk/psLib/src/dataManip/psVectorFFT.c	(revision 1073)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 02:17:25 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,5 +35,5 @@
     /* got good image data? */
     if (in==NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -44,5 +44,5 @@
         psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -51,5 +51,5 @@
         psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
 
@@ -76,5 +76,5 @@
     if (plan == NULL) {
         psError(__func__,"Failed to create FFTW plan.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -98,5 +98,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -143,5 +143,5 @@
         psError(__func__,"Can not extract real component from given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -158,5 +158,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -205,5 +205,5 @@
         psError(__func__,"Can not extract imaginary component from given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -220,5 +220,5 @@
 
     if (real == NULL || imag == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -230,5 +230,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psImageComplex must be the same type.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -237,5 +237,5 @@
             imag->numRows != numRows) {
         psError(__func__,"The inputs to psImageComplex must be the same dimensions.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -243,5 +243,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psImageComplex can not be complex.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -249,5 +249,5 @@
     if (type != PS_TYPE_F32 && type != PS_TYPE_F64) {
         psError(__func__,"The input type to psImageComplex must be a floating point.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -287,5 +287,5 @@
         psError(__func__,"Can not merge real and imaginary portions for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -302,5 +302,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -347,5 +347,5 @@
         psError(__func__,"Can not compute complex conjugate for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -362,5 +362,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -374,5 +374,5 @@
     if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -417,5 +417,5 @@
         psError(__func__,"Can not power spectrum for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -435,5 +435,5 @@
     /* got good image data? */
     if (in==NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -444,5 +444,5 @@
         psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -451,5 +451,5 @@
         psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
 
@@ -491,5 +491,5 @@
     if (plan == NULL) {
         psError(__func__,"Failed to create FFTW plan.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -510,5 +510,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -542,5 +542,5 @@
         psError(__func__,"Can not extract real component from given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -556,5 +556,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -588,5 +588,5 @@
         psError(__func__,"Can not extract imaginary component from given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -602,5 +602,5 @@
 
     if (real == NULL || imag == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -615,5 +615,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psVectorComplex must be the same type.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -621,5 +621,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psVectorComplex can not be complex.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -640,5 +640,5 @@
         psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -654,5 +654,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -687,5 +687,5 @@
         psError(__func__,"Can not compute complex conjugate for given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -703,5 +703,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -716,5 +716,5 @@
     if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -747,9 +747,9 @@
         psError(__func__,"Can not power spectrum for given vector type (%d).",
                 type);
-        psVectorFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
Index: trunk/psLib/src/fft/psVectorFFT.c
===================================================================
--- trunk/psLib/src/fft/psVectorFFT.c	(revision 1072)
+++ trunk/psLib/src/fft/psVectorFFT.c	(revision 1073)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 02:17:25 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -35,5 +35,5 @@
     /* got good image data? */
     if (in==NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -44,5 +44,5 @@
         psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -51,5 +51,5 @@
         psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
 
@@ -76,5 +76,5 @@
     if (plan == NULL) {
         psError(__func__,"Failed to create FFTW plan.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -98,5 +98,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -143,5 +143,5 @@
         psError(__func__,"Can not extract real component from given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -158,5 +158,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -205,5 +205,5 @@
         psError(__func__,"Can not extract imaginary component from given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -220,5 +220,5 @@
 
     if (real == NULL || imag == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -230,5 +230,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psImageComplex must be the same type.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -237,5 +237,5 @@
             imag->numRows != numRows) {
         psError(__func__,"The inputs to psImageComplex must be the same dimensions.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -243,5 +243,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psImageComplex can not be complex.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -249,5 +249,5 @@
     if (type != PS_TYPE_F32 && type != PS_TYPE_F64) {
         psError(__func__,"The input type to psImageComplex must be a floating point.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -287,5 +287,5 @@
         psError(__func__,"Can not merge real and imaginary portions for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -302,5 +302,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -347,5 +347,5 @@
         psError(__func__,"Can not compute complex conjugate for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -362,5 +362,5 @@
 
     if (in == NULL) {
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -374,5 +374,5 @@
     if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -417,5 +417,5 @@
         psError(__func__,"Can not power spectrum for given image type (%d).",
                 type);
-        psImageFree(out);
+        psFree(out);
         return NULL;
     }
@@ -435,5 +435,5 @@
     /* got good image data? */
     if (in==NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -444,5 +444,5 @@
         psError(__func__,"Input image must be a 32-bit float or complex image (type=%d)",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -451,5 +451,5 @@
         psError(__func__,"Input image must be complex image for reverse FFT (type=%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
 
@@ -491,5 +491,5 @@
     if (plan == NULL) {
         psError(__func__,"Failed to create FFTW plan.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -510,5 +510,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -542,5 +542,5 @@
         psError(__func__,"Can not extract real component from given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -556,5 +556,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -588,5 +588,5 @@
         psError(__func__,"Can not extract imaginary component from given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -602,5 +602,5 @@
 
     if (real == NULL || imag == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -615,5 +615,5 @@
     if (imag->type.type != type) {
         psError(__func__,"The inputs to psVectorComplex must be the same type.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -621,5 +621,5 @@
     if (PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"The inputs to psVectorComplex can not be complex.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -640,5 +640,5 @@
         psError(__func__,"Can not merge real and imaginary portions for given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -654,5 +654,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -687,5 +687,5 @@
         psError(__func__,"Can not compute complex conjugate for given vector type (%d).",
                 type);
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -703,5 +703,5 @@
 
     if (in == NULL) {
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -716,5 +716,5 @@
     if (! PS_IS_PSELEMTYPE_COMPLEX(type)) {
         psError(__func__,"Power Spectrum for non-complex inputs is not implemented.");
-        psVectorFree(out);
+        psFree(out);
         return NULL;
     }
@@ -747,9 +747,9 @@
         psError(__func__,"Can not power spectrum for given vector type (%d).",
                 type);
-        psVectorFree(out);
-        return NULL;
-    }
-
-    return out;
-
-}
+        psFree(out);
+        return NULL;
+    }
+
+    return out;
+
+}
Index: trunk/psLib/src/image/psImage.c
===================================================================
--- trunk/psLib/src/image/psImage.c	(revision 1072)
+++ trunk/psLib/src/image/psImage.c	(revision 1073)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-11 02:02:53 $
+ *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -28,4 +28,5 @@
 #include "psImage.h"
 
+static void imageFree(psImage* image);
 
 /*****************************************************************************/
@@ -49,4 +50,5 @@
 
     psImage *image = (psImage *)psAlloc(sizeof(psImage));
+    p_psMemSetDeallocator(image,(psFreeFcn)imageFree);
 
     image->data.V = psAlloc(sizeof(void*)*numRows);
@@ -71,5 +73,5 @@
 }
 
-void psImageFree(psImage *image)
+static void imageFree(psImage* image)
 {
     if (image == NULL) {
@@ -96,6 +98,4 @@
     psFree(image->data.V);
     image->data.V = NULL;
-
-    psFree(image);
 }
 
@@ -237,5 +237,5 @@
         if (children[i] != NULL) {
             numFreed++;
-            psImageFree(children[i]);
+            psFree(children[i]);
         }
     }
@@ -341,5 +341,5 @@
     case PS_TYPE_PTR: \
         psError(__func__,"Can't copy image from a matrix of pointers."); \
-        psImageFree(output); \
+        psFree(output); \
         return NULL; \
     default: \
@@ -391,5 +391,5 @@
     case PS_TYPE_PTR:
         psError(__func__,"Can't copy image into a matrix of pointers.");
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -534,5 +534,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -676,5 +676,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -818,5 +818,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -960,5 +960,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1102,5 +1102,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1244,5 +1244,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1386,5 +1386,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1528,5 +1528,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1670,5 +1670,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1812,5 +1812,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1954,5 +1954,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -2096,5 +2096,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -2104,5 +2104,5 @@
     case PS_TYPE_PTR:
         psError (__func__, "Can't copy image into a matrix of pointers.");
-        psImageFree (output);
+        psFree (output);
         return ((void *) 0);
     }
Index: trunk/psLib/src/image/psImage.h
===================================================================
--- trunk/psLib/src/image/psImage.h	(revision 1072)
+++ trunk/psLib/src/image/psImage.h	(revision 1073)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 01:58:06 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -110,14 +110,4 @@
 );
 
-/** Destroy the specified image.
- *
- *  Uses psLib memory deallocation functions to free an image and any existing
- *  children.
- *
- */
-void psImageFree(
-    psImage *restrict image             ///< Free psImage
-);
-
 /** Frees all children of a psImage.
  *
Index: trunk/psLib/src/image/psImageIO.c
===================================================================
--- trunk/psLib/src/image/psImageIO.c	(revision 1072)
+++ trunk/psLib/src/image/psImageIO.c	(revision 1073)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-11 03:45:07 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -19,4 +19,5 @@
 #include "psImageIO.h"
 #include "psError.h"
+#include "psMemory.h"
 
 psImage* psImageReadSection(psImage* output, int col, int row, int numCols,
@@ -39,5 +40,5 @@
     if (filename == NULL) {
         psError(__func__,"Must specify filename; it can not be NULL.");
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -49,5 +50,5 @@
         psError(__func__,"Could not open file '%s'. (%s)",
                 filename, fitsErr);
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -61,5 +62,5 @@
             psError(__func__,"Could not index to '%s' HDU for file %s. (%s)",
                     extname, filename, fitsErr);
-            psImageFree(output);
+            psFree(output);
             return NULL;
         }
@@ -71,5 +72,5 @@
             psError(__func__,"Could not index to HDU #%d for file %s. (%s)",
                     extnum, filename, fitsErr);
-            psImageFree(output);
+            psFree(output);
             return NULL;
         }
@@ -83,5 +84,5 @@
         psError("Could not determine image data type of '%s'. (%s)",
                 filename, fitsErr);
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -94,5 +95,5 @@
         psError("Could not determine dimensions of '%s'. (%s)",
                 filename,fitsErr);
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -104,5 +105,5 @@
         psError("Dimensions of '%s' are not supported (NAXIS=%i).",
                 filename, nAxis);
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -115,5 +116,5 @@
         psError("Could not determine image size of '%s'. (%s)",
                 filename,fitsErr);
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -181,5 +182,5 @@
         psError(__func__,"Unsupported bitpix value (%d) in FITS file %s.",
                 bitPix,filename);
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -187,5 +188,5 @@
     if (fits_read_subset(fptr, fitsDatatype, firstPixel, lastPixel, increment,
                          NULL, output->data.V[0], &anynull, &status) != 0) {
-        psImageFree(output);
+        psFree(output);
         (void)fits_get_errstatus(status, fitsErr);
         status = 0;
Index: trunk/psLib/src/image/psImageIO.d
===================================================================
--- trunk/psLib/src/image/psImageIO.d	(revision 1072)
+++ trunk/psLib/src/image/psImageIO.d	(revision 1073)
@@ -1,2 +1,2 @@
 psImageIO.o psImageIO.d : psImageIO.c psImageIO.h ../collections/psImage.h \
-  ../collections/psType.h ../sysUtils/psError.h
+  ../collections/psType.h ../sysUtils/psError.h ../sysUtils/psMemory.h
Index: trunk/psLib/src/image/psImageStats.c
===================================================================
--- trunk/psLib/src/image/psImageStats.c	(revision 1072)
+++ trunk/psLib/src/image/psImageStats.c	(revision 1073)
@@ -67,9 +67,9 @@
 
         stats = psVectorStats(stats, junkData, junkMask, maskVal);
-        psVectorFree(junkMask);
+        psFree(junkMask);
     } else {
         stats = psVectorStats(stats, junkData, NULL, 0);
     }
-    psVectorFree(junkData);
+    psFree(junkData);
     return(stats);
 }
@@ -129,9 +129,9 @@
         }
         out = psHistogramVector(out, junkData, junkMask, maskVal);
-        psVectorFree(junkMask);
+        psFree(junkMask);
     } else {
         out = psHistogramVector(out, junkData, NULL, 0);
     }
-    psVectorFree(junkData);
+    psFree(junkData);
 
     return(out);
@@ -339,5 +339,5 @@
     // Free the Chebyshev polynomials that were created in this routine.
     for (i=0;i<maxChebyPoly;i++) {
-        psPolynomial1DFree(chebPolys[i]);
+        psFree(chebPolys[i]);
     }
     psFree(chebPolys);
@@ -413,5 +413,5 @@
     // Free the Chebyshev polynomials that were created in this routine.
     for (i=0;i<maxChebyPoly;i++) {
-        psPolynomial1DFree(chebPolys[i]);
+        psFree(chebPolys[i]);
     }
     psFree(chebPolys);
Index: trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- trunk/psLib/src/imageops/psImageStats.c	(revision 1072)
+++ trunk/psLib/src/imageops/psImageStats.c	(revision 1073)
@@ -67,9 +67,9 @@
 
         stats = psVectorStats(stats, junkData, junkMask, maskVal);
-        psVectorFree(junkMask);
+        psFree(junkMask);
     } else {
         stats = psVectorStats(stats, junkData, NULL, 0);
     }
-    psVectorFree(junkData);
+    psFree(junkData);
     return(stats);
 }
@@ -129,9 +129,9 @@
         }
         out = psHistogramVector(out, junkData, junkMask, maskVal);
-        psVectorFree(junkMask);
+        psFree(junkMask);
     } else {
         out = psHistogramVector(out, junkData, NULL, 0);
     }
-    psVectorFree(junkData);
+    psFree(junkData);
 
     return(out);
@@ -339,5 +339,5 @@
     // Free the Chebyshev polynomials that were created in this routine.
     for (i=0;i<maxChebyPoly;i++) {
-        psPolynomial1DFree(chebPolys[i]);
+        psFree(chebPolys[i]);
     }
     psFree(chebPolys);
@@ -413,5 +413,5 @@
     // Free the Chebyshev polynomials that were created in this routine.
     for (i=0;i<maxChebyPoly;i++) {
-        psPolynomial1DFree(chebPolys[i]);
+        psFree(chebPolys[i]);
     }
     psFree(chebPolys);
Index: trunk/psLib/src/math/psPolynomial.c
===================================================================
--- trunk/psLib/src/math/psPolynomial.c	(revision 1072)
+++ trunk/psLib/src/math/psPolynomial.c	(revision 1073)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:40:14 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,14 @@
 #include <gsl/gsl_rng.h>
 #include <gsl/gsl_randist.h>
+
+static void polynomial1DFree(psPolynomial1D *myPoly);
+static void polynomial2DFree(psPolynomial2D *myPoly);
+static void polynomial3DFree(psPolynomial3D *myPoly);
+static void polynomial4DFree(psPolynomial4D *myPoly);
+static void dPolynomial1DFree(psDPolynomial1D *myPoly);
+static void dPolynomial2DFree(psDPolynomial2D *myPoly);
+static void dPolynomial3DFree(psDPolynomial3D *myPoly);
+static void dPolynomial4DFree(psDPolynomial4D *myPoly);
+
 /*****************************************************************************/
 /*  FUNCTION IMPLEMENTATION - PUBLIC                                         */
@@ -108,4 +118,5 @@
 
     newPoly = (psPolynomial1D *) psAlloc(sizeof(psPolynomial1D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial1DFree);
     newPoly->n = n;
     newPoly->coeff    = (float *) psAlloc(n * sizeof(float));
@@ -128,4 +139,5 @@
 
     newPoly = (psPolynomial2D *) psAlloc(sizeof(psPolynomial2D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial2DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -158,4 +170,5 @@
 
     newPoly = (psPolynomial3D *) psAlloc(sizeof(psPolynomial3D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial3DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -197,4 +210,5 @@
 
     newPoly = (psPolynomial4D *) psAlloc(sizeof(psPolynomial4D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial4DFree);
     newPoly->nW = nW;
     newPoly->nX = nX;
@@ -235,13 +249,12 @@
 }
 
-void psPolynomial1DFree(psPolynomial1D *myPoly)
+static void polynomial1DFree(psPolynomial1D *myPoly)
 {
     psFree(myPoly->coeff);
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psPolynomial2DFree(psPolynomial2D *myPoly)
+}
+
+static void polynomial2DFree(psPolynomial2D *myPoly)
 {
     int x = 0;
@@ -255,9 +268,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-
-    psFree(myPoly);
-}
-
-void psPolynomial3DFree(psPolynomial3D *myPoly)
+}
+
+static void polynomial3DFree(psPolynomial3D *myPoly)
 {
     int x = 0;
@@ -278,8 +289,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psPolynomial4DFree(psPolynomial4D *myPoly)
+}
+
+static void polynomial4DFree(psPolynomial4D *myPoly)
 {
     int w = 0;
@@ -306,5 +316,4 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
 }
 
@@ -434,4 +443,5 @@
 
     newPoly = (psDPolynomial1D *) psAlloc(sizeof(psDPolynomial1D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial1DFree);
     newPoly->n = n;
     newPoly->coeff    = (double *) psAlloc(n * sizeof(double));
@@ -454,4 +464,5 @@
 
     newPoly = (psDPolynomial2D *) psAlloc(sizeof(psDPolynomial2D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial2DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -484,4 +495,5 @@
 
     newPoly = (psDPolynomial3D *) psAlloc(sizeof(psDPolynomial3D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial3DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -523,4 +535,5 @@
 
     newPoly = (psDPolynomial4D *) psAlloc(sizeof(psDPolynomial4D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial4DFree);
     newPoly->nW = nW;
     newPoly->nX = nX;
@@ -561,13 +574,12 @@
 }
 
-void psDPolynomial1DFree(psDPolynomial1D *myPoly)
+static void dPolynomial1DFree(psDPolynomial1D *myPoly)
 {
     psFree(myPoly->coeff);
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psDPolynomial2DFree(psDPolynomial2D *myPoly)
+}
+
+static void dPolynomial2DFree(psDPolynomial2D *myPoly)
 {
     int x = 0;
@@ -581,9 +593,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-
-    psFree(myPoly);
-}
-
-void psDPolynomial3DFree(psDPolynomial3D *myPoly)
+}
+
+static void dPolynomial3DFree(psDPolynomial3D *myPoly)
 {
     int x = 0;
@@ -604,8 +614,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psDPolynomial4DFree(psDPolynomial4D *myPoly)
+}
+
+static void dPolynomial4DFree(psDPolynomial4D *myPoly)
 {
     int w = 0;
@@ -632,5 +641,4 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
 }
 
Index: trunk/psLib/src/math/psPolynomial.h
===================================================================
--- trunk/psLib/src/math/psPolynomial.h	(revision 1072)
+++ trunk/psLib/src/math/psPolynomial.h	(revision 1073)
@@ -12,6 +12,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:32:42 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -104,19 +104,4 @@
                                    );
 
-/** Destructor */
-void psPolynomial1DFree(psPolynomial1D *myPoly ///< Polynomial to destroy
-                       );
-
-/** Destructor */
-void psPolynomial2DFree(psPolynomial2D *myPoly ///< Polynomial to destroy
-                       );
-/** Destructor */
-void psPolynomial3DFree(psPolynomial3D *myPoly ///< Polynomial to destroy
-                       );
-/** Destructor */
-void psPolynomial4DFree(psPolynomial4D *myPoly ///< Polynomial to destroy
-                       );
-
-
 /** Evaluate 1D polynomial */
 float
@@ -206,19 +191,4 @@
                                      );
 
-
-/** Destructor */
-void psDPolynomial1DFree(psDPolynomial1D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial2DFree(psDPolynomial2D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial3DFree(psDPolynomial3D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial4DFree(psDPolynomial4D *myPoly ///< Polynomial to destroy
-                        );
-
-
 /** Evaluate 1D polynomial (double precision) */
 double
Index: trunk/psLib/src/math/psSpline.c
===================================================================
--- trunk/psLib/src/math/psSpline.c	(revision 1072)
+++ trunk/psLib/src/math/psSpline.c	(revision 1073)
@@ -7,6 +7,6 @@
  *  polynomials.  It also contains a Gaussian functions.
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:40:14 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,14 @@
 #include <gsl/gsl_rng.h>
 #include <gsl/gsl_randist.h>
+
+static void polynomial1DFree(psPolynomial1D *myPoly);
+static void polynomial2DFree(psPolynomial2D *myPoly);
+static void polynomial3DFree(psPolynomial3D *myPoly);
+static void polynomial4DFree(psPolynomial4D *myPoly);
+static void dPolynomial1DFree(psDPolynomial1D *myPoly);
+static void dPolynomial2DFree(psDPolynomial2D *myPoly);
+static void dPolynomial3DFree(psDPolynomial3D *myPoly);
+static void dPolynomial4DFree(psDPolynomial4D *myPoly);
+
 /*****************************************************************************/
 /*  FUNCTION IMPLEMENTATION - PUBLIC                                         */
@@ -108,4 +118,5 @@
 
     newPoly = (psPolynomial1D *) psAlloc(sizeof(psPolynomial1D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial1DFree);
     newPoly->n = n;
     newPoly->coeff    = (float *) psAlloc(n * sizeof(float));
@@ -128,4 +139,5 @@
 
     newPoly = (psPolynomial2D *) psAlloc(sizeof(psPolynomial2D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial2DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -158,4 +170,5 @@
 
     newPoly = (psPolynomial3D *) psAlloc(sizeof(psPolynomial3D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial3DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -197,4 +210,5 @@
 
     newPoly = (psPolynomial4D *) psAlloc(sizeof(psPolynomial4D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)polynomial4DFree);
     newPoly->nW = nW;
     newPoly->nX = nX;
@@ -235,13 +249,12 @@
 }
 
-void psPolynomial1DFree(psPolynomial1D *myPoly)
+static void polynomial1DFree(psPolynomial1D *myPoly)
 {
     psFree(myPoly->coeff);
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psPolynomial2DFree(psPolynomial2D *myPoly)
+}
+
+static void polynomial2DFree(psPolynomial2D *myPoly)
 {
     int x = 0;
@@ -255,9 +268,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-
-    psFree(myPoly);
-}
-
-void psPolynomial3DFree(psPolynomial3D *myPoly)
+}
+
+static void polynomial3DFree(psPolynomial3D *myPoly)
 {
     int x = 0;
@@ -278,8 +289,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psPolynomial4DFree(psPolynomial4D *myPoly)
+}
+
+static void polynomial4DFree(psPolynomial4D *myPoly)
 {
     int w = 0;
@@ -306,5 +316,4 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
 }
 
@@ -434,4 +443,5 @@
 
     newPoly = (psDPolynomial1D *) psAlloc(sizeof(psDPolynomial1D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial1DFree);
     newPoly->n = n;
     newPoly->coeff    = (double *) psAlloc(n * sizeof(double));
@@ -454,4 +464,5 @@
 
     newPoly = (psDPolynomial2D *) psAlloc(sizeof(psDPolynomial2D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial2DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -484,4 +495,5 @@
 
     newPoly = (psDPolynomial3D *) psAlloc(sizeof(psDPolynomial3D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial3DFree);
     newPoly->nX = nX;
     newPoly->nY = nY;
@@ -523,4 +535,5 @@
 
     newPoly = (psDPolynomial4D *) psAlloc(sizeof(psDPolynomial4D));
+    p_psMemSetDeallocator(newPoly,(psFreeFcn)dPolynomial4DFree);
     newPoly->nW = nW;
     newPoly->nX = nX;
@@ -561,13 +574,12 @@
 }
 
-void psDPolynomial1DFree(psDPolynomial1D *myPoly)
+static void dPolynomial1DFree(psDPolynomial1D *myPoly)
 {
     psFree(myPoly->coeff);
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psDPolynomial2DFree(psDPolynomial2D *myPoly)
+}
+
+static void dPolynomial2DFree(psDPolynomial2D *myPoly)
 {
     int x = 0;
@@ -581,9 +593,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-
-    psFree(myPoly);
-}
-
-void psDPolynomial3DFree(psDPolynomial3D *myPoly)
+}
+
+static void dPolynomial3DFree(psDPolynomial3D *myPoly)
 {
     int x = 0;
@@ -604,8 +614,7 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
-}
-
-void psDPolynomial4DFree(psDPolynomial4D *myPoly)
+}
+
+static void dPolynomial4DFree(psDPolynomial4D *myPoly)
 {
     int w = 0;
@@ -632,5 +641,4 @@
     psFree(myPoly->coeffErr);
     psFree(myPoly->mask);
-    psFree(myPoly);
 }
 
Index: trunk/psLib/src/math/psSpline.h
===================================================================
--- trunk/psLib/src/math/psSpline.h	(revision 1072)
+++ trunk/psLib/src/math/psSpline.h	(revision 1073)
@@ -12,6 +12,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:32:42 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -104,19 +104,4 @@
                                    );
 
-/** Destructor */
-void psPolynomial1DFree(psPolynomial1D *myPoly ///< Polynomial to destroy
-                       );
-
-/** Destructor */
-void psPolynomial2DFree(psPolynomial2D *myPoly ///< Polynomial to destroy
-                       );
-/** Destructor */
-void psPolynomial3DFree(psPolynomial3D *myPoly ///< Polynomial to destroy
-                       );
-/** Destructor */
-void psPolynomial4DFree(psPolynomial4D *myPoly ///< Polynomial to destroy
-                       );
-
-
 /** Evaluate 1D polynomial */
 float
@@ -206,19 +191,4 @@
                                      );
 
-
-/** Destructor */
-void psDPolynomial1DFree(psDPolynomial1D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial2DFree(psDPolynomial2D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial3DFree(psDPolynomial3D *myPoly ///< Polynomial to destroy
-                        );
-/** Destructor */
-void psDPolynomial4DFree(psDPolynomial4D *myPoly ///< Polynomial to destroy
-                        );
-
-
 /** Evaluate 1D polynomial (double precision) */
 double
Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 1072)
+++ trunk/psLib/src/math/psStats.c	(revision 1073)
@@ -32,4 +32,6 @@
                            psStats *stats);
 #endif
+
+static void histogramFree(psHistogram *myHist);
 
 /******************************************************************************
@@ -68,12 +70,4 @@
 
 /******************************************************************************
-    psStatsFree(): This routine must free the psStats data structure.
- *****************************************************************************/
-void psStatsFree(psStats *stats)
-{
-    psFree(stats);
-}
-
-/******************************************************************************
 psHistogramAlloc(lower, upper, n): allocate a uniform histogram structure
 with the specifed upper and lower limits, and the specifed number of bins.
@@ -108,4 +102,5 @@
     // bins, then there are N+1 bounds to those bins.
     newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
+    p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree);
     newHist->bounds = psVectorAlloc(n+1, PS_TYPE_F32);
     newHist->bounds->n = newHist->bounds->nalloc;
@@ -160,4 +155,5 @@
     // Allocate memory for the new histogram structure.
     newHist = (psHistogram *) psAlloc(sizeof(psHistogram));
+    p_psMemSetDeallocator(newHist,(psFreeFcn)histogramFree);
     newHist->bounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
     newHist->bounds->n = newHist->bounds->nalloc;
@@ -182,9 +178,8 @@
 }
 
-void psHistogramFree(psHistogram *myHist)
-{
-    psVectorFree(myHist->bounds);
-    psVectorFree(myHist->nums);
-    psFree(myHist);
+static void histogramFree(psHistogram *myHist)
+{
+    psFree(myHist->bounds);
+    psFree(myHist->nums);
 }
 
@@ -618,5 +613,5 @@
 
         // Free temporary data buffers.
-        psStatsFree(stats2);
+        psFree(stats2);
 
         // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure.
@@ -688,6 +683,6 @@
 
     // Free the temporary data structures.
-    psVectorFree(unsortedVector);
-    psVectorFree(sortedVector);
+    psFree(unsortedVector);
+    psFree(sortedVector);
 }
 
@@ -775,5 +770,5 @@
 
         // Free temporary data buffers.
-        psStatsFree(stats2);
+        psFree(stats2);
 
         // Set the PS_STAT_ROBUST_FOR_SAMPLE bit in the stats structure.
@@ -840,6 +835,6 @@
 
     // Free the temporary data structures.
-    psVectorFree(unsortedVector);
-    psVectorFree(sortedVector);
+    psFree(unsortedVector);
+    psFree(sortedVector);
     // NOTE: This is the
 }
@@ -1043,5 +1038,5 @@
     }
 
-    psVectorFree(tmpMask);
+    psFree(tmpMask);
 }
 
@@ -1125,6 +1120,6 @@
             stats->robustLQ = stats->clippedMean;
         }
-        psStatsFree(tmpStats);
-        psHistogramFree(robustHistogram);
+        psFree(tmpStats);
+        psFree(robustHistogram);
         return;
     }
@@ -1200,6 +1195,6 @@
     stats->robustNfit = 0.0;
     stats->robustN50 = 0.0;
-    psStatsFree(tmpStats);
-    psHistogramFree(robustHistogram);
+    psFree(tmpStats);
+    psFree(robustHistogram);
 }
 
Index: trunk/psLib/src/math/psStats.h
===================================================================
--- trunk/psLib/src/math/psStats.h	(revision 1072)
+++ trunk/psLib/src/math/psStats.h	(revision 1073)
@@ -9,6 +9,6 @@
  *  @author George Gusciora, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:33:09 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,7 +88,4 @@
 psStats *psStatsAlloc(psStatsOptions options); ///< Statistics to measure
 
-/** A destructor for the stats structure.*/
-void psStatsFree(psStats *restrict stats); ///< Stats structure to destroy
-
 /******************************************************************************
     Histogram functions and data structures.
@@ -116,9 +113,4 @@
 psHistogram * psHistogramAllocGeneric(const psVector *restrict bounds); ///< Bounds for the bins
 
-
-/** Destructor \ingroup MathGroup **/
-void psHistogramFree(psHistogram *myHist);          ///< Histogram to destroy
-
-
 /** Calculate a histogram \ingroup MathGroup **/
 psHistogram *psHistogramVector (psHistogram *out,   ///< Histogram data
Index: trunk/psLib/src/mathtypes/psImage.c
===================================================================
--- trunk/psLib/src/mathtypes/psImage.c	(revision 1072)
+++ trunk/psLib/src/mathtypes/psImage.c	(revision 1073)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-11 02:02:53 $
+ *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -28,4 +28,5 @@
 #include "psImage.h"
 
+static void imageFree(psImage* image);
 
 /*****************************************************************************/
@@ -49,4 +50,5 @@
 
     psImage *image = (psImage *)psAlloc(sizeof(psImage));
+    p_psMemSetDeallocator(image,(psFreeFcn)imageFree);
 
     image->data.V = psAlloc(sizeof(void*)*numRows);
@@ -71,5 +73,5 @@
 }
 
-void psImageFree(psImage *image)
+static void imageFree(psImage* image)
 {
     if (image == NULL) {
@@ -96,6 +98,4 @@
     psFree(image->data.V);
     image->data.V = NULL;
-
-    psFree(image);
 }
 
@@ -237,5 +237,5 @@
         if (children[i] != NULL) {
             numFreed++;
-            psImageFree(children[i]);
+            psFree(children[i]);
         }
     }
@@ -341,5 +341,5 @@
     case PS_TYPE_PTR: \
         psError(__func__,"Can't copy image from a matrix of pointers."); \
-        psImageFree(output); \
+        psFree(output); \
         return NULL; \
     default: \
@@ -391,5 +391,5 @@
     case PS_TYPE_PTR:
         psError(__func__,"Can't copy image into a matrix of pointers.");
-        psImageFree(output);
+        psFree(output);
         return NULL;
     }
@@ -534,5 +534,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -676,5 +676,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -818,5 +818,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -960,5 +960,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1102,5 +1102,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1244,5 +1244,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1386,5 +1386,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1528,5 +1528,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1670,5 +1670,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1812,5 +1812,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -1954,5 +1954,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -2096,5 +2096,5 @@
         case PS_TYPE_PTR:
             psError (__func__, "Can't copy image from a matrix of pointers.");
-            psImageFree (output);
+            psFree (output);
             return ((void *) 0);
         default:
@@ -2104,5 +2104,5 @@
     case PS_TYPE_PTR:
         psError (__func__, "Can't copy image into a matrix of pointers.");
-        psImageFree (output);
+        psFree (output);
         return ((void *) 0);
     }
Index: trunk/psLib/src/mathtypes/psImage.h
===================================================================
--- trunk/psLib/src/mathtypes/psImage.h	(revision 1072)
+++ trunk/psLib/src/mathtypes/psImage.h	(revision 1073)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 01:58:06 $
+ *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -110,14 +110,4 @@
 );
 
-/** Destroy the specified image.
- *
- *  Uses psLib memory deallocation functions to free an image and any existing
- *  children.
- *
- */
-void psImageFree(
-    psImage *restrict image             ///< Free psImage
-);
-
 /** Frees all children of a psImage.
  *
Index: trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- trunk/psLib/src/mathtypes/psVector.c	(revision 1072)
+++ trunk/psLib/src/mathtypes/psVector.c	(revision 1073)
@@ -8,6 +8,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 01:33:16 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -49,4 +49,5 @@
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
+static void vectorFree(psVector *restrict psVec);
 
 /*****************************************************************************/
@@ -68,4 +69,5 @@
     // Create vector struct
     psVec = (psVector *)psAlloc(sizeof(psVector));
+    p_psMemSetDeallocator(psVec,(psFreeFcn)vectorFree);
 
     psVec->type.dimen = PS_DIMEN_VECTOR;
@@ -132,5 +134,5 @@
     if(nalloc < 1) {
         psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
-        psVectorFree(in);
+        psFree(in);
         return NULL;
     }
@@ -154,5 +156,5 @@
 }
 
-void psVectorFree(psVector *restrict psVec)
+static void vectorFree(psVector *restrict psVec)
 {
     if (psVec == NULL) {
@@ -160,9 +162,15 @@
     }
 
+    if (psVec->type.type == PS_TYPE_PTR) {
+        for(int i = 0; i < psVec->n; i++) {
+            psFree(psVec->data.PTR[i]);
+            psVec->data.PTR[i] = NULL;
+        }
+    }
+
     psFree(psVec->data.V);
-    psFree(psVec);
 }
 
-void psVectorElementFree(psVector *restrict psVec, void (*elemFree)(void *))
+void psVectorElementFree(psVector *restrict psVec)
 {
 
@@ -176,10 +184,6 @@
     }
 
-    for(int i = 0; i < psVec->nalloc; i++) {
-        if(elemFree == NULL) {
-            psMemDecrRefCounter(psVec->data.PTR[i]);
-        } else {
-            elemFree(psMemDecrRefCounter(psVec->data.PTR[i]));
-        }
+    for(int i = 0; i < psVec->n; i++) {
+        psFree(psVec->data.PTR[i]);
         psVec->data.PTR[i] = NULL;
     }
Index: trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- trunk/psLib/src/mathtypes/psVector.h	(revision 1072)
+++ trunk/psLib/src/mathtypes/psVector.h	(revision 1073)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 01:58:06 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -100,17 +100,4 @@
 );
 
-/** Deallocate a vector.
- *
- * Uses psLib memory allocation functions to deallocate a vector collection of data. The vector is deallocated
- * according to the psType type member contained within the vector.
- *
- * @return psVector*: Pointer to psVector.
- *
- */
-void psVectorFree(
-    psVector *restrict psVec  ///< Vector to free.
-);
-
-
 /** Deallocate/Dereference elements of a void pointer vector.
  *
@@ -122,6 +109,5 @@
  */
 void psVectorElementFree(
-    psVector *restrict psVec,   ///< Void pointer vector to destroy.
-    void (*elemFree)(void *)    ///< Optional callback function to remove vector elements.
+    psVector *restrict psVec    ///< Void pointer vector to destroy.
 );
 
Index: trunk/psLib/src/sys/psMemory.c
===================================================================
--- trunk/psLib/src/sys/psMemory.c	(revision 1072)
+++ trunk/psLib/src/sys/psMemory.c	(revision 1073)
@@ -8,6 +8,6 @@
  *  @author Robert Lupton, Princeton University
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-04 23:46:48 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -30,6 +30,6 @@
 static int checkMemBlock(const psMemBlock *m, const char* funcName);
 static psMemBlock *lastMemBlockAllocated = NULL;
-pthread_mutex_t   memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t   memIdMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER;
 
 /**
@@ -96,5 +96,5 @@
 psMemoryId p_psMemFreeID = 0;   // notify user this block is freed
 
-psMemoryId psMemAllocateCallbackSetID(psMemoryId id) // set p_psMemAllocateID to id
+psMemoryId psMemAllocateCallbackSetID(psMemoryId id)
 {
     psMemoryId old = p_psMemAllocateID;
@@ -104,5 +104,5 @@
 }
 
-psMemoryId psMemFreeCallbackSetID(psMemoryId id)  // set p_psMemFreeID to id
+psMemoryId psMemFreeCallbackSetID(psMemoryId id)
 {
     psMemoryId old = p_psMemFreeID;
@@ -184,7 +184,5 @@
 #define ALIGNED(P) ((void *)((long)(P) & ~03) == (P))
 
-static int
-checkMemBlock(const psMemBlock *m,
-              const char* funcName)
+static int checkMemBlock(const psMemBlock *m, const char* funcName)
 {
     // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked,
@@ -260,4 +258,5 @@
 
     ptr->file = file;
+    ptr->freeFcn = NULL;
     *(unsigned int*)&ptr->lineno = lineno;
     ptr->startblock = P_PS_MEMMAGIC;
@@ -346,7 +345,8 @@
     if (checkMemBlock(ptr, __func__) != 0) {
         memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
-    }
-
-    psMemDecrRefCounter(vptr);          // this handles the free, if required.
+        return;
+    }
+
+    (void)psMemDecrRefCounter(vptr);   // this handles the free, if required.
 }
 
@@ -354,8 +354,5 @@
  * Check for memory leaks. Not production quality code
  */
-int psMemCheckLeaks(
-    psMemoryId id0,                     // don't list blocks with id < id0
-    psMemBlock ***arr,                  // pointer to array of pointers to leaked blocks, or NULL
-    FILE *fd)                           // print list of leaks to fd (or NULL)
+int psMemCheckLeaks(psMemoryId id0,psMemBlock ***arr,FILE *fd)
 {
     int nleak = 0;
@@ -365,6 +362,5 @@
     pthread_mutex_lock(&memBlockListMutex);
 
-    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
-    {
+    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
         if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
             nleak++;
@@ -382,6 +378,5 @@
     pthread_mutex_unlock(&memBlockListMutex);
 
-    if (nleak == 0 || arr == NULL)
-    {
+    if (nleak == 0 || arr == NULL) {
         return nleak;
     }
@@ -390,6 +385,5 @@
     pthread_mutex_lock(&memBlockListMutex);
 
-    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
-    {
+    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
         if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
             (*arr)[j++] = iter;
@@ -408,11 +402,11 @@
  * Reference counting APIs
  */
-psReferenceCount psMemGetRefCounter(void *vptr) // return refCounter
+// return refCounter
+psReferenceCount psMemGetRefCounter(void *vptr)
 {
     psMemBlock *ptr;
     unsigned int refCount;
 
-    if (vptr == NULL)
-    {
+    if (vptr == NULL) {
         return 0;
     }
@@ -420,6 +414,5 @@
     ptr = ((psMemBlock *)vptr) - 1;
 
-    if (checkMemBlock(ptr, __func__) != 0)
-    {
+    if (checkMemBlock(ptr, __func__) != 0) {
         memProblemCallback(ptr, __func__, __LINE__);
     }
@@ -431,11 +424,10 @@
     return refCount;
 }
-
-void *psMemIncrRefCounter(void *vptr) // increment and return refCounter
+// increment and return refCounter
+void *psMemIncrRefCounter(void *vptr)
 {
     psMemBlock *ptr;
 
-    if (vptr == NULL)
-    {
+    if (vptr == NULL) {
         return vptr;
     }
@@ -443,6 +435,5 @@
     ptr = ((psMemBlock *)vptr) - 1;
 
-    if (checkMemBlock(ptr, __func__))
-    {
+    if (checkMemBlock(ptr, __func__)) {
         memProblemCallback(ptr, __func__, __LINE__);
     }
@@ -455,8 +446,8 @@
 }
 
-void *psMemDecrRefCounter(void *vptr) // decrement and return refCounter
-{
-    if (vptr == NULL)
-    {
+// decrement and return refCounter
+void *psMemDecrRefCounter(void *vptr)
+{
+    if (vptr == NULL) {
         return NULL;
     }
@@ -467,12 +458,10 @@
     pthread_mutex_lock(&ptr->refCounterMutex);
 
-    if (ptr->refCounter > 1)
-    {
+    if (ptr->refCounter > 1) {
         /// XXX - Probably should have another mutex here.
         ptr->refCounter--;          // multiple references, just decrement the count.
         pthread_mutex_unlock(&ptr->refCounterMutex);
 
-    } else
-    {
+    } else {
         pthread_mutex_unlock(&ptr->refCounterMutex);
 
@@ -482,4 +471,8 @@
         }
 
+        if (ptr->freeFcn != NULL) {
+            ptr->freeFcn(vptr);
+        }
+
         pthread_mutex_lock(&memBlockListMutex);
 
@@ -507,15 +500,23 @@
 }
 
-void p_psCustomFree(psFreeFcn fcn, void* ptr)
-{
-
-    if (fcn == NULL) {
+void p_psMemSetDeallocator(void* vptr, psFreeFcn freeFcn)
+{
+    if (vptr == NULL) {
         return;
-    } else {
-        if (fcn == PS_FREE) {
-            psFree(ptr);
-        } else {
-            fcn(ptr);
-        }
-    }
-}
+    }
+
+    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
+
+    ptr->freeFcn = freeFcn;
+
+}
+psFreeFcn p_psMemGetDeallocator(void* vptr)
+{
+    if (vptr == NULL) {
+        return NULL;
+    }
+
+    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
+
+    return ptr->freeFcn;
+}
Index: trunk/psLib/src/sys/psMemory.h
===================================================================
--- trunk/psLib/src/sys/psMemory.h	(revision 1072)
+++ trunk/psLib/src/sys/psMemory.h	(revision 1073)
@@ -14,6 +14,6 @@
  *  @ingroup MemoryManagement
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 02:09:57 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -50,4 +50,7 @@
 /// typedef for a memory block's reference count. Guaranteed to be some variety of integer.
 typedef unsigned long psReferenceCount;
+
+/// typedef for deallocator.
+typedef void (*psFreeFcn)(void* ptr);
 
 /** Book-keeping data for storage allocator.
@@ -58,14 +61,15 @@
 typedef struct psMemBlock
 {
-    const void* startblock;             ///< initialised to p_psMEMMAGIC
-    struct psMemBlock* previousBlock;   ///< previous block in allocation list
-    struct psMemBlock* nextBlock;       ///< next block allocation list
-    size_t  userMemorySize;             ///< the size of the user-portion of the memory block
-    const psMemoryId id;                ///< a unique ID for this allocation
-    const char* file;                   ///< set from __FILE__ in e.g. p_psAlloc
-    const int lineno;                   ///< set from __LINE__ in e.g. p_psAlloc
-    pthread_mutex_t   refCounterMutex;  ///< mutex to ensure exclusive access to reference counter
-    psReferenceCount refCounter;        ///< how many times pointer is referenced
-    const void* endblock;               ///< initialised to p_psMEMMAGIC
+    const void* startblock;            ///< initialised to p_psMEMMAGIC
+    struct psMemBlock* previousBlock;  ///< previous block in allocation list
+    struct psMemBlock* nextBlock;      ///< next block allocation list
+    psFreeFcn freeFcn;                 ///< deallocator.  If NULL, use generic deallocation.
+    size_t  userMemorySize;            ///< the size of the user-portion of the memory block
+    const psMemoryId id;               ///< a unique ID for this allocation
+    const char* file;                  ///< set from __FILE__ in e.g. p_psAlloc
+    const int lineno;                  ///< set from __LINE__ in e.g. p_psAlloc
+    pthread_mutex_t   refCounterMutex; ///< mutex to ensure exclusive access to reference counter
+    psReferenceCount refCounter;       ///< how many times pointer is referenced
+    const void* endblock;              ///< initialised to p_psMEMMAGIC
 }
 psMemBlock;
@@ -114,10 +118,8 @@
 );
 
-typedef void (*psFreeFcn)(void* ptr);
-
 /** Memory allocation.  This operates much like malloc(), but is guaranteed to return a non-NULL value.
  *
  *  @return void* pointer to the allocated buffer. This will not be NULL.
- *  @see psFree
+ *  @see psFree 
  */
 #ifdef DOXYGEN
@@ -131,4 +133,8 @@
     int lineno                      ///< Line number of call
 );
+
+void p_psMemSetDeallocator(void* ptr, psFreeFcn freeFcn);
+psFreeFcn p_psMemGetDeallocator(void* ptr);
+
 /// Memory allocation. psAlloc sends file and line number to p_psAlloc.
 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__)
@@ -282,12 +288,7 @@
 );
 
-#define PS_FREE     (void*)1
-
 //@} End of Memory Management Functions
 
-
 #ifndef DOXYGEN
-
-void p_psCustomFree(psFreeFcn fcn,void* ptr);
 
 /*
Index: trunk/psLib/src/sysUtils/psHash.c
===================================================================
--- trunk/psLib/src/sysUtils/psHash.c	(revision 1072)
+++ trunk/psLib/src/sysUtils/psHash.c	(revision 1073)
@@ -10,6 +10,6 @@
  *  @author George Gusciora, MHPCC
  *   
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 00:09:55 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -18,4 +18,5 @@
 #include <stdio.h>
 #include <string.h>
+#include <stdbool.h>
 #include "psHash.h"
 #include "psMemory.h"
@@ -24,4 +25,9 @@
 #include "psAbort.h"
 
+static psHashBucket *hashBucketAlloc(const char *key,void *data,psHashBucket *next);
+static void hashBucketFree(psHashBucket *bucket);
+static void *doHashWork(psHash* table, const char* key, void* data, bool remove
+                           );
+static void hashFree(psHash *table);
 
 /******************************************************************************
@@ -87,4 +93,5 @@
     // Allocate memory for the new hash bucket.
     psHashBucket *bucket = psAlloc(sizeof(psHashBucket));
+    p_psMemSetDeallocator(bucket,(psFreeFcn)hashBucketFree);
 
     // Initialize the bucket.
@@ -105,20 +112,14 @@
 
 /******************************************************************************
-hashBucketFree(bucket, itemFree): This procedure deallocates the specified
-hash bucket.  If "itemFree" is NULL, then we simply free the data with the
-standard psFree() function.  If "itemFree" is not NULL, then it must be a
-function pointer which takes the hash bucket as a parameter, and frees the
-data in that hash bucket.
+hashBucketFree(bucket): This procedure deallocates the specified
+hash bucket.  
 Inputs:
     bucket: the hash bucket to be freed.
-    itemFree: a function pointer, possibly NULL.
 Return:
     NONE
  *****************************************************************************/
-static void hashBucketFree(psHashBucket *bucket,   // bucket to free
-                           void (*itemFree)(void *item)) // how to free data;
-{
-    if (bucket == NULL)
-    {
+static void hashBucketFree(psHashBucket *bucket)
+{
+    if (bucket == NULL) {
         return;
     }
@@ -126,21 +127,9 @@
     // A bucket is actually a linked list of buckets.  We recursively step
     // through that linked list, free each bucket.
-    if (bucket->next != NULL)
-    {
-        hashBucketFree(bucket, itemFree);
-    }
+    psFree(bucket->next);
 
     psFree(bucket->key);
-    psMemDecrRefCounter(bucket->data);
-
-    if (itemFree != NULL)
-    {
-        itemFree(bucket->data);
-    } else
-    {
-        psFree(bucket->data);
-    }
-
-    psFree(bucket);
+
+    psFree(bucket->data);
 }
 
@@ -159,4 +148,5 @@
     // Create the new hash table.
     psHash *table = psAlloc(sizeof(psHash));
+    p_psMemSetDeallocator(table,(psFreeFcn)hashFree);
 
     // Allocate memory for the buckets.
@@ -185,10 +175,8 @@
 Inputs:
     table: a hash table
-    itemFree: a function pointer, possibly NULL.
 Return:
     NONE
  *****************************************************************************/
-void psHashFree(psHash *table,  // hash table to be freed
-                void (*itemFree)(void *item)) // how to free hashed data; or NULL
+static void hashFree(psHash *table)
 {
     psHashBucket *tmp = NULL;           // Used to step through linked list.
@@ -196,6 +184,5 @@
     int i = 0;                          // Loop index variable.
 
-    if (table == NULL)
-    {
+    if (table == NULL) {
         return;
     }
@@ -204,6 +191,5 @@
     // NULL, then free the bucket via a function call to hashBucketFree();
 
-    for (i = 0; i < table->nbucket; i++)
-    {
+    for (i = 0; i < table->nbucket; i++) {
         // A bucket is composed of a linked list of buckets.  We use the
         // "tmp" and "ptr" pointers to step through that list and free each
@@ -214,5 +200,5 @@
             while (ptr != NULL) {
                 tmp = ptr->next;
-                hashBucketFree(ptr, itemFree);
+                psFree(ptr);
                 ptr = tmp;
             }
@@ -222,15 +208,13 @@
     // Free the bucket structure, then the hash table.
     psFree(table->buckets);
-    psFree(table);
-}
-
-/******************************************************************************
-doHashWork(table, key, data, remove, itemFree): This is an internal
+}
+
+/******************************************************************************
+doHashWork(table, key, data, remove): This is an internal
 procedure which does the bulk of the work in using the hash table.  Depending
 upon the input parameters, it will either insert a new key/data into the hash
 table, retrieve the data for a specified key, or remove a key/data item.  If
-we try to insert a key that already exists in the hash table, then we call
-the user-supplied function itemfree (or psFree if that is NULL), to free the
-existing data/key item.
+we try to insert a key that already exists in the hash table, then we deallocate
+the existing data/key item.
 Inputs:
     table: a hash table
@@ -238,5 +222,4 @@
     data: the data to insert, if not NULL
     remove: set to non-zero if the key/data should be removed from the table.
-    itemFree: function pointer
 Return:
     NONE
@@ -246,10 +229,6 @@
 there is little common code between those functions.
   *****************************************************************************/
-static void *doHashWork(psHash     *table,   // table to insert in
-                        const char *key,     // key to use
-                        void       *data,    // data to insert, or (if NULL) retrieve/remove
-                        int remove
-                            ,          // remove the item from the list?
-                            void (*itemFree)(void *item)) // how to free hashed data
+static void *doHashWork(psHash *table, const char *key, void *data, bool remove
+                           )
 {
     long int hash = 1;                  // This will contain an integer value
@@ -313,10 +292,9 @@
                     }
 
-                    psFree(ptr->key);
                     psFree(ptr);
 
                     // By definition, the data associated with that key
                     // must be returned, not freed.
-                    return psMemDecrRefCounter(data);
+                    return data;
                 }
                 optr = ptr;
@@ -354,9 +332,5 @@
                 // the new data was not inserted into the hash table.
 
-                if (itemFree == NULL) {
-                    psFree(psMemDecrRefCounter(ptr->data));
-                } else {
-                    itemFree(psMemDecrRefCounter(ptr->data));
-                }
+                psFree(ptr->data);
 
                 ptr->data = psMemIncrRefCounter(data);
@@ -385,8 +359,5 @@
     NONE
  *****************************************************************************/
-void *psHashInsert(psHash *table,   // table to insert in
-                   const char *key, // key to use
-                   void *data,      // data to insert
-                   void (*itemFree)(void *item)) // how to free hashed data;
+void *psHashInsert(psHash *table, const char *key, void *data)
 {
     if (table == NULL) {
@@ -400,5 +371,5 @@
     }
 
-    return doHashWork(table, key, data, 0, itemFree);
+    return doHashWork(table, key, data, 0);
 }
 
@@ -425,5 +396,5 @@
 
 
-    return doHashWork(table, key, NULL, 0, NULL);
+    return doHashWork(table, key, NULL, 0);
 }
 
@@ -438,7 +409,5 @@
     The data that was associated with that key.
  *****************************************************************************/
-void *psHashRemove(psHash *table,   // table to lookup key in
-                   const char *key, // key to lookup
-                   void (*itemFree)(void *item)) // how to free hashed data;
+void *psHashRemove(psHash *table, const char *key)
 {
     if (table == NULL) {
@@ -449,4 +418,4 @@
     }
 
-    return doHashWork(table, key, NULL, 1, itemFree);
-}
+    return doHashWork(table, key, NULL, 1);
+}
Index: trunk/psLib/src/sysUtils/psHash.d
===================================================================
--- trunk/psLib/src/sysUtils/psHash.d	(revision 1072)
+++ trunk/psLib/src/sysUtils/psHash.d	(revision 1073)
@@ -1,3 +1,3 @@
 psHash.o psHash.d : psHash.c psHash.h ../collections/psList.h \
-  ../collections/psVector.h ../collections/psType.h \
-  ../sysUtils/psMemory.h psString.h psTrace.h psAbort.h
+  ../collections/psVector.h ../collections/psType.h psMemory.h psString.h \
+  psTrace.h psAbort.h
Index: trunk/psLib/src/sysUtils/psHash.h
===================================================================
--- trunk/psLib/src/sysUtils/psHash.h	(revision 1072)
+++ trunk/psLib/src/sysUtils/psHash.h	(revision 1073)
@@ -10,6 +10,6 @@
  *  @author George Gusciora, MHPCC
  *   
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 05:50:01 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -45,25 +45,18 @@
                    );
 
-/// Free hash buckets from table.
-void psHashFree(psHash *table,               ///< hash table to be freed
-                void (*itemFree)(void *item) ///< how to free hashed data; or NULL
-               );
-
 /// Insert entry into table.
 void *psHashInsert(psHash *table,               ///< table to insert in
                    const char *key,             ///< key to use
-                   void *data,                  ///< data to insert
-                   void (*itemFree)(void *item) ///< how to free hashed data; or NULL
+                   void *data                   ///< data to insert
                   );
 
 /// Lookup key in table.
-void *psHashLookup(psHash *table, ///< table to lookup key in
-                   const char *key ///< key to lookup
+void *psHashLookup(psHash *table,      ///< table to lookup key in
+                   const char *key     ///< key to lookup
                   );
 
 /// Remove key from table.
-void *psHashRemove(psHash *table, ///< table to lookup key in
-                   const char *key, ///< key to lookup
-                   void (*itemFree)(void *item) ///< how to free hashed data; or NULL
+void *psHashRemove(psHash *table,      ///< table to lookup key in
+                   const char *key     ///< key to lookup
                   );
 
Index: trunk/psLib/src/sysUtils/psMemory.c
===================================================================
--- trunk/psLib/src/sysUtils/psMemory.c	(revision 1072)
+++ trunk/psLib/src/sysUtils/psMemory.c	(revision 1073)
@@ -8,6 +8,6 @@
  *  @author Robert Lupton, Princeton University
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-04 23:46:48 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -30,6 +30,6 @@
 static int checkMemBlock(const psMemBlock *m, const char* funcName);
 static psMemBlock *lastMemBlockAllocated = NULL;
-pthread_mutex_t   memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t   memIdMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t memIdMutex = PTHREAD_MUTEX_INITIALIZER;
 
 /**
@@ -96,5 +96,5 @@
 psMemoryId p_psMemFreeID = 0;   // notify user this block is freed
 
-psMemoryId psMemAllocateCallbackSetID(psMemoryId id) // set p_psMemAllocateID to id
+psMemoryId psMemAllocateCallbackSetID(psMemoryId id)
 {
     psMemoryId old = p_psMemAllocateID;
@@ -104,5 +104,5 @@
 }
 
-psMemoryId psMemFreeCallbackSetID(psMemoryId id)  // set p_psMemFreeID to id
+psMemoryId psMemFreeCallbackSetID(psMemoryId id)
 {
     psMemoryId old = p_psMemFreeID;
@@ -184,7 +184,5 @@
 #define ALIGNED(P) ((void *)((long)(P) & ~03) == (P))
 
-static int
-checkMemBlock(const psMemBlock *m,
-              const char* funcName)
+static int checkMemBlock(const psMemBlock *m, const char* funcName)
 {
     // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked,
@@ -260,4 +258,5 @@
 
     ptr->file = file;
+    ptr->freeFcn = NULL;
     *(unsigned int*)&ptr->lineno = lineno;
     ptr->startblock = P_PS_MEMMAGIC;
@@ -346,7 +345,8 @@
     if (checkMemBlock(ptr, __func__) != 0) {
         memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
-    }
-
-    psMemDecrRefCounter(vptr);          // this handles the free, if required.
+        return;
+    }
+
+    (void)psMemDecrRefCounter(vptr);   // this handles the free, if required.
 }
 
@@ -354,8 +354,5 @@
  * Check for memory leaks. Not production quality code
  */
-int psMemCheckLeaks(
-    psMemoryId id0,                     // don't list blocks with id < id0
-    psMemBlock ***arr,                  // pointer to array of pointers to leaked blocks, or NULL
-    FILE *fd)                           // print list of leaks to fd (or NULL)
+int psMemCheckLeaks(psMemoryId id0,psMemBlock ***arr,FILE *fd)
 {
     int nleak = 0;
@@ -365,6 +362,5 @@
     pthread_mutex_lock(&memBlockListMutex);
 
-    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
-    {
+    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
         if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
             nleak++;
@@ -382,6 +378,5 @@
     pthread_mutex_unlock(&memBlockListMutex);
 
-    if (nleak == 0 || arr == NULL)
-    {
+    if (nleak == 0 || arr == NULL) {
         return nleak;
     }
@@ -390,6 +385,5 @@
     pthread_mutex_lock(&memBlockListMutex);
 
-    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock)
-    {
+    for (psMemBlock* iter = topBlock; iter != NULL; iter=iter->nextBlock) {
         if ( (psMemGetRefCounter(iter+1) > 0) && (iter->id >= id0) ) {
             (*arr)[j++] = iter;
@@ -408,11 +402,11 @@
  * Reference counting APIs
  */
-psReferenceCount psMemGetRefCounter(void *vptr) // return refCounter
+// return refCounter
+psReferenceCount psMemGetRefCounter(void *vptr)
 {
     psMemBlock *ptr;
     unsigned int refCount;
 
-    if (vptr == NULL)
-    {
+    if (vptr == NULL) {
         return 0;
     }
@@ -420,6 +414,5 @@
     ptr = ((psMemBlock *)vptr) - 1;
 
-    if (checkMemBlock(ptr, __func__) != 0)
-    {
+    if (checkMemBlock(ptr, __func__) != 0) {
         memProblemCallback(ptr, __func__, __LINE__);
     }
@@ -431,11 +424,10 @@
     return refCount;
 }
-
-void *psMemIncrRefCounter(void *vptr) // increment and return refCounter
+// increment and return refCounter
+void *psMemIncrRefCounter(void *vptr)
 {
     psMemBlock *ptr;
 
-    if (vptr == NULL)
-    {
+    if (vptr == NULL) {
         return vptr;
     }
@@ -443,6 +435,5 @@
     ptr = ((psMemBlock *)vptr) - 1;
 
-    if (checkMemBlock(ptr, __func__))
-    {
+    if (checkMemBlock(ptr, __func__)) {
         memProblemCallback(ptr, __func__, __LINE__);
     }
@@ -455,8 +446,8 @@
 }
 
-void *psMemDecrRefCounter(void *vptr) // decrement and return refCounter
-{
-    if (vptr == NULL)
-    {
+// decrement and return refCounter
+void *psMemDecrRefCounter(void *vptr)
+{
+    if (vptr == NULL) {
         return NULL;
     }
@@ -467,12 +458,10 @@
     pthread_mutex_lock(&ptr->refCounterMutex);
 
-    if (ptr->refCounter > 1)
-    {
+    if (ptr->refCounter > 1) {
         /// XXX - Probably should have another mutex here.
         ptr->refCounter--;          // multiple references, just decrement the count.
         pthread_mutex_unlock(&ptr->refCounterMutex);
 
-    } else
-    {
+    } else {
         pthread_mutex_unlock(&ptr->refCounterMutex);
 
@@ -482,4 +471,8 @@
         }
 
+        if (ptr->freeFcn != NULL) {
+            ptr->freeFcn(vptr);
+        }
+
         pthread_mutex_lock(&memBlockListMutex);
 
@@ -507,15 +500,23 @@
 }
 
-void p_psCustomFree(psFreeFcn fcn, void* ptr)
-{
-
-    if (fcn == NULL) {
+void p_psMemSetDeallocator(void* vptr, psFreeFcn freeFcn)
+{
+    if (vptr == NULL) {
         return;
-    } else {
-        if (fcn == PS_FREE) {
-            psFree(ptr);
-        } else {
-            fcn(ptr);
-        }
-    }
-}
+    }
+
+    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
+
+    ptr->freeFcn = freeFcn;
+
+}
+psFreeFcn p_psMemGetDeallocator(void* vptr)
+{
+    if (vptr == NULL) {
+        return NULL;
+    }
+
+    psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
+
+    return ptr->freeFcn;
+}
Index: trunk/psLib/src/sysUtils/psMemory.h
===================================================================
--- trunk/psLib/src/sysUtils/psMemory.h	(revision 1072)
+++ trunk/psLib/src/sysUtils/psMemory.h	(revision 1073)
@@ -14,6 +14,6 @@
  *  @ingroup MemoryManagement
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 02:09:57 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -50,4 +50,7 @@
 /// typedef for a memory block's reference count. Guaranteed to be some variety of integer.
 typedef unsigned long psReferenceCount;
+
+/// typedef for deallocator.
+typedef void (*psFreeFcn)(void* ptr);
 
 /** Book-keeping data for storage allocator.
@@ -58,14 +61,15 @@
 typedef struct psMemBlock
 {
-    const void* startblock;             ///< initialised to p_psMEMMAGIC
-    struct psMemBlock* previousBlock;   ///< previous block in allocation list
-    struct psMemBlock* nextBlock;       ///< next block allocation list
-    size_t  userMemorySize;             ///< the size of the user-portion of the memory block
-    const psMemoryId id;                ///< a unique ID for this allocation
-    const char* file;                   ///< set from __FILE__ in e.g. p_psAlloc
-    const int lineno;                   ///< set from __LINE__ in e.g. p_psAlloc
-    pthread_mutex_t   refCounterMutex;  ///< mutex to ensure exclusive access to reference counter
-    psReferenceCount refCounter;        ///< how many times pointer is referenced
-    const void* endblock;               ///< initialised to p_psMEMMAGIC
+    const void* startblock;            ///< initialised to p_psMEMMAGIC
+    struct psMemBlock* previousBlock;  ///< previous block in allocation list
+    struct psMemBlock* nextBlock;      ///< next block allocation list
+    psFreeFcn freeFcn;                 ///< deallocator.  If NULL, use generic deallocation.
+    size_t  userMemorySize;            ///< the size of the user-portion of the memory block
+    const psMemoryId id;               ///< a unique ID for this allocation
+    const char* file;                  ///< set from __FILE__ in e.g. p_psAlloc
+    const int lineno;                  ///< set from __LINE__ in e.g. p_psAlloc
+    pthread_mutex_t   refCounterMutex; ///< mutex to ensure exclusive access to reference counter
+    psReferenceCount refCounter;       ///< how many times pointer is referenced
+    const void* endblock;              ///< initialised to p_psMEMMAGIC
 }
 psMemBlock;
@@ -114,10 +118,8 @@
 );
 
-typedef void (*psFreeFcn)(void* ptr);
-
 /** Memory allocation.  This operates much like malloc(), but is guaranteed to return a non-NULL value.
  *
  *  @return void* pointer to the allocated buffer. This will not be NULL.
- *  @see psFree
+ *  @see psFree 
  */
 #ifdef DOXYGEN
@@ -131,4 +133,8 @@
     int lineno                      ///< Line number of call
 );
+
+void p_psMemSetDeallocator(void* ptr, psFreeFcn freeFcn);
+psFreeFcn p_psMemGetDeallocator(void* ptr);
+
 /// Memory allocation. psAlloc sends file and line number to p_psAlloc.
 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__)
@@ -282,12 +288,7 @@
 );
 
-#define PS_FREE     (void*)1
-
 //@} End of Memory Management Functions
 
-
 #ifndef DOXYGEN
-
-void p_psCustomFree(psFreeFcn fcn,void* ptr);
 
 /*
Index: trunk/psLib/src/types/psBitSet.c
===================================================================
--- trunk/psLib/src/types/psBitSet.c	(revision 1072)
+++ trunk/psLib/src/types/psBitSet.c	(revision 1073)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-15 02:45:43 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -55,4 +55,6 @@
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
+static void bitSetFree(psBitSet *restrict inBitSet);
+
 
 /** Private function to create a mask.
@@ -88,4 +90,5 @@
     numBytes = ceil(n/8.0);
     newObj = psAlloc(sizeof(psBitSet));
+    p_psMemSetDeallocator(newObj,(psFreeFcn)bitSetFree);
     newObj->n = numBytes;
 
@@ -98,5 +101,5 @@
 }
 
-void psBitSetFree(psBitSet *restrict inBitSet)
+static void bitSetFree(psBitSet *restrict inBitSet)
 {
     if(inBitSet == NULL) {
@@ -105,5 +108,4 @@
     }
     psFree(inBitSet->bits);
-    psFree(inBitSet);
 }
 
Index: trunk/psLib/src/types/psBitSet.h
===================================================================
--- trunk/psLib/src/types/psBitSet.h	(revision 1072)
+++ trunk/psLib/src/types/psBitSet.h	(revision 1073)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-10 01:58:06 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -54,12 +54,4 @@
 psBitSet* psBitSetAlloc(
     int n   /**< Number of bits in psBitSet array */
-);
-
-/** Free a psBitSet
- *
- *  Deletes a psBitSet array.
- */
-void psBitSetFree(
-    psBitSet *restrict inMask  /**< Pointer to psBitSet to be deleted. */
 );
 
Index: trunk/psLib/src/types/psList.c
===================================================================
--- trunk/psLib/src/types/psList.c	(revision 1072)
+++ trunk/psLib/src/types/psList.c	(revision 1073)
@@ -6,6 +6,6 @@
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-14 19:45:46 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -28,7 +28,8 @@
 
 // private functions.
-psListElem* listGetIterator(psList* list);
-int listGetIteratorIndex(psList* list);
-void listSetIterator(psList *list, int where, bool lockList);
+static psListElem* listGetIterator(psList* list);
+static int listGetIteratorIndex(psList* list);
+static void listSetIterator(psList *list, int where, bool lockList);
+static void listFree(psList *list);
 
 
@@ -36,4 +37,5 @@
 {
     psList *list = psAlloc(sizeof(psList));
+    p_psMemSetDeallocator(list,(psFreeFcn)listFree);
 
     list->size = 0;
@@ -41,4 +43,5 @@
     list->iter = ITER_INIT_HEAD;
     list->iterIndex = PS_LIST_HEAD;
+
     pthread_mutex_init(&(list->lock),NULL)
     ;
@@ -51,5 +54,5 @@
 }
 
-void psListFree(psList *list, psFreeFcn elemFree)
+static void listFree(psList *list)
 {
     if (list == NULL) {
@@ -63,5 +66,5 @@
         psListElem *next = ptr->next;
 
-        p_psCustomFree(elemFree, psMemDecrRefCounter(ptr->data));
+        psFree(ptr->data);
         psFree(ptr);
 
@@ -75,5 +78,4 @@
     ;
 
-    psFree(list);
 }
 
Index: trunk/psLib/src/types/psList.h
===================================================================
--- trunk/psLib/src/types/psList.h	(revision 1072)
+++ trunk/psLib/src/types/psList.h	(revision 1073)
@@ -10,6 +10,6 @@
  *  @ingroup LinkedList
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-06-12 22:15:39 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-23 23:00:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -73,15 +73,4 @@
 )
 ;
-
-#include "psMemory.h"
-/** Destroys a psList linked list object.  This also frees the elements of the
- *  list using the psFreeFcn given, if any.  If no psFreeFcn is specified,
- *  the elements are just dereferenced via psMemDecrRefCounter(...).
- *
- */
-void psListFree(
-    psList* restrict list,              ///< list to destroy
-    psFreeFcn elemFree                  ///< destructor for data on list
-);
 
 /** Adds an element to a psList at position given.
