------------------------------------------------------------ revno: 13270 [merge] revision-id: kinkie@squid-cache.org-20140212104326-02nuwcl3tteha46y parent: kinkie@squid-cache.org-20140211113520-sq4wpokg0i5bd0pz parent: kinkie@squid-cache.org-20140212091906-gxovffqu3p5yokrf committer: Francesco Chemolli branch nick: trunk timestamp: Wed 2014-02-12 11:43:26 +0100 message: Refactor Vector and Stack to STL counterparts ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kinkie@squid-cache.org-20140212104326-02nuwcl3tteha46y # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: cbdfafd09b86c505d287bb7fd435e58bf9f98de2 # timestamp: 2014-02-12 10:53:56 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: kinkie@squid-cache.org-20140211113520-\ # sq4wpokg0i5bd0pz # # Begin patch === modified file 'include/MemPoolMalloc.h' --- include/MemPoolMalloc.h 2012-08-28 13:00:30 +0000 +++ include/MemPoolMalloc.h 2014-02-11 11:22:39 +0000 @@ -22,6 +22,8 @@ #include "MemPool.h" +#include + /// \ingroup MemPoolsAPI class MemPoolMalloc : public MemImplementingAllocator { @@ -42,7 +44,7 @@ virtual void *allocate(); virtual void deallocate(void *, bool aggressive); private: - Stack freelist; + std::stack freelist; }; #endif /* _MEM_POOL_MALLOC_H_ */ === removed file 'include/Stack.h' --- include/Stack.h 2013-05-04 11:50:26 +0000 +++ include/Stack.h 1970-01-01 00:00:00 +0000 @@ -1,67 +0,0 @@ -/* - * AUTHOR: Alex Rousskov - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * - */ - -#ifndef SQUID_STACK_H -#define SQUID_STACK_H - -#include "base/Vector.h" - -/* RBC: 20030714 Composition might be better long-term, but for now, - * there's no reason to do so. - */ - -template - -class Stack : public Vector -{ -public: - using Vector::count; - using Vector::items; - typedef typename Vector::value_type value_type; - typedef typename Vector::pointer pointer; - value_type pop() { - if (!count) - return value_type(); - - value_type result = items[--count]; - - this->items[count] = value_type(); - - return result; - } - - /* todo, fatal on empty Top call */ - value_type top() const { - return count ? items[count - 1] : value_type(); - } -}; - -#endif /* SQUID_STACK_H */ === modified file 'include/splay.h' --- include/splay.h 2013-05-04 14:23:49 +0000 +++ include/splay.h 2014-02-11 11:22:39 +0000 @@ -3,7 +3,9 @@ #if defined(__cplusplus) -#include "Stack.h" +#include "fatal.h" + +#include template class SplayNode @@ -376,7 +378,7 @@ void advance(); void addLeftPath(SplayNode *aNode); void init(SplayNode *); - Stack *> toVisit; + std::stack *> toVisit; }; template @@ -389,7 +391,12 @@ bool SplayConstIterator::operator == (SplayConstIterator const &right) const { - return toVisit.top() == right.toVisit.top(); + if (toVisit.empty() && right.toVisit.empty()) + return true; + if (!toVisit.empty() && !right.toVisit.empty()) + return toVisit.top() == right.toVisit.top(); + // only one of the two is empty + return false; } template @@ -421,19 +428,21 @@ void SplayConstIterator::advance() { - if (toVisit.size() == 0) - return; - - toVisit.pop(); - - if (toVisit.size() == 0) - return; - - SplayNode *currentNode = toVisit.pop(); + if (toVisit.empty()) + return; + + toVisit.pop(); + + if (toVisit.empty()) + return; + + // not empty + SplayNode *currentNode = toVisit.top(); + toVisit.pop(); addLeftPath(currentNode->right); - toVisit.push_back(currentNode); + toVisit.push(currentNode); } template @@ -444,7 +453,7 @@ return; do { - toVisit.push_back(aNode); + toVisit.push(aNode); aNode = aNode->left; } while (aNode != NULL); } === modified file 'lib/MemPoolMalloc.cc' --- lib/MemPoolMalloc.cc 2014-02-02 08:57:20 +0000 +++ lib/MemPoolMalloc.cc 2014-02-11 09:57:24 +0000 @@ -51,7 +51,11 @@ void * MemPoolMalloc::allocate() { - void *obj = freelist.pop(); + void *obj = NULL; + if (!freelist.empty()) { + obj = freelist.top(); + freelist.pop(); + } if (obj) { memMeterDec(meter.idle); ++saved_calls; @@ -77,7 +81,7 @@ if (doZero) memset(obj, 0, obj_size); memMeterInc(meter.idle); - freelist.push_back(obj); + freelist.push(obj); } } @@ -133,7 +137,9 @@ void MemPoolMalloc::clean(time_t maxage) { - while (void *obj = freelist.pop()) { + while (!freelist.empty()) { + void *obj = freelist.top(); + freelist.pop(); memMeterDec(meter.idle); memMeterDec(meter.alloc); xfree(obj); === modified file 'src/DelayUser.h' --- src/DelayUser.h 2013-10-25 00:13:46 +0000 +++ src/DelayUser.h 2014-02-11 13:14:09 +0000 @@ -38,7 +38,6 @@ #include "auth/Gadgets.h" #include "auth/User.h" -#include "base/Vector.h" #include "CompositePoolNode.h" #include "DelayBucket.h" #include "DelayIdComposite.h" === modified file 'src/Generic.h' --- src/Generic.h 2012-09-01 14:38:36 +0000 +++ src/Generic.h 2014-02-11 12:05:47 +0000 @@ -60,18 +60,6 @@ return visitor; } -template -class Stack; - -template -T& for_each(Stack const &collection, T& visitor) -{ - for (size_t index = 0; index < collection.count; ++index) - visitor(*(typename T::argument_type const *)collection.items[index]); - - return visitor; -}; - /* RBC 20030718 - use this to provide instance expecting classes a pointer to a * singleton */ === modified file 'src/HttpHeader.cc' --- src/HttpHeader.cc 2014-02-10 15:07:49 +0000 +++ src/HttpHeader.cc 2014-02-12 08:51:26 +0000 @@ -52,6 +52,10 @@ #include +/* XXX: the whole set of API managing the entries vector should be rethought + * after the parse4r-ng effort is complete. + */ + /* * On naming conventions: * @@ -437,8 +441,6 @@ void HttpHeader::clean() { - HttpHeaderPos pos = HttpHeaderInitPos; - HttpHeaderEntry *e; assert(owner > hoNone && owner < hoEnd); debugs(55, 7, "cleaning hdr: " << this << " owner: " << owner); @@ -464,18 +466,19 @@ HttpHeaderStats[owner].busyDestroyedCount += entries.size() > 0; } // if (owner <= hoReply) - while ((e = getEntry(&pos))) { - /* tmp hack to try to avoid coredumps */ - + for (std::vector::iterator i = entries.begin(); i != entries.end(); ++i) { + HttpHeaderEntry *e = *i; + if (e == NULL) + continue; if (e->id < 0 || e->id >= HDR_ENUM_END) { - debugs(55, DBG_CRITICAL, "HttpHeader::clean BUG: entry[" << pos << "] is invalid (" << e->id << "). Ignored."); + debugs(55, DBG_CRITICAL, "BUG: invalid entry (" << e->id << "). Ignored."); } else { if (owner <= hoReply) HttpHeaderStats[owner].fieldTypeDistr.count(e->id); - /* yes, this deletion leaves us in an inconsistent state */ delete e; } } + entries.clear(); httpHeaderMaskInit(&mask, 0); len = 0; === modified file 'src/Makefile.am' --- src/Makefile.am 2014-02-07 13:45:20 +0000 +++ src/Makefile.am 2014-02-11 13:14:09 +0000 @@ -1077,8 +1077,7 @@ tests/testSBuf \ tests/testSBufList \ tests/testConfigParser \ - tests/testStatHist \ - tests/testVector + tests/testStatHist if HAVE_FS_ROCK check_PROGRAMS += tests/testRock @@ -3826,21 +3825,6 @@ $(COMPAT_LIB) tests_testStatHist_DEPENDENCIES = $(SQUID_CPPUNIT_LA) -tests_testVector_SOURCES = \ - tests/testVector.cc \ - tests/testMain.cc \ - tests/testVector.h -nodist_tests_testVector_SOURCES = \ - $(TESTSOURCES) -tests_testVector_LDADD= \ - $(SQUID_CPPUNIT_LIBS) \ - $(COMPAT_LIB) \ - $(XTRA_LIBS) -tests_testVector_LDFLAGS = $(LIBADD_DL) -tests_testVector_DEPENDENCIES = \ - $(SQUID_CPPUNIT_LA) - - TESTS += testHeaders ## Special Universal .h dependency test script === modified file 'src/base/Makefile.am' --- src/base/Makefile.am 2014-01-01 17:15:10 +0000 +++ src/base/Makefile.am 2014-02-11 13:14:09 +0000 @@ -23,9 +23,7 @@ RunnersRegistry.h \ Subscription.h \ TextException.cc \ - TextException.h \ - Vector.cc \ - Vector.h + TextException.h EXTRA_PROGRAMS = \ testCharacterSet === removed file 'src/base/Vector.cc' --- src/base/Vector.cc 2013-05-04 11:50:26 +0000 +++ src/base/Vector.cc 1970-01-01 00:00:00 +0000 @@ -1,48 +0,0 @@ -/* - * AUTHOR: Alex Rousskov - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * - */ - -/* - * Array is an array of (void*) items with unlimited capacity - * - * Array grows when arrayAppend() is called and no space is left - * Currently, array does not have an interface for deleting an item because - * we do not need such an interface yet. - */ - -#include "squid.h" -#include "base/Vector.h" - -#if HAVE_ASSERT_H -#include -#endif -#if HAVE_STRING_H -#include -#endif === removed file 'src/base/Vector.h' --- src/base/Vector.h 2014-02-10 17:52:49 +0000 +++ src/base/Vector.h 1970-01-01 00:00:00 +0000 @@ -1,471 +0,0 @@ -/* - * AUTHOR: Alex Rousskov - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * - */ -#ifndef SQUID_ARRAY_H -#define SQUID_ARRAY_H - -/** - \todo remove this after replacing with STL - */ - -#include "fatal.h" -#include "util.h" - -/* users of this template also need assert() */ -#include "compat/assert.h" - -/* iterator support */ -#include - -template -class VectorIteratorBase -{ -public: - typedef typename C::value_type value_type; - typedef std::forward_iterator_tag iterator_category; - typedef typename C::pointer pointer; - typedef typename C::reference reference; - typedef typename C::difference_type difference_type; - - VectorIteratorBase(); - VectorIteratorBase(C &); - VectorIteratorBase(size_t, C &); - VectorIteratorBase & operator =(VectorIteratorBase const &); - bool operator != (VectorIteratorBase const &rhs) const; - bool operator == (VectorIteratorBase const &rhs) const; - VectorIteratorBase & operator ++(); - VectorIteratorBase operator ++(int); - typename C::value_type & operator *() const { - return theVector->items[pos]; - } - - typename C::value_type * operator -> () const { - return &theVector->items[pos]; - } - - ssize_t operator - (VectorIteratorBase const &rhs) const; - bool incrementable() const; - -private: - size_t pos; - C * theVector; -}; - -template -class Vector -{ -public: - typedef E value_type; - typedef E* pointer; - typedef E& reference; - typedef VectorIteratorBase > iterator; - typedef VectorIteratorBase const> const_iterator; - typedef ptrdiff_t difference_type; - friend class VectorIteratorBase >; - friend class VectorIteratorBase const>; - void *operator new (size_t); - void operator delete (void *); - - Vector(); - ~Vector(); - Vector(Vector const &); - Vector &operator = (Vector const &); - void clear(); - void reserve (size_t capacity); - void push_back (E); - - void insert (E); - const E &front() const; - E &front(); - E &back(); - void pop_back(); - E shift(); // aka pop_front - void prune(E); - void preAppend(int app_count); - inline bool empty() const; - inline size_t size() const; - iterator begin(); - const_iterator begin () const; - iterator end(); - const_iterator end () const; - E& at(unsigned i); - const E& at(unsigned i) const; - inline E& operator [] (unsigned i); - inline const E& operator [] (unsigned i) const; - E* data() const { return items; } - -protected: - size_t capacity; - size_t count; - E *items; -}; - -template -void * -Vector::operator new(size_t size) -{ - return xmalloc(size); -} - -template -void -Vector::operator delete (void *address) -{ - xfree (address); -} - -template -Vector::Vector() : capacity (0), count(0), items (NULL) -{} - -template -Vector::~Vector() -{ - clear(); -} - -template -void -Vector::clear() -{ - /* could also warn if some objects are left */ - delete[] items; - items = NULL; - capacity = 0; - count = 0; -} - -/* grows internal buffer to satisfy required minimal capacity */ -template -void -Vector::reserve(size_t min_capacity) -{ - const int min_delta = 16; - int delta; - - if (capacity >= min_capacity) - return; - - delta = min_capacity; - - /* make delta a multiple of min_delta */ - delta += min_delta - 1; - - delta /= min_delta; - - delta *= min_delta; - - /* actual grow */ - if (delta < 0) - delta = min_capacity - capacity; - - E*newitems = new E[capacity + delta]; - - for (size_t counter = 0; counter < size(); ++counter) { - newitems[counter] = items[counter]; - } - - capacity += delta; - delete[]items; - items = newitems; -} - -template -void -Vector::push_back(E obj) -{ - if (size() >= capacity) - reserve (size() + 1); - - items[count++] = obj; -} - -template -void -Vector::insert(E obj) -{ - if (size() >= capacity) - reserve (size() + 1); - - int i; - - for (i = count; i > 0; i--) - items[i] = items[i - 1]; - - items[i] = obj; - - count += 1; -} - -template -E -Vector::shift() -{ - assert (size()); - value_type result = items[0]; - - for (unsigned int i = 1; i < count; i++) - items[i-1] = items[i]; - - count--; - - /*reset the last (unused) element...*/ - items[count] = value_type(); - - return result; -} - -template -void -Vector::pop_back() -{ - assert (size()); - --count; - items[count] = value_type(); -} - -template -E & -Vector::back() -{ - assert (size()); - return items[size() - 1]; -} - -template -const E & -Vector::front() const -{ - assert (size()); - return items[0]; -} - -template -E & -Vector::front() -{ - assert (size()); - return items[0]; -} - -template -void -Vector::prune(E item) -{ - unsigned int n = 0; - for (unsigned int i = 0; i < count; i++) { - if (items[i] != item) { - if (i != n) - items[n] = items[i]; - n++; - } - } - - count = n; -} - -/* if you are going to append a known and large number of items, call this first */ -template -void -Vector::preAppend(int app_count) -{ - if (size() + app_count > capacity) - reserve(size() + app_count); -} - -template -Vector::Vector (Vector const &rhs) -{ - items = NULL; - capacity = 0; - count = 0; - reserve (rhs.size()); - - for (size_t counter = 0; counter < rhs.size(); ++counter) - push_back (rhs.items[counter]); -} - -template -Vector & -Vector::operator = (Vector const &old) -{ - clear(); - reserve (old.size()); - - for (size_t counter = 0; counter < old.size(); ++counter) - push_back (old.items[counter]); - - return *this; -} - -template -bool -Vector::empty() const -{ - return size() == 0; -} - -template -size_t -Vector::size() const -{ - return count; -} - -template -typename Vector::iterator -Vector::begin() -{ - return iterator (0, *this); -} - -template -typename Vector::iterator -Vector::end() -{ - return iterator(size(), *this); -} - -template -typename Vector::const_iterator -Vector::begin() const -{ - return const_iterator (0, *this); -} - -template -typename Vector::const_iterator -Vector::end() const -{ - return const_iterator(size(), *this); -} - -template -E & -Vector::at(unsigned i) -{ - assert (size() > i); - return operator[](i); -} - -template -const E & -Vector::at(unsigned i) const -{ - assert (size() > i); - return operator[](i); -} - -template -E & -Vector::operator [] (unsigned i) -{ - return items[i]; -} - -template -const E & -Vector::operator [] (unsigned i) const -{ - return items[i]; -} - -template -VectorIteratorBase::VectorIteratorBase() : pos(0), theVector(NULL) -{} - -template -VectorIteratorBase::VectorIteratorBase(C &container) : pos(container.begin()), theVector(&container) -{} - -template -VectorIteratorBase::VectorIteratorBase(size_t aPos, C &container) : pos(aPos), theVector(&container) {} - -template -bool VectorIteratorBase:: operator != (VectorIteratorBase const &rhs) const -{ - assert (theVector); - return pos != rhs.pos; -} - -template -bool VectorIteratorBase:: operator == (VectorIteratorBase const &rhs) const -{ - assert (theVector); - return pos == rhs.pos; -} - -template -bool -VectorIteratorBase::incrementable() const -{ - assert (theVector); - return pos != theVector->size(); -} - -template -VectorIteratorBase & VectorIteratorBase:: operator ++() -{ - assert (theVector); - - if (!incrementable()) - fatal ("domain error"); - - ++pos; - - return *this; -} - -template -VectorIteratorBase VectorIteratorBase:: operator ++(int) -{ - VectorIteratorBase result(*this); - ++*this; - return result; -} - -template -VectorIteratorBase& -VectorIteratorBase::operator =(VectorIteratorBase const &old) -{ - pos = old.pos; - theVector = old.theVector; - return *this; -} - -template -ssize_t -VectorIteratorBase::operator - (VectorIteratorBase const &rhs) const -{ - assert(theVector == rhs.theVector); - return pos - rhs.pos; -} - -#endif /* SQUID_ARRAY_H */ === modified file 'src/cbdata.cc' --- src/cbdata.cc 2012-09-01 14:38:36 +0000 +++ src/cbdata.cc 2014-02-11 12:02:07 +0000 @@ -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 @@ -124,7 +125,7 @@ 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 */ @@ -209,10 +210,11 @@ cbdata::~cbdata() { #if USE_CBDATA_DEBUG - CBDataCall *aCall; - while ((aCall = calls.pop())) - delete aCall; + while (!calls.empty()) { + delete calls.back(); + calls.pop_back(); + } #endif @@ -316,7 +318,7 @@ 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); @@ -614,8 +616,8 @@ 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; @@ -628,7 +630,7 @@ 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"); } === modified file 'src/store.cc' --- src/store.cc 2014-02-02 08:57:20 +0000 +++ src/store.cc 2014-02-12 09:19:06 +0000 @@ -51,7 +51,6 @@ #include "RequestFlags.h" #include "SquidConfig.h" #include "SquidTime.h" -#include "Stack.h" #include "StatCounters.h" #include "stmem.h" #include "Store.h" @@ -74,6 +73,8 @@ #include #endif +#include + #define REBUILD_TIMESTAMP_DELTA_MAX 2 #define STORE_IN_MEM_BUCKETS (229) @@ -125,7 +126,7 @@ /* * local variables */ -static Stack LateReleaseStack; +static std::stack LateReleaseStack; MemAllocator *StoreEntry::pool = NULL; StorePointer Store::CurrentRoot = NULL; @@ -1253,7 +1254,7 @@ // lock the entry until rebuilding is done lock("storeLateRelease"); setReleaseFlag(); - LateReleaseStack.push_back(this); + LateReleaseStack.push(this); } else { destroyStoreEntry(static_cast(this)); // "this" is no longer valid @@ -1281,7 +1282,6 @@ storeLateRelease(void *unused) { StoreEntry *e; - int i; static int n = 0; if (StoreController::store_dirs_rebuilding) { @@ -1289,13 +1289,14 @@ return; } - for (i = 0; i < 10; ++i) { - e = LateReleaseStack.empty() ? NULL : LateReleaseStack.pop(); - - if (e == NULL) { - /* done! */ + // TODO: this works but looks unelegant. + for (int i = 0; i < 10; ++i) { + if (LateReleaseStack.empty()) { debugs(20, DBG_IMPORTANT, "storeLateRelease: released " << n << " objects"); return; + } else { + e = LateReleaseStack.top(); + LateReleaseStack.pop(); } e->unlock("storeLateRelease"); === removed file 'src/tests/testVector.cc' --- src/tests/testVector.cc 2013-11-18 17:03:55 +0000 +++ src/tests/testVector.cc 1970-01-01 00:00:00 +0000 @@ -1,19 +0,0 @@ -#define SQUID_UNIT_TEST 1 -#include "squid.h" -#include "base/Vector.h" -#include "tests/testVector.h" - -#include - -CPPUNIT_TEST_SUITE_REGISTRATION( testVector ); - -void testVector::all() -{ - CPPUNIT_ASSERT_EQUAL(1 , 1); - Vector aArray; - CPPUNIT_ASSERT_EQUAL(static_cast(0), aArray.size()); - aArray.push_back(2); - CPPUNIT_ASSERT_EQUAL(static_cast(1), aArray.size()); - CPPUNIT_ASSERT_EQUAL(2, aArray.back()); - CPPUNIT_ASSERT_EQUAL(static_cast(1), aArray.size()); -} === removed file 'src/tests/testVector.h' --- src/tests/testVector.h 2013-05-04 11:50:26 +0000 +++ src/tests/testVector.h 1970-01-01 00:00:00 +0000 @@ -1,24 +0,0 @@ -#ifndef SQUID_SRC_TESTS_TESTVECTOR_H -#define SQUID_SRC_TESTS_TESTVECTOR_H - -#include - -/* - * A test case that is designed to produce - * example errors and failures - * - */ - -class testVector : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( testVector ); - CPPUNIT_TEST( all ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void all(); -}; - -#endif === modified file 'test-suite/Makefile.am' --- test-suite/Makefile.am 2013-10-02 09:06:03 +0000 +++ test-suite/Makefile.am 2014-02-11 13:14:09 +0000 @@ -31,7 +31,6 @@ TESTS += debug \ syntheticoperators \ VirtualDeleteOperator \ - StackTest \ splay\ MemPoolTest\ mem_node_test\ @@ -46,7 +45,6 @@ mem_node_test\ mem_hdr_test \ splay \ - StackTest \ syntheticoperators \ VirtualDeleteOperator @@ -89,8 +87,6 @@ splay_SOURCES = splay.cc -StackTest_SOURCES = StackTest.cc $(DEBUG_SOURCE) - syntheticoperators_SOURCES = syntheticoperators.cc $(DEBUG_SOURCE) VirtualDeleteOperator_SOURCES = VirtualDeleteOperator.cc $(DEBUG_SOURCE) === removed file 'test-suite/StackTest.cc' --- test-suite/StackTest.cc 2012-09-01 14:38:36 +0000 +++ test-suite/StackTest.cc 1970-01-01 00:00:00 +0000 @@ -1,56 +0,0 @@ - -/* - * DEBUG: section 19 Store Memory Primitives - * AUTHOR: Robert Collins - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * - * Copyright (c) 2003 Robert Collins - */ - -#include "squid.h" -#include "Stack.h" - -int -main(int argc, char **argv) -{ - Stack aStack; - assert (aStack.size() == 0); - aStack.push_back(2); - assert (aStack.size() == 1); - assert (aStack.top() == 2); - assert (aStack.pop() == 2); - assert (aStack.size() == 0); - Stack<> oldStack; - assert (oldStack.size() == 0); - oldStack.push_back(&aStack); - assert (oldStack.size() == 1); - assert (oldStack.top() == &aStack); - assert (oldStack.pop() == &aStack); - assert (oldStack.size() == 0); - return 0; -}