From: Timo Teras Date: Sat, 12 May 2012 03:48:02 +0000 (-0600) Subject: Bug 3537: statistics histogram leaks memory X-Git-Tag: BumpSslServerFirst.take08~7^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1bcd7daff67e41100cce0933da0f095728e911e;p=thirdparty%2Fsquid.git Bug 3537: statistics histogram leaks memory --- diff --git a/src/StatHist.cc b/src/StatHist.cc index 9e5d0ddcc1..422ea742ce 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -62,8 +62,9 @@ StatHist::init(unsigned int newCapacity, hbase_f * val_in_, hbase_f * val_out_, void StatHist::clear() { - for (unsigned int i=0; i(xcalloc(src.capacity_, sizeof(int))); + bins = static_cast(xcalloc(src.capacity_, sizeof(bins_type))); memcpy(bins,src.bins,capacity_*sizeof(*bins)); } } diff --git a/src/StatHist.h b/src/StatHist.h index 576525d21a..b422ce7ba7 100644 --- a/src/StatHist.h +++ b/src/StatHist.h @@ -57,7 +57,7 @@ public: */ StatHist(); StatHist(const StatHist&); //not needed - ~StatHist(); + ~StatHist() { clear(); }; typedef uint64_t bins_type; @@ -148,12 +148,4 @@ StatHist::StatHist() : scale_(1.0), val_in(NULL), val_out(NULL) {} -inline -StatHist::~StatHist() -{ - xfree(bins); //can handle case of bins being NULL - bins=NULL; - capacity_=0; //mark as destructed, may be needed for troubleshooting -} - #endif /* STATHIST_H_ */