]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
StatHist fixes
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 17 Dec 2011 08:32:53 +0000 (09:32 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 17 Dec 2011 08:32:53 +0000 (09:32 +0100)
- added protection against self-assignment
- hid copy-constructor
- de-virtualized destructor

src/StatHist.cc
src/StatHist.h

index 82a95ef7421701191cf87ae252199b523b72d8a8..1e266071de3de5001ca0ad2feb831432424f7d44 100644 (file)
@@ -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.
index bf34cf6c6a5ddbade0f22be6dd8f9c508eb7f448..76d08042bf9a55bcd834c3c7ea4f42ddb807ad91 100644 (file)
@@ -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);