]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Implemented and made public StatHist copy-constructor
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 17 Dec 2011 21:23:14 +0000 (22:23 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 17 Dec 2011 21:23:14 +0000 (22:23 +0100)
src/StatHist.cc
src/StatHist.h

index 1e266071de3de5001ca0ad2feb831432424f7d44..6831c390f538734903e3d7d18eec46a9c3122e6b 100644 (file)
@@ -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<int *>(xcalloc(src.capacity_, sizeof(int)));
+        memcpy(bins,src.bins,capacity_*sizeof(*bins));
+    }
+}
+
 void
 StatHist::count(double val)
 {
index 76d08042bf9a55bcd834c3c7ea4f42ddb807ad91..dcd4e687140a3572c2c5a8d882f6bffb19da6e2a 100644 (file)
@@ -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);