From: Francesco Chemolli Date: Sat, 17 Dec 2011 21:23:14 +0000 (+0100) Subject: Implemented and made public StatHist copy-constructor X-Git-Tag: BumpSslServerFirst.take05~12^2~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=978901be03f2fc9f22a49879f86216742881788d;p=thirdparty%2Fsquid.git Implemented and made public StatHist copy-constructor --- diff --git a/src/StatHist.cc b/src/StatHist.cc index 1e266071de..6831c390f5 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -106,6 +106,16 @@ StatHist::operator =(const StatHist & src) return *this; } +StatHist::StatHist(const StatHist &src) : + capacity_(src.capacity_), min_(src.min_), max_(src.max_), + scale_(src.scale_), val_in(src.val_in), val_out(src.val_out) +{ + if(src.bins!=NULL) { + bins = static_cast(xcalloc(src.capacity_, sizeof(int))); + memcpy(bins,src.bins,capacity_*sizeof(*bins)); + } +} + void StatHist::count(double val) { diff --git a/src/StatHist.h b/src/StatHist.h index 76d08042bf..dcd4e68714 100644 --- a/src/StatHist.h +++ b/src/StatHist.h @@ -56,8 +56,10 @@ public: * relevant initializations are done at build-time */ StatHist() : scale_(1.0) {} - StatHist &operator=(const StatHist &); + StatHist(const StatHist&); //not needed ~StatHist(); + + StatHist &operator=(const StatHist &); /** clear the contents of the histograms * * \todo remove: this function has been replaced in its purpose @@ -81,11 +83,9 @@ public: */ void dump(StoreEntry *sentry, StatHistBinDumper * bd) const; /** Initialize the Histogram using a logarithmic values distribution - * */ void logInit(int capacity, double min, double max); /** initialize the histogram to count occurrences in an enum-represented set - * */ void enumInit(int last_enum); protected: @@ -115,8 +115,6 @@ protected: double scale_; hbase_f *val_in; /* e.g., log() for log-based histogram */ hbase_f *val_out; /* e.g., exp() for log based histogram */ -private: - StatHist(const StatHist&); //not needed }; double statHistDeltaMedian(const StatHist & A, const StatHist & B);