Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 1071)
+++ 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);
 }
 
