Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Histogram
comparison FloatHist.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:3d52e900a017 | 1:d3b2e6ead5a1 |
|---|---|
| 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 | |
| 12 | 10 |
| 13 /*This Histogram Abstract Data Type has a number of bins, the starting | 11 /*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. | 12 * value, and the width of each bin, as a float, all chosen at creation. |
| 15 * | 13 * |
| 16 *One creates a Histogram instance using the makeFloatHistogram function, then | 14 *One creates a Histogram instance using the makeFloatHistogram function, then |
| 26 makeFloatHistogram( int32 numBins, float32 startOfRange, float32 binWidth ) | 24 makeFloatHistogram( int32 numBins, float32 startOfRange, float32 binWidth ) |
| 27 { | 25 { |
| 28 FloatHist *hist; | 26 FloatHist *hist; |
| 29 int i; | 27 int i; |
| 30 | 28 |
| 31 hist = malloc( sizeof(FloatHist) ); | 29 hist = VMS__malloc( sizeof(FloatHist) ); |
| 32 hist->bins = malloc( numBins * sizeof(int) ); | 30 hist->bins = VMS__malloc( numBins * sizeof(int) ); |
| 33 | 31 |
| 34 hist->numBins = numBins; | 32 hist->numBins = numBins; |
| 35 hist->binWidth = binWidth; | 33 hist->binWidth = binWidth; |
| 36 hist->endOfRange = startOfRange + hist->binWidth * numBins; | 34 hist->endOfRange = startOfRange + hist->binWidth * numBins; |
| 37 hist->startOfRange = startOfRange; | 35 hist->startOfRange = startOfRange; |
| 96 } | 94 } |
| 97 printf("\n"); | 95 printf("\n"); |
| 98 } | 96 } |
| 99 } | 97 } |
| 100 | 98 |
| 99 | |
| 100 void | |
| 101 freeDblHist( FloatHist *hist ) | |
| 102 { | |
| 103 VMS__free( hist->bins ); | |
| 104 VMS__free( hist ); | |
| 105 } |
