Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Histogram
comparison Histogram.c @ 14:1fbaedaac2c7
made defualt brch pure C (no VMS__malloc..)
| author | Me@portablequad |
|---|---|
| date | Sat, 11 Feb 2012 19:19:06 -0800 |
| parents | 31a248920429 |
| children | 32489b8b763c |
comparison
equal
deleted
inserted
replaced
| 9:46294775ff4b | 10:4c6bac8365ea |
|---|---|
| 5 * Author: seanhalle@yahoo.com | 5 * Author: seanhalle@yahoo.com |
| 6 * | 6 * |
| 7 */ | 7 */ |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include "Histogram.h" | 9 #include "Histogram.h" |
| 10 #include "../VMS.h" | |
| 11 #include "../vutilities.h" | |
| 12 #include "../vmalloc.h" | |
| 13 | 10 |
| 14 //External variables for saving of the histogram | 11 //External variables for saving of the histogram |
| 15 //These have to be defined by to plugins in order to enable VMS to print this | 12 //These have to be defined by to plugins in order to enable VMS to print this |
| 16 //information to the histogram file | 13 //information to the histogram file |
| 17 extern char __ProgrammName[]; //Defined in main.c | 14 extern char __ProgrammName[]; //Defined in main.c |
| 36 { | 33 { |
| 37 Histogram *hist; | 34 Histogram *hist; |
| 38 int32 i; | 35 int32 i; |
| 39 | 36 |
| 40 | 37 |
| 41 hist = VMS__malloc( sizeof(Histogram) ); | 38 hist = malloc( sizeof(Histogram) ); |
| 42 hist->bins = VMS__malloc( numBins * sizeof(int32) ); | 39 hist->bins = malloc( numBins * sizeof(int32) ); |
| 43 | 40 |
| 44 hist->numBins = numBins; | 41 hist->numBins = numBins; |
| 45 hist->binWidth = (endOfRange - startOfRange) / numBins; | 42 hist->binWidth = (endOfRange - startOfRange) / numBins; |
| 46 hist->endOfRange = startOfRange + hist->binWidth * numBins; | 43 hist->endOfRange = startOfRange + hist->binWidth * numBins; |
| 47 hist->startOfRange = startOfRange; | 44 hist->startOfRange = startOfRange; |
| 73 char *name ) | 70 char *name ) |
| 74 | 71 |
| 75 { | 72 { |
| 76 Histogram *hist; | 73 Histogram *hist; |
| 77 | 74 |
| 78 hist = VMS__malloc( sizeof(Histogram) ); | 75 hist = malloc( sizeof(Histogram) ); |
| 79 hist->bins = VMS__malloc( numBins * sizeof(int32) ); | 76 hist->bins = malloc( numBins * sizeof(int32) ); |
| 80 | 77 |
| 81 makeHist_helper( hist, numBins, startOfRange, binWidth,VMS__strDup(name)); | 78 makeHist_helper( hist, numBins, startOfRange, binWidth,strDup(name)); |
| 82 | 79 |
| 83 return hist; | 80 return hist; |
| 84 } | 81 } |
| 85 | 82 |
| 86 Histogram * | 83 Histogram * |
| 87 makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth, | 84 makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth, |
| 88 char *name ) | 85 char *name ) |
| 89 | 86 |
| 90 { | 87 { |
| 91 Histogram *hist; | 88 Histogram *hist; |
| 92 | 89 |
| 347 } | 344 } |
| 348 | 345 |
| 349 void | 346 void |
| 350 freeHist( Histogram *hist ) | 347 freeHist( Histogram *hist ) |
| 351 { | 348 { |
| 352 VMS__free( hist->bins ); | |
| 353 VMS__free( hist->name ); | |
| 354 VMS__free( hist ); | |
| 355 } | |
| 356 void | |
| 357 freeHistExt( Histogram *hist ) | |
| 358 { | |
| 359 free( hist->bins ); | 349 free( hist->bins ); |
| 360 free( hist->name ); | 350 free( hist->name ); |
| 361 free( hist ); | 351 free( hist ); |
| 362 } | 352 } |
