Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Histogram
comparison Histogram.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 | 6e864a0cb520 |
| children | 83a412f2ef98 |
comparison
equal
deleted
inserted
replaced
| 0:2a791e7d37a2 | 1:60428bf5ba01 |
|---|---|
| 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 plus a range of | 12 /*This Histogram Abstract Data Type has a number of bins plus a range of |
| 14 * values that the bins span, both chosen at creation. | 13 * values that the bins span, both chosen at creation. |
| 15 * | 14 * |
| 26 makeHistogram( int numBins, int startOfRange, int endOfRange ) | 25 makeHistogram( int numBins, int startOfRange, int endOfRange ) |
| 27 { | 26 { |
| 28 Histogram *hist; | 27 Histogram *hist; |
| 29 int i; | 28 int i; |
| 30 | 29 |
| 31 hist = malloc( sizeof(Histogram) ); | 30 hist = VMS__malloc( sizeof(Histogram) ); |
| 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 = (endOfRange - startOfRange) / numBins; | 34 hist->binWidth = (endOfRange - startOfRange) / numBins; |
| 36 hist->endOfRange = startOfRange + hist->binWidth * numBins; | 35 hist->endOfRange = startOfRange + hist->binWidth * numBins; |
| 37 hist->startOfRange = startOfRange; | 36 hist->startOfRange = startOfRange; |
| 91 } | 90 } |
| 92 printf("\n"); | 91 printf("\n"); |
| 93 } | 92 } |
| 94 } | 93 } |
| 95 | 94 |
| 95 void | |
| 96 freeHist( Histogram *hist ) | |
| 97 { | |
| 98 VMS__free( hist->bins ); | |
| 99 VMS__free( hist ); | |
| 100 } |
