]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Implemented proper distructor for StatHist
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 13 Dec 2011 18:24:47 +0000 (19:24 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 13 Dec 2011 18:24:47 +0000 (19:24 +0100)
Started to add some documentation for StatHist.
Removed includes of config.h from header files.

src/StatCounters.h
src/StatHist.cc
src/StatHist.h

index 4e57e709556e58ee42f564f39fa6e10410d85525..c5f64f79336a9cacc07193ffc04f36e17cff6a14 100644 (file)
@@ -31,8 +31,6 @@
 #ifndef STATCOUNTERS_H_
 #define STATCOUNTERS_H_
 
-#include "config.h"
-
 #include "StatHist.h"
 
 #if USE_CACHE_DIGESTS
index 7dd385e8cba8dca81cd330de080624472c76e8cb..c857de3b73ff623ce178c16156c3ba0e6592da69 100644 (file)
@@ -87,8 +87,16 @@ StatHist::init(int capacity_, hbase_f * val_in_, hbase_f * val_out_, double min_
 void
 StatHist::clear()
 {
-    xfree(bins);
-    bins = NULL;
+    for(int i=0;i<capacity;++i)
+        bins[i]=0;
+}
+
+StatHist::~StatHist()
+{
+    if (bins != NULL) {
+        xfree(bins);
+        bins = NULL;
+    }
 }
 
 /* assumes that somebody already called init for Dest */
@@ -288,3 +296,4 @@ statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int cou
     if (count)
         storeAppendPrintf(sentry, "%9d\t%9d\n", (int) val, count);
 }
+
index 3ff4bfd92603dcbc7dce6315f89068298d96ed5e..edbbbf67eeb060abe7ee4246821113d6fc829859 100644 (file)
 
 #include "typedefs.h"
 
-/*
- * "very generic" histogram;
+/** Generic histogram class
+ *
  * see important comments on hbase_f restrictions in StatHist.c
  */
-
 class StatHist {
 public:
+    /** Default constructor
+     *
+     * \note the default constructor doesn't fully initialize.
+     *       you have to call one of the *init functions to specialize the
+     *       histogram
+     * \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 &operator=(const StatHist &);
+    virtual ~StatHist();
+    /**
+     *
+     */
     void clear();
     double deltaPctile(const StatHist &B, double pctile) const;
-    double val(int bin) const; //todo: make private
+    double val(int bin) const;
     void count(double val);
-    StatHist &operator=(const StatHist &);
-    StatHist() : scale(1.0) {};
-    StatHist(const StatHist&);
     void dump(StoreEntry *sentry, StatHistBinDumper * bd) const;
     void logInit(int capacity, double min, double max);
     void enumInit(int last_enum);
@@ -67,7 +78,6 @@ protected:
 void statHistCount(StatHist * H, double val);
 double statHistDeltaMedian(const StatHist & A, const StatHist & B);
 double statHistDeltaPctile(const StatHist & A, const StatHist & B, double pctile);
-//void statHistIntInit(StatHist * H, int n);
 StatHistBinDumper statHistEnumDumper;
 StatHistBinDumper statHistIntDumper;