comparison Histogram.c @ 34:8166ea441cb5

changed headers and PR_int__malloc to PR__malloc
author Sean Halle <seanhalle@yahoo.com>
date Tue, 23 Jul 2013 07:32:47 -0700
parents 84601ecae690
children eb23eeae4198
comparison
equal deleted inserted replaced
22:0ec254b6651e 24:49e58ff41a6a
6 * 6 *
7 */ 7 */
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <string.h> 9 #include <string.h>
10 #include "Histogram.h" 10 #include "Histogram.h"
11 11 #include "PR__common_includes/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h"
12 12
13 /*This Histogram Abstract Data Type has a number of bins plus a range of 13 /*This Histogram Abstract Data Type has a number of bins plus a range of
14 * values that the bins span, both chosen at creation. 14 * values that the bins span, both chosen at creation.
15 * 15 *
16 *One creates a Histogram instance using the makeHistogram function, then 16 *One creates a Histogram instance using the makeHistogram function, then
27 { 27 {
28 Histogram *hist; 28 Histogram *hist;
29 int32 i; 29 int32 i;
30 30
31 31
32 hist = PR_int__malloc( sizeof(Histogram) ); 32 hist = PR__malloc( sizeof(Histogram) );
33 hist->bins = PR_int__malloc( numBins * sizeof(int32) ); 33 hist->bins = PR__malloc( numBins * sizeof(int32) );
34 34
35 hist->numBins = numBins; 35 hist->numBins = numBins;
36 hist->binWidth = (endOfRange - startOfRange) / numBins; 36 hist->binWidth = (endOfRange - startOfRange) / numBins;
37 hist->endOfRange = startOfRange + hist->binWidth * numBins; 37 hist->endOfRange = startOfRange + hist->binWidth * numBins;
38 hist->startOfRange = startOfRange; 38 hist->startOfRange = startOfRange;
64 char *name ) 64 char *name )
65 65
66 { 66 {
67 Histogram *hist; 67 Histogram *hist;
68 68
69 hist = PR_int__malloc( sizeof(Histogram) ); 69 hist = PR__malloc( sizeof(Histogram) );
70 hist->bins = PR_int__malloc( numBins * sizeof(int32) ); 70 hist->bins = PR__malloc( numBins * sizeof(int32) );
71 71
72 char *nameCopy = (char *)PR_int__strDup(name); 72 char *nameCopy = (char *)PR_int__strDup(name);
73 makeHist_helper( hist, numBins, startOfRange, binWidth, nameCopy); 73 makeHist_helper( hist, numBins, startOfRange, binWidth, nameCopy);
74 74
75 return hist; 75 return hist;
296 } 296 }
297 297
298 void 298 void
299 freeHist( Histogram *hist ) 299 freeHist( Histogram *hist )
300 { 300 {
301 PR_int__free( hist->bins ); 301 PR__free( hist->bins );
302 PR_int__free( hist->name ); 302 PR__free( hist->name );
303 PR_int__free( hist ); 303 PR__free( hist );
304 } 304 }
305 void 305 void
306 freeHistExt( Histogram *hist ) 306 freeHistExt( Histogram *hist )
307 { 307 {
308 free( hist->bins ); 308 free( hist->bins );