#include "cbdata.h"
#include "mgr/Registration.h"
#include "Store.h"
+#if USE_CBDATA_DEBUG
+#include "Stack.h"
+#endif
#include "Generic.h"
#include <climits>
-#if USE_CBDATA_DEBUG
-#include <algorithm>
-#include <vector>
-#endif
#if WITH_VALGRIND
#define HASHED_CBDATA 1
dlink_node link;
const char *file;
int line;
- std::vector<CBDataCall*> calls; // used as a stack with random access operator
+ Stack<CBDataCall*> calls;
#endif
/* cookie used while debugging */
cbdata::~cbdata()
{
#if USE_CBDATA_DEBUG
+ CBDataCall *aCall;
- while (!calls.empty()) {
- delete calls.back();
- calls.pop_back();
- }
+ while ((aCall = calls.pop()))
+ delete aCall;
#endif
c->file = file;
c->line = line;
- c->calls = std::vector<CBDataCall *> ();
+ c->calls = Stack<CBDataCall *> ();
c->addHistory("Alloc", file, line);
dlinkAdd(c, &c->link, &cbdataEntries);
debugs(45, 3, "cbdataAlloc: " << p << " " << file << ":" << line);
struct CBDataCallDumper : public unary_function<CBDataCall, void> {
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;
CBDataDumper::operator()(x);
storeAppendPrintf(where, "\n");
storeAppendPrintf(where, "Action\tFile\tLine\n");
- std::for_each (x.calls.begin(), x.calls.end(), callDumper);
+ for_each (x.calls,callDumper);
storeAppendPrintf(where, "\n");
}