From: Francesco Chemolli Date: Sat, 17 Dec 2011 08:32:53 +0000 (+0100) Subject: StatHist fixes X-Git-Tag: BumpSslServerFirst.take05~12^2~116 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f563056cb633cde12fb542ab7a7d75664b07205;p=thirdparty%2Fsquid.git StatHist fixes - added protection against self-assignment - hid copy-constructor - de-virtualized destructor --- diff --git a/src/StatHist.cc b/src/StatHist.cc index 82a95ef742..1e266071de 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -87,6 +87,8 @@ StatHist::~StatHist() StatHist& StatHist::operator =(const StatHist & src) { + if (this==&src) //handle self-assignment + return *this; assert(src.bins != NULL); // TODO: remove after initializing bins at construction time if (capacity_ != src.capacity_) { // need to resize. diff --git a/src/StatHist.h b/src/StatHist.h index bf34cf6c6a..76d08042bf 100644 --- a/src/StatHist.h +++ b/src/StatHist.h @@ -1,6 +1,4 @@ /* - * AUTHOR: Francesco Chemolli - * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- * @@ -57,10 +55,9 @@ public: * \todo specialize the class in a small hierarchy so that all * relevant initializations are done at build-time */ - StatHist() : scale_(1.0) {}; - StatHist(const StatHist&); + StatHist() : scale_(1.0) {} StatHist &operator=(const StatHist &); - virtual ~StatHist(); + ~StatHist(); /** clear the contents of the histograms * * \todo remove: this function has been replaced in its purpose @@ -118,6 +115,8 @@ 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);