changeset 3:3d35477a5121 VMS__malloc_brch

This branch has replace malloc and free with VMS__malloc and VMS__free
author Me
date Sun, 31 Oct 2010 20:22:29 -0700
parents 06128e387cfa
children 83a412f2ef98
files DblHist.c FloatHist.c Histogram.c
diffstat 3 files changed, 26 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/DblHist.c	Sat Oct 30 22:13:09 2010 -0700
     1.2 +++ b/DblHist.c	Sun Oct 31 20:22:29 2010 -0700
     1.3 @@ -7,7 +7,6 @@
     1.4   */
     1.5  
     1.6  #include "Histogram.h"
     1.7 -#include <malloc.h>
     1.8  
     1.9  
    1.10  /*This Histogram Abstract Data Type has a number of bins, the starting
    1.11 @@ -28,8 +27,8 @@
    1.12     DblHist *hist;
    1.13     int i;
    1.14  
    1.15 -   hist = malloc( sizeof(DblHist) );
    1.16 -   hist->bins = malloc( numBins * sizeof(int) );
    1.17 +   hist = VMS__malloc( sizeof(DblHist) );
    1.18 +   hist->bins = VMS__malloc( numBins * sizeof(int) );
    1.19  
    1.20     hist->numBins      = numBins;
    1.21     hist->binWidth     = binWidth;
    1.22 @@ -98,3 +97,10 @@
    1.23      }
    1.24   }
    1.25  
    1.26 +
    1.27 +void
    1.28 +freeDblHist( DblHist *hist )
    1.29 + {
    1.30 +   VMS__free( hist->bins );
    1.31 +   VMS__free( hist );
    1.32 + }
     2.1 --- a/FloatHist.c	Sat Oct 30 22:13:09 2010 -0700
     2.2 +++ b/FloatHist.c	Sun Oct 31 20:22:29 2010 -0700
     2.3 @@ -7,8 +7,6 @@
     2.4   */
     2.5  
     2.6  #include "Histogram.h"
     2.7 -#include <malloc.h>
     2.8 -
     2.9  
    2.10  /*This Histogram Abstract Data Type has a number of bins, the starting
    2.11   * value, and the width of each bin, as a float, all chosen at creation.
    2.12 @@ -28,8 +26,8 @@
    2.13     FloatHist *hist;
    2.14     int i;
    2.15  
    2.16 -   hist = malloc( sizeof(FloatHist) );
    2.17 -   hist->bins = malloc( numBins * sizeof(int) );
    2.18 +   hist = VMS__malloc( sizeof(FloatHist) );
    2.19 +   hist->bins = VMS__malloc( numBins * sizeof(int) );
    2.20  
    2.21     hist->numBins      = numBins;
    2.22     hist->binWidth     = binWidth;
    2.23 @@ -98,3 +96,10 @@
    2.24      }
    2.25   }
    2.26  
    2.27 +
    2.28 +void
    2.29 +freeDblHist( FloatHist *hist )
    2.30 + {
    2.31 +   VMS__free( hist->bins );
    2.32 +   VMS__free( hist );
    2.33 + }
     3.1 --- a/Histogram.c	Sat Oct 30 22:13:09 2010 -0700
     3.2 +++ b/Histogram.c	Sun Oct 31 20:22:29 2010 -0700
     3.3 @@ -7,7 +7,6 @@
     3.4   */
     3.5  
     3.6  #include "Histogram.h"
     3.7 -#include <malloc.h>
     3.8  
     3.9  
    3.10  /*This Histogram Abstract Data Type has a number of bins plus a range of
    3.11 @@ -28,8 +27,8 @@
    3.12     Histogram *hist;
    3.13     int i;
    3.14  
    3.15 -   hist = malloc( sizeof(Histogram) );
    3.16 -   hist->bins = malloc( numBins * sizeof(int) );
    3.17 +   hist = VMS__malloc( sizeof(Histogram) );
    3.18 +   hist->bins = VMS__malloc( numBins * sizeof(int) );
    3.19  
    3.20     hist->numBins      = numBins;
    3.21     hist->binWidth     = (endOfRange - startOfRange) / numBins;
    3.22 @@ -93,3 +92,9 @@
    3.23      }
    3.24   }
    3.25  
    3.26 +void
    3.27 +freeHist( Histogram *hist )
    3.28 + {
    3.29 +   VMS__free( hist->bins );
    3.30 +   VMS__free( hist );
    3.31 + }