From: Francesco Chemolli Date: Tue, 11 Feb 2014 12:02:07 +0000 (+0100) Subject: Reworked cbdata to use std::vector to be able to have a random access iterator X-Git-Tag: SQUID_3_5_0_1~375^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85b067e359c24a0f643b44293992829ca7a1eb44;p=thirdparty%2Fsquid.git Reworked cbdata to use std::vector to be able to have a random access iterator --- diff --git a/src/cbdata.cc b/src/cbdata.cc index 74e1724483..d9c8d8353b 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -50,14 +50,15 @@ #include "cbdata.h" #include "mgr/Registration.h" #include "Store.h" -#if USE_CBDATA_DEBUG -#include "Stack.h" -#endif #include "Generic.h" #if HAVE_LIMITS_H #include #endif +#if USE_CBDATA_DEBUG +#include +#include +#endif #if WITH_VALGRIND #define HASHED_CBDATA 1 @@ -118,13 +119,13 @@ public: if (calls.size() > 1000) return; - calls.push(new CBDataCall(label, aFile, aLine)); + calls.push_back(new CBDataCall(label, aFile, aLine)); } dlink_node link; const char *file; int line; - Stack calls; + std::vector calls; // used as a stack with random access operator #endif /* cookie used while debugging */ @@ -211,8 +212,8 @@ cbdata::~cbdata() #if USE_CBDATA_DEBUG while (!calls.empty()) { - delete calls.top(); - calls.pop(); + delete calls.back(); + calls.pop_back(); } #endif @@ -317,7 +318,7 @@ cbdataInternalAlloc(cbdata_type type) c->file = file; c->line = line; - c->calls = Stack (); + c->calls = std::vector (); c->addHistory("Alloc", file, line); dlinkAdd(c, &c->link, &cbdataEntries); debugs(45, 3, "cbdataAlloc: " << p << " " << file << ":" << line); @@ -615,8 +616,8 @@ CBDATA_CLASS_INIT(generic_cbdata); struct CBDataCallDumper : public unary_function { CBDataCallDumper (StoreEntry *anEntry):where(anEntry) {} - void operator()(CBDataCall const &x) { - storeAppendPrintf(where, "%s\t%s\t%d\n", x.label, x.file, x.line); + void operator()(CBDataCall * const &x) { + storeAppendPrintf(where, "%s\t%s\t%d\n", x->label, x->file, x->line); } StoreEntry *where; @@ -629,7 +630,7 @@ struct CBDataHistoryDumper : public CBDataDumper { CBDataDumper::operator()(x); storeAppendPrintf(where, "\n"); storeAppendPrintf(where, "Action\tFile\tLine\n"); - for_each (x.calls,callDumper); + std::for_each (x.calls.begin(), x.calls.end(), callDumper); storeAppendPrintf(where, "\n"); }