IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psStats.c

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