=== modified file 'include/MemPoolMalloc.h' --- include/MemPoolMalloc.h 2012-08-28 13:00:30 +0000 +++ include/MemPoolMalloc.h 2014-02-11 11:44:50 +0000 @@ -1,48 +1,50 @@ #ifndef _MEM_POOL_MALLOC_H_ #define _MEM_POOL_MALLOC_H_ /** \defgroup MemPoolsAPI Memory Management (Memory Pool Allocator) \ingroup Components * *\par * MemPools are a pooled memory allocator running on top of malloc(). It's * purpose is to reduce memory fragmentation and provide detailed statistics * on memory consumption. * \par * Preferably all memory allocations in Squid should be done using MemPools * or one of the types built on top of it (i.e. cbdata). * \note Usually it is better to use cbdata types as these gives you additional * safeguards in references and typechecking. However, for high usage pools where * the cbdata functionality of cbdata is not required directly using a MemPool * might be the way to go. */ #include "MemPool.h" +#include + /// \ingroup MemPoolsAPI class MemPoolMalloc : public MemImplementingAllocator { public: MemPoolMalloc(char const *label, size_t aSize); ~MemPoolMalloc(); virtual bool idleTrigger(int shift) const; virtual void clean(time_t maxage); /** \param stats Object to be filled with statistical data about pool. \retval Number of objects in use, ie. allocated. */ virtual int getStats(MemPoolStats * stats, int accumulate); virtual int getInUseCount(); protected: 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:44:50 +0000 @@ -1,36 +1,38 @@ #ifndef SQUID_SPLAY_H #define SQUID_SPLAY_H #if defined(__cplusplus) -#include "Stack.h" +#include "fatal.h" + +#include template class SplayNode { public: typedef V Value; typedef int SPLAYCMP(Value const &a, Value const &b); typedef void SPLAYFREE(Value &); typedef void SPLAYWALKEE(Value const & nodedata, void *state); static void DefaultFree (Value &aValue) {delete aValue;} SplayNode (Value const &); Value data; mutable SplayNode *left; mutable SplayNode *right; void destroy(SPLAYFREE *); void walk(SPLAYWALKEE *, void *callerState); bool empty() const { return this == NULL; } SplayNode const * start() const; SplayNode const * finish() const; SplayNode * remove(const Value data, SPLAYCMP * compare); SplayNode * insert(Value data, SPLAYCMP * compare); template SplayNode * splay(const FindValue &data, int( * compare)(FindValue const &a, Value const &b)) const; }; typedef SplayNode splayNode; @@ -349,125 +351,132 @@ Splay::size() const template const SplayConstIterator Splay::begin() const { return const_iterator(head); } template const SplayConstIterator Splay::end() const { return const_iterator(NULL); } template class SplayConstIterator { public: typedef const V value_type; SplayConstIterator (SplayNode *aNode); bool operator == (SplayConstIterator const &right) const; SplayConstIterator operator ++ (int dummy); SplayConstIterator &operator ++ (); V const & operator * () const; private: void advance(); void addLeftPath(SplayNode *aNode); void init(SplayNode *); - Stack *> toVisit; + std::stack *> toVisit; }; template SplayConstIterator::SplayConstIterator (SplayNode *aNode) { init(aNode); } template 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 SplayConstIterator & SplayConstIterator::operator ++ () { advance(); return *this; } template SplayConstIterator SplayConstIterator::operator ++ (int dummy) { SplayConstIterator result = *this; advance(); return result; } /* advance is simple enough: * if the stack is empty, we're done. * otherwise, pop the last visited node * then, pop the next node to visit * if that has a right child, add it and it's * left-to-end path. * then add the node back. */ template void SplayConstIterator::advance() { - if (toVisit.size() == 0) + if (toVisit.empty()) return; toVisit.pop(); - if (toVisit.size() == 0) + if (toVisit.empty()) return; - SplayNode *currentNode = toVisit.pop(); + // not empty + SplayNode *currentNode = toVisit.top(); + toVisit.pop(); addLeftPath(currentNode->right); - toVisit.push_back(currentNode); + toVisit.push(currentNode); } template void SplayConstIterator::addLeftPath(SplayNode *aNode) { if (aNode == NULL) return; do { - toVisit.push_back(aNode); + toVisit.push(aNode); aNode = aNode->left; } while (aNode != NULL); } template void SplayConstIterator::init(SplayNode *head) { addLeftPath(head); } template V const & SplayConstIterator::operator * () const { /* can't dereference when past the end */ if (toVisit.size() == 0) fatal ("Attempt to dereference SplayConstIterator past-the-end\n"); return toVisit.top()->data; } #endif /* cplusplus */ #endif /* SQUID_SPLAY_H */ === modified file 'lib/MemPoolMalloc.cc' --- lib/MemPoolMalloc.cc 2014-02-02 08:57:20 +0000 +++ lib/MemPoolMalloc.cc 2014-02-11 11:44:50 +0000 @@ -24,119 +24,125 @@ * 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. * */ #include "squid.h" #if HAVE_ASSERT_H #include #endif #include "MemPoolMalloc.h" #if HAVE_STRING_H #include #endif /* * XXX This is a boundary violation between lib and src.. would be good * if it could be solved otherwise, but left for now. */ extern time_t squid_curtime; 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; } else { if (doZero) obj = xcalloc(1, obj_size); else obj = xmalloc(obj_size); memMeterInc(meter.alloc); } memMeterInc(meter.inuse); return obj; } void MemPoolMalloc::deallocate(void *obj, bool aggressive) { memMeterDec(meter.inuse); if (aggressive) { xfree(obj); memMeterDec(meter.alloc); } else { if (doZero) memset(obj, 0, obj_size); memMeterInc(meter.idle); - freelist.push_back(obj); + freelist.push(obj); } } /* TODO extract common logic to MemAllocate */ int MemPoolMalloc::getStats(MemPoolStats * stats, int accumulate) { if (!accumulate) /* need skip memset for GlobalStats accumulation */ memset(stats, 0, sizeof(MemPoolStats)); stats->pool = this; stats->label = objectType(); stats->meter = &meter; stats->obj_size = obj_size; stats->chunk_capacity = 0; stats->chunks_alloc += 0; stats->chunks_inuse += 0; stats->chunks_partial += 0; stats->chunks_free += 0; stats->items_alloc += meter.alloc.level; stats->items_inuse += meter.inuse.level; stats->items_idle += meter.idle.level; stats->overhead += sizeof(MemPoolMalloc) + strlen(objectType()) + 1; return meter.inuse.level; } int MemPoolMalloc::getInUseCount() { return meter.inuse.level; } MemPoolMalloc::MemPoolMalloc(char const *aLabel, size_t aSize) : MemImplementingAllocator(aLabel, aSize) { } MemPoolMalloc::~MemPoolMalloc() { assert(meter.inuse.level == 0); clean(0); } bool MemPoolMalloc::idleTrigger(int shift) const { return freelist.size() >> (shift ? 8 : 0); } 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 12:08:28 +0000 @@ -11,61 +11,60 @@ * 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 */ #ifndef DELAYUSER_H #define DELAYUSER_H #if USE_DELAY_POOLS && USE_AUTH #include "auth/Gadgets.h" #include "auth/User.h" -#include "base/Vector.h" #include "CompositePoolNode.h" #include "DelayBucket.h" #include "DelayIdComposite.h" #include "DelaySpec.h" #include "splay.h" /// \ingroup DelayPoolsAPI class DelayUserBucket : public RefCountable { public: typedef RefCount Pointer; void *operator new(size_t); void operator delete (void *); void stats(StoreEntry *)const; DelayUserBucket(Auth::User::Pointer); ~DelayUserBucket(); DelayBucket theBucket; Auth::User::Pointer authUser; }; /// \ingroup DelayPoolsAPI class DelayUser : public CompositePoolNode { public: typedef RefCount Pointer; void *operator new(size_t); void operator delete (void *); === modified file 'src/Generic.h' --- src/Generic.h 2012-09-01 14:38:36 +0000 +++ src/Generic.h 2014-02-11 12:02:37 +0000 @@ -33,72 +33,60 @@ #include "dlink.h" #if HAVE_OSTREAM #include #endif template struct unary_function { typedef _Arg argument_type; typedef _Result result_type; }; template T& for_each(L const &head, T& visitor) { for (L const *node = &head; node; node=node->next) visitor(*node); return visitor; } template T& for_each(dlink_list const &collection, T& visitor) { for (dlink_node const *node = collection.head; node; node=node->next) visitor(*(typename T::argument_type const *)node->data); 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 */ template class InstanceToSingletonAdapter : public C { public: void *operator new (size_t byteCount) { return ::operator new (byteCount);} void operator delete (void *address) { ::operator delete (address);} InstanceToSingletonAdapter(C const *instance) : theInstance (instance) {} C const * operator-> () const {return theInstance; } C * operator-> () {return const_cast(theInstance); } C const & operator * () const {return *theInstance; } C & operator * () {return *const_cast(theInstance); } operator C const * () const {return theInstance;} operator C *() {return const_cast(theInstance);} private: C const *theInstance; }; === modified file 'src/Makefile.am' --- src/Makefile.am 2014-02-07 13:45:20 +0000 +++ src/Makefile.am 2014-02-11 12:08:04 +0000 @@ -1050,62 +1050,61 @@ CLEANFILES += cf.data squid.conf.default test_tools.cc *.a test_tools.cc: $(top_srcdir)/test-suite/test_tools.cc cp $(top_srcdir)/test-suite/test_tools.cc . # stock tools for unit tests - library independent versions of dlink_list # etc. # globals.cc is needed by test_tools.cc. # Neither of these should be disted from here. TESTSOURCES= \ tests/STUB.h \ test_tools.cc \ globals.cc check_PROGRAMS+=\ tests/testBoilerplate \ tests/testCacheManager \ tests/testDiskIO \ tests/testEvent \ tests/testEventLoop \ tests/test_http_range \ tests/testHttpParser \ tests/testHttpReply \ tests/testHttpRequest \ tests/testStore \ tests/testString \ tests/testURL \ tests/testSBuf \ tests/testSBufList \ tests/testConfigParser \ - tests/testStatHist \ - tests/testVector + tests/testStatHist if HAVE_FS_ROCK check_PROGRAMS += tests/testRock endif if HAVE_FS_UFS check_PROGRAMS += tests/testUfs endif ## NP: required to run the above list. check_PROGRAMS only builds the binaries... TESTS += $(check_PROGRAMS) ### Template for new Unit Test Program ## - add tests/testX to check_PROGRAMS above. ## - copy template below and substitue X for class name ## - add other component .(h|cc) files needed to link and run tests ## ##NP: (TESTSOURCES) defines stub debugs() and new/delete for testing ## #tests_testX_SOURCES=\ # tests/testX.h \ # tests/testX.cc \ # tests/testMain.cc \ # X.h \ # X.cc #nodist_tests_testX_SOURCES=\ # $(TESTSOURCES) #tests_testX_LDFLAGS = $(LIBADD_DL) #tests_testX_LDADD=\ # $(SQUID_CPPUNIT_LIBS) \ # $(SQUID_CPPUNIT_LA) \ @@ -3799,56 +3798,41 @@ tests_testStatHist_SOURCES = \ tests/stub_debug.cc \ tests/stub_DelayId.cc \ tests/stub_HelperChildConfig.cc \ Mem.h \ tests/stub_mem.cc \ tests/stub_MemObject.cc \ mime.h \ tests/stub_mime.cc \ tests/stub_pconn.cc \ tests/stub_stmem.cc \ repl_modules.h \ tests/stub_store.cc \ tests/stub_store_stats.cc \ tools.h \ tests/stub_tools.cc \ tests/testMain.cc \ tests/testStatHist.cc \ tests/testStatHist.h nodist_tests_testStatHist_SOURCES = \ $(TESTSOURCES) tests_testStatHist_LDFLAGS = $(LIBADD_DL) tests_testStatHist_LDADD = \ base/libbase.la \ $(top_builddir)/lib/libmiscutil.la \ $(top_builddir)/lib/libmisccontainers.la \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(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 ## aborts if error encountered testHeaders: $(srcdir)/*.h $(srcdir)/DiskIO/*.h $(srcdir)/DiskIO/*/*.h $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" $^ || exit 1 ## src/repl/ has no .h files and its own makefile. CLEANFILES += testHeaders .PHONY: testHeaders === modified file 'src/base/Makefile.am' --- src/base/Makefile.am 2014-01-01 17:15:10 +0000 +++ src/base/Makefile.am 2014-02-11 12:08:22 +0000 @@ -1,52 +1,50 @@ include $(top_srcdir)/src/Common.am include $(top_srcdir)/src/TestHeaders.am noinst_LTLIBRARIES = libbase.la libbase_la_SOURCES = \ AsyncCall.cc \ AsyncCall.h \ AsyncCbdataCalls.h \ AsyncJob.h \ AsyncJob.cc \ AsyncJobCalls.h \ AsyncCallQueue.cc \ AsyncCallQueue.h \ CharacterSet.h \ CharacterSet.cc \ TidyPointer.h \ CbcPointer.h \ InstanceId.h \ Lock.h \ LruMap.h \ RunnersRegistry.cc \ RunnersRegistry.h \ Subscription.h \ TextException.cc \ - TextException.h \ - Vector.cc \ - Vector.h + TextException.h EXTRA_PROGRAMS = \ testCharacterSet check_PROGRAMS += testCharacterSet TESTS += testCharacterSet testCharacterSet_SOURCES = \ CharacterSet.h \ testCharacterSet.h \ testCharacterSet.cc nodist_testCharacterSet_SOURCES = \ $(top_srcdir)/src/tests/testMain.cc \ $(top_srcdir)/src/tests/stub_debug.cc \ $(top_srcdir)/src/tests/stub_MemBuf.cc \ $(top_srcdir)/src/tests/stub_cbdata.cc testCharacterSet_LDFLAGS = $(LIBADD_DL) testCharacterSet_LDADD=\ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ libbase.la \ $(COMPAT_LIB) \ $(XTRA_LIBS) testCharacterSet_DEPENDENCIES= $(SQUID_CPPUNIT_LA) === 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:00:26 +0000 @@ -23,68 +23,69 @@ * (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. * */ /** \defgroup CBDATAInternal Callback Data Allocator Internals \ingroup CBDATAAPI * * These routines manage a set of registered callback data pointers. * One of the easiest ways to make Squid coredump is to issue a * callback to for some data structure which has previously been * freed. With these routines, we register (add) callback data * pointers, lock them just before registering the callback function, * validate them before issuing the callback, and then free them * when finished. */ #include "squid.h" #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 #endif static int cbdataCount = 0; #if USE_CBDATA_DEBUG dlink_list cbdataEntries; #endif #if USE_CBDATA_DEBUG class CBDataCall { public: CBDataCall (char const *callLabel, char const *aFile, int aLine) : label(callLabel), file(aFile), line(aLine) {} char const *label; char const *file; int line; }; #endif /// \ingroup CBDATAInternal #define OFFSET_OF(TYPE, MEMBER) ((size_t) &(((TYPE) *)0)->(MEMBER)) /// \ingroup CBDATAInternal class cbdata @@ -97,61 +98,61 @@ public: #endif #if USE_CBDATA_DEBUG void dump(StoreEntry *)const; #endif #if !HASHED_CBDATA void *operator new(size_t size, void *where); void operator delete(void *where, void *where2); #else MEMPROXY_CLASS(cndata); #endif ~cbdata(); int valid; int32_t locks; cbdata_type type; #if USE_CBDATA_DEBUG void addHistory(char const *label, char const *aFile, int aLine) { if (calls.size() > 1000) return; 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 */ long cookie; void check(int aLine) const {assert(cookie == ((long)this ^ Cookie));} static const long Cookie; #if !HASHED_CBDATA size_t dataSize() const { return sizeof(data);} static long MakeOffset(); static const long Offset; /* MUST be the last per-instance member */ void *data; #endif }; const long cbdata::Cookie((long)0xDEADBEEF); #if !HASHED_CBDATA const long cbdata::Offset(MakeOffset()); void * cbdata::operator new(size_t size, void *where) { // assert (size == sizeof(cbdata)); return where; } /** * Only ever invoked when placement new throws @@ -182,64 +183,65 @@ static OBJH cbdataDumpHistory; /// \ingroup CBDATAInternal struct CBDataIndex { MemAllocator *pool; FREE *free_func; } *cbdata_index = NULL; /// \ingroup CBDATAInternal int cbdata_types = 0; #if HASHED_CBDATA static hash_table *cbdata_htable = NULL; static int cbdata_cmp(const void *p1, const void *p2) { return (char *) p1 - (char *) p2; } static unsigned int cbdata_hash(const void *p, unsigned int mod) { return ((unsigned long) p >> 8) % mod; } #endif cbdata::~cbdata() { #if USE_CBDATA_DEBUG - CBDataCall *aCall; - while ((aCall = calls.pop())) - delete aCall; + while (!calls.empty()) { + delete calls.back(); + calls.pop_back(); + } #endif FREE *free_func = cbdata_index[type].free_func; #if HASHED_CBDATA void *p = hash.key; #else void *p = &data; #endif if (free_func) free_func(p); } static void cbdataInternalInitType(cbdata_type type, const char *name, int size, FREE * free_func) { char *label; assert (type == cbdata_types + 1); cbdata_index = (CBDataIndex *)xrealloc(cbdata_index, (type + 1) * sizeof(*cbdata_index)); memset(&cbdata_index[type], 0, sizeof(*cbdata_index)); cbdata_types = type; label = (char *)xmalloc(strlen(name) + 20); snprintf(label, strlen(name) + 20, "cbdata %s (%d)", name, (int) type); #if !HASHED_CBDATA @@ -289,61 +291,61 @@ void * cbdataInternalAllocDbg(cbdata_type type, const char *file, int line) #else cbdataInternalAlloc(cbdata_type type) #endif { cbdata *c; void *p; assert(type > 0 && type <= cbdata_types); /* placement new: the pool alloc gives us cbdata + user type memory space * and we init it with cbdata at the start of it */ #if HASHED_CBDATA c = new cbdata; p = cbdata_index[type].pool->alloc(); c->hash.key = p; hash_join(cbdata_htable, &c->hash); #else c = new (cbdata_index[type].pool->alloc()) cbdata; p = (void *)&c->data; #endif c->type = type; c->valid = 1; c->locks = 0; c->cookie = (long) c ^ cbdata::Cookie; ++cbdataCount; #if USE_CBDATA_DEBUG 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); #else debugs(45, 9, "cbdataAlloc: " << p); #endif return p; } void * #if USE_CBDATA_DEBUG cbdataInternalFreeDbg(void *p, const char *file, int line) #else cbdataInternalFree(void *p) #endif { cbdata *c; #if HASHED_CBDATA c = (cbdata *) hash_lookup(cbdata_htable, p); #else c = (cbdata *) (((char *) p) - cbdata::Offset); #endif #if USE_CBDATA_DEBUG debugs(45, 3, "cbdataFree: " << p << " " << file << ":" << line); #else debugs(45, 9, "cbdataFree: " << p); #endif @@ -587,62 +589,62 @@ cbdataDump(StoreEntry * sentry) storeAppendPrintf(sentry, "types\tsize\tallocated\ttotal\n"); for (int i = 1; i < cbdata_types; ++i) { MemAllocator *pool = cbdata_index[i].pool; if (pool) { #if HASHED_CBDATA int obj_size = pool->objectSize(); #else int obj_size = pool->objectSize() - cbdata::Offset; #endif storeAppendPrintf(sentry, "%s\t%d\t%ld\t%ld\n", pool->objectType() + 7, obj_size, (long int)pool->getMeter().inuse.level, (long int)obj_size * pool->getMeter().inuse.level); } } #else storeAppendPrintf(sentry, "detailed allocation information only available when compiled with --enable-debug-cbdata\n"); #endif storeAppendPrintf(sentry, "\nsee also \"Memory utilization\" for detailed per type statistics\n"); } CBDATA_CLASS_INIT(generic_cbdata); #if USE_CBDATA_DEBUG 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; }; struct CBDataHistoryDumper : public CBDataDumper { CBDataHistoryDumper(StoreEntry *anEntry):CBDataDumper(anEntry),where(anEntry), callDumper(anEntry) {} void operator()(cbdata const &x) { 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"); } StoreEntry *where; CBDataCallDumper callDumper; }; void cbdataDumpHistory(StoreEntry *sentry) { storeAppendPrintf(sentry, "%d cbdata entries\n", cbdataCount); storeAppendPrintf(sentry, "Pointer\tType\tLocks\tAllocated by\n"); CBDataHistoryDumper dumper(sentry); for_each (cbdataEntries, dumper); } #endif === modified file 'src/store.cc' --- src/store.cc 2014-02-02 08:57:20 +0000 +++ src/store.cc 2014-02-11 12:04:20 +0000 @@ -24,135 +24,136 @@ * 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. * */ #include "squid.h" #include "CacheDigest.h" #include "CacheManager.h" #include "comm/Connection.h" #include "ETag.h" #include "event.h" #include "fde.h" #include "globals.h" #include "http.h" #include "HttpReply.h" #include "HttpRequest.h" #include "mem_node.h" #include "MemObject.h" #include "mgr/Registration.h" #include "mgr/StoreIoAction.h" #include "profiler/Profiler.h" #include "repl_modules.h" #include "RequestFlags.h" #include "SquidConfig.h" #include "SquidTime.h" -#include "Stack.h" #include "StatCounters.h" #include "stmem.h" #include "Store.h" #include "store_digest.h" #include "store_key_md5.h" #include "store_key_md5.h" #include "store_log.h" #include "store_rebuild.h" #include "StoreClient.h" #include "StoreIOState.h" #include "StoreMeta.h" #include "StrList.h" #include "swap_log_op.h" #include "SwapDir.h" #include "tools.h" #if USE_DELAY_POOLS #include "DelayPools.h" #endif #if HAVE_LIMITS_H #include #endif +#include + #define REBUILD_TIMESTAMP_DELTA_MAX 2 #define STORE_IN_MEM_BUCKETS (229) /** \todo Convert these string constants to enum string-arrays generated */ const char *memStatusStr[] = { "NOT_IN_MEMORY", "IN_MEMORY" }; const char *pingStatusStr[] = { "PING_NONE", "PING_WAITING", "PING_DONE" }; const char *storeStatusStr[] = { "STORE_OK", "STORE_PENDING" }; const char *swapStatusStr[] = { "SWAPOUT_NONE", "SWAPOUT_WRITING", "SWAPOUT_DONE" }; /* * This defines an repl type */ typedef struct _storerepl_entry storerepl_entry_t; struct _storerepl_entry { const char *typestr; REMOVALPOLICYCREATE *create; }; static storerepl_entry_t *storerepl_list = NULL; /* * local function prototypes */ static int getKeyCounter(void); static OBJH storeCheckCachableStats; static EVH storeLateRelease; /* * local variables */ -static Stack LateReleaseStack; +static std::stack LateReleaseStack; MemAllocator *StoreEntry::pool = NULL; StorePointer Store::CurrentRoot = NULL; void Store::Root(Store * aRoot) { CurrentRoot = aRoot; } void Store::Root(StorePointer aRoot) { Root(aRoot.getRaw()); } void Store::Stats(StoreEntry * output) { assert (output); Root().stat(*output); } void Store::create() {} void Store::diskFull() {} @@ -1226,98 +1227,104 @@ StoreController::maintain() PROF_stop(storeMaintainSwapSpace); } /* release an object from a cache */ void StoreEntry::release() { PROF_start(storeRelease); debugs(20, 3, "releasing " << *this << ' ' << getMD5Text()); /* If, for any reason we can't discard this object because of an * outstanding request, mark it for pending release */ if (locked()) { expireNow(); debugs(20, 3, "storeRelease: Only setting RELEASE_REQUEST bit"); releaseRequest(); PROF_stop(storeRelease); return; } Store::Root().memoryUnlink(*this); if (StoreController::store_dirs_rebuilding && swap_filen > -1) { setPrivateKey(); if (swap_filen > -1) { // 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 } PROF_stop(storeRelease); return; } storeLog(STORE_LOG_RELEASE, this); if (swap_filen > -1) { // log before unlink() below clears swap_filen if (!EBIT_TEST(flags, KEY_PRIVATE)) storeDirSwapLog(this, SWAP_LOG_DEL); unlink(); } destroyStoreEntry(static_cast(this)); PROF_stop(storeRelease); } static void storeLateRelease(void *unused) { StoreEntry *e; int i; static int n = 0; if (StoreController::store_dirs_rebuilding) { eventAdd("storeLateRelease", storeLateRelease, NULL, 1.0, 1); return; } + // TODO: this works but looks unelegant. for (i = 0; i < 10; ++i) { - e = LateReleaseStack.empty() ? NULL : LateReleaseStack.pop(); + if (LateReleaseStack.empty()) { + e = NULL; + } else { + e = LateReleaseStack.top(); + LateReleaseStack.pop(); + } if (e == NULL) { /* done! */ debugs(20, DBG_IMPORTANT, "storeLateRelease: released " << n << " objects"); return; } e->unlock("storeLateRelease"); ++n; } eventAdd("storeLateRelease", storeLateRelease, NULL, 0.0, 1); } /* return 1 if a store entry is locked */ int StoreEntry::locked() const { if (lock_count) return 1; /* * SPECIAL, PUBLIC entries should be "locked"; * XXX: Their owner should lock them then instead of relying on this hack. */ if (EBIT_TEST(flags, ENTRY_SPECIAL)) if (!EBIT_TEST(flags, KEY_PRIVATE)) return 1; return 0; === 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 12:09:57 +0000 @@ -4,120 +4,116 @@ AUTOMAKE_OPTIONS = subdir-objects ## we need our local files too (but avoid -I. at all costs) INCLUDES += -I$(srcdir) LDADD = \ $(top_builddir)/src/globals.o \ $(top_builddir)/src/time.o \ $(top_builddir)/lib/libmiscutil.la \ $(COMPAT_LIB) \ $(XTRA_LIBS) EXTRA_PROGRAMS = mem_node_test membanger splay tcp-banger2 EXTRA_DIST = \ $(srcdir)/squidconf/* \ testheaders.sh ESI_ALL_TESTS = \ ESIExpressions if USE_ESI ESI_TESTS = $(ESI_ALL_TESTS) else ESI_TESTS = endif ## Sort by dependencies - test lowest layers first TESTS += debug \ syntheticoperators \ VirtualDeleteOperator \ - StackTest \ splay\ MemPoolTest\ mem_node_test\ mem_hdr_test\ $(ESI_TESTS) \ squid-conf-tests ## Sort by alpha - any build failures are significant. check_PROGRAMS += debug \ $(ESI_TESTS) \ MemPoolTest\ mem_node_test\ mem_hdr_test \ splay \ - StackTest \ syntheticoperators \ VirtualDeleteOperator tcp_banger2_LDADD = $(top_builddir)/lib/libmiscutil.la DEBUG_SOURCE = test_tools.cc stub_debug.cc stub_tools.cc stub_fatal.cc stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc cp $(top_srcdir)/src/tests/stub_debug.cc . stub_tools.cc: $(top_srcdir)/src/tests/stub_tools.cc cp $(top_srcdir)/src/tests/stub_tools.cc . stub_fatal.cc: $(top_srcdir)/src/tests/stub_fatal.cc cp $(top_srcdir)/src/tests/stub_fatal.cc . CLEANFILES += stub_debug.cc stub_tools.cc stub_fatal.cc ## XXX: somewhat broken. Its meant to test our debugs() implementation. ## but it has never been linked to the actual src/debug.cc implementation !! ## all it tests are the stream operators and macro in src/Debug.h debug_SOURCES = debug.cc $(DEBUG_SOURCE) ESIExpressions_SOURCES = ESIExpressions.cc $(DEBUG_SOURCE) ESIExpressions_LDADD = $(top_builddir)/src/esi/Expression.o \ $(LDADD) mem_node_test_SOURCES = mem_node_test.cc mem_node_test_LDADD = $(top_builddir)/src/mem_node.o $(LDADD) mem_hdr_test_SOURCES = mem_hdr_test.cc $(DEBUG_SOURCE) mem_hdr_test_LDADD = \ $(top_builddir)/src/stmem.o \ $(top_builddir)/src/mem_node.o \ $(LDADD) MemPoolTest_SOURCES = MemPoolTest.cc splay_SOURCES = splay.cc -StackTest_SOURCES = StackTest.cc $(DEBUG_SOURCE) - syntheticoperators_SOURCES = syntheticoperators.cc $(DEBUG_SOURCE) VirtualDeleteOperator_SOURCES = VirtualDeleteOperator.cc $(DEBUG_SOURCE) ## membanger won't link today. Bitrot.. ##CC = gcc ##CFLAGS = -g -Wall -I../include -I../src ##OBJS = membanger.o hash.o SizeToPool.o ##LIB = -L. -lMem ##TARGLIB = libMem.a ##LIBOBJS = Mem.o \ ## Stack.o ##AR_R = /usr/bin/ar r ##RM = rm ##XTRA_LIBS = -lm -lmalloc ## ##all: membanger ## ##membanger: $(OBJS) $(TARGLIB) ## $(CC) -o membanger $(OBJS) $(LIB) ## ##$(TARGLIB): $(LIBOBJS) ## $(AR_R) $(TARGLIB) $(LIBOBJS) squid-conf-tests: $(top_builddir)/src/squid.conf.default $(srcdir)/squidconf/* @failed=0; cfglist="$?"; rm -f $@ || $(TRUE); \ for cfg in $$cfglist ; do \ $(top_builddir)/src/squid -k parse -f $$cfg || \ { echo "FAIL: squid.conf test: $$cfg" | \ sed s%$(top_builddir)/src/%% | \ === 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; -}