comparison DblHist.c @ 3:3d35477a5121

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
comparison
equal deleted inserted replaced
0:20a7e34aeac4 1:5170eb3621b1
5 * Author: seanhalle@yahoo.com 5 * Author: seanhalle@yahoo.com
6 * 6 *
7 */ 7 */
8 8
9 #include "Histogram.h" 9 #include "Histogram.h"
10 #include <malloc.h>
11 10
12 11
13 /*This Histogram Abstract Data Type has a number of bins, the starting 12 /*This Histogram Abstract Data Type has a number of bins, the starting
14 * value, and the width of each bin, as a float, all chosen at creation. 13 * value, and the width of each bin, as a float, all chosen at creation.
15 * 14 *
26 makeDblHistogram( int32 numBins, float64 startOfRange, float64 binWidth ) 25 makeDblHistogram( int32 numBins, float64 startOfRange, float64 binWidth )
27 { 26 {
28 DblHist *hist; 27 DblHist *hist;
29 int i; 28 int i;
30 29
31 hist = malloc( sizeof(DblHist) ); 30 hist = VMS__malloc( sizeof(DblHist) );
32 hist->bins = malloc( numBins * sizeof(int) ); 31 hist->bins = VMS__malloc( numBins * sizeof(int) );
33 32
34 hist->numBins = numBins; 33 hist->numBins = numBins;
35 hist->binWidth = binWidth; 34 hist->binWidth = binWidth;
36 hist->endOfRange = startOfRange + hist->binWidth * numBins; 35 hist->endOfRange = startOfRange + hist->binWidth * numBins;
37 hist->startOfRange = startOfRange; 36 hist->startOfRange = startOfRange;
96 } 95 }
97 printf("\n"); 96 printf("\n");
98 } 97 }
99 } 98 }
100 99
100
101 void
102 freeDblHist( DblHist *hist )
103 {
104 VMS__free( hist->bins );
105 VMS__free( hist );
106 }