From: Alex Rousskov Date: Tue, 24 Jun 2014 22:21:48 +0000 (-0600) Subject: Prep for merge from trunk: undo branch r13313, r13312, and r13311 that were X-Git-Tag: SQUID_3_5_0_1~170^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfb88efb1e75015ac6c38fd975eb5c565f1c36b1;p=thirdparty%2Fsquid.git Prep for merge from trunk: undo branch r13313, r13312, and r13311 that were temporary undoing trunk r13266, r13269, and r13270 (std::vector migration). --- diff --git a/include/MemPoolMalloc.h b/include/MemPoolMalloc.h index 2999dd4620..43064203ea 100644 --- a/include/MemPoolMalloc.h +++ b/include/MemPoolMalloc.h @@ -22,6 +22,8 @@ #include "MemPool.h" +#include + /// \ingroup MemPoolsAPI class MemPoolMalloc : public MemImplementingAllocator { @@ -42,7 +44,7 @@ protected: virtual void *allocate(); virtual void deallocate(void *, bool aggressive); private: - Stack freelist; + std::stack freelist; }; #endif /* _MEM_POOL_MALLOC_H_ */ diff --git a/include/Stack.h b/include/Stack.h deleted file mode 100644 index fe39f6680f..0000000000 --- a/include/Stack.h +++ /dev/null @@ -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 */ diff --git a/include/splay.h b/include/splay.h index d4e4202fe8..fc48ae12d0 100644 --- a/include/splay.h +++ b/include/splay.h @@ -3,7 +3,9 @@ #if defined(__cplusplus) -#include "Stack.h" +#include "fatal.h" + +#include template class SplayNode @@ -402,7 +404,7 @@ private: void advance(); void addLeftPath(SplayNode *aNode); void init(SplayNode *); - Stack *> toVisit; + std::stack *> toVisit; }; template @@ -415,7 +417,12 @@ 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 @@ -447,19 +454,21 @@ 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 @@ -470,7 +479,7 @@ SplayConstIterator::addLeftPath(SplayNode *aNode) return; do { - toVisit.push_back(aNode); + toVisit.push(aNode); aNode = aNode->left; } while (aNode != NULL); } diff --git a/lib/MemPoolMalloc.cc b/lib/MemPoolMalloc.cc index 4e25cc4207..f0fe52fe98 100644 --- a/lib/MemPoolMalloc.cc +++ b/lib/MemPoolMalloc.cc @@ -46,7 +46,11 @@ 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; @@ -72,7 +76,7 @@ MemPoolMalloc::deallocate(void *obj, bool aggressive) if (doZero) memset(obj, 0, obj_size); memMeterInc(meter.idle); - freelist.push_back(obj); + freelist.push(obj); } } @@ -122,13 +126,15 @@ MemPoolMalloc::~MemPoolMalloc() bool MemPoolMalloc::idleTrigger(int shift) const { - return freelist.count >> (shift ? 8 : 0); + 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); diff --git a/src/ClientDelayConfig.cc b/src/ClientDelayConfig.cc index 0d95212f78..a588fd4aea 100644 --- a/src/ClientDelayConfig.cc +++ b/src/ClientDelayConfig.cc @@ -30,7 +30,7 @@ ClientDelayConfig::finalize() void ClientDelayConfig::freePoolCount() { - pools.clean(); + pools.clear(); } void ClientDelayConfig::dumpPoolCount(StoreEntry * entry, const char *name) const diff --git a/src/ClientDelayConfig.h b/src/ClientDelayConfig.h index d9e3c69707..30cd5abcf9 100644 --- a/src/ClientDelayConfig.h +++ b/src/ClientDelayConfig.h @@ -2,7 +2,8 @@ #define SQUID_CLIENTDELAYCONFIG_H #include "acl/forward.h" -#include "base/Vector.h" + +#include class StoreEntry; class ConfigParser; @@ -21,7 +22,7 @@ public: int64_t highwatermark; }; -typedef Vector ClientDelayPools; +typedef std::vector ClientDelayPools; /* represents configuration of client write limiting delay pools */ class ClientDelayConfig diff --git a/src/ConfigOption.cc b/src/ConfigOption.cc index 92a5ede6af..93f691a4a0 100644 --- a/src/ConfigOption.cc +++ b/src/ConfigOption.cc @@ -35,7 +35,7 @@ ConfigOptionVector::~ConfigOptionVector() { - while (options.size()) { + while (!options.empty()) { delete options.back(); options.pop_back(); } @@ -44,7 +44,7 @@ ConfigOptionVector::~ConfigOptionVector() bool ConfigOptionVector::parse(char const *option, const char *value, int isaReconfig) { - Vector::iterator i = options.begin(); + std::vector::iterator i = options.begin(); while (i != options.end()) { if ((*i)->parse(option,value, isaReconfig)) @@ -59,7 +59,7 @@ ConfigOptionVector::parse(char const *option, const char *value, int isaReconfig void ConfigOptionVector::dump(StoreEntry * e) const { - for (Vector::const_iterator i = options.begin(); + for (std::vector::const_iterator i = options.begin(); i != options.end(); ++i) (*i)->dump(e); } diff --git a/src/ConfigOption.h b/src/ConfigOption.h index 2016eb6b7f..9ca1c00f7b 100644 --- a/src/ConfigOption.h +++ b/src/ConfigOption.h @@ -30,7 +30,7 @@ #ifndef SQUID_CONFIGOPTION_H #define SQUID_CONFIGOPTION_H -#include "base/Vector.h" +#include class StoreEntry; @@ -53,7 +53,7 @@ public: virtual ~ConfigOptionVector(); virtual bool parse(char const *option, const char *value, int reconfiguring); virtual void dump(StoreEntry * e) const; - Vectoroptions; + std::vectoroptions; }; template diff --git a/src/CpuAffinityMap.cc b/src/CpuAffinityMap.cc index 2d616263e8..d4132f0365 100644 --- a/src/CpuAffinityMap.cc +++ b/src/CpuAffinityMap.cc @@ -10,7 +10,7 @@ #include "Debug.h" bool -CpuAffinityMap::add(const Vector &aProcesses, const Vector &aCores) +CpuAffinityMap::add(const std::vector &aProcesses, const std::vector &aCores) { if (aProcesses.size() != aCores.size()) return false; diff --git a/src/CpuAffinityMap.h b/src/CpuAffinityMap.h index d322573f3d..e2038cfcb7 100644 --- a/src/CpuAffinityMap.h +++ b/src/CpuAffinityMap.h @@ -4,7 +4,7 @@ #ifndef SQUID_CPU_AFFINITY_MAP_H #define SQUID_CPU_AFFINITY_MAP_H -#include "base/Vector.h" +#include class CpuAffinitySet; @@ -13,20 +13,20 @@ class CpuAffinityMap { public: /// append cpu_affinity_map option - bool add(const Vector &aProcesses, const Vector &aCores); + bool add(const std::vector &aProcesses, const std::vector &aCores); /// calculate CPU set for this process CpuAffinitySet *calculateSet(const int targetProcess) const; /// returns list of process numbers - const Vector &processes() const { return theProcesses; } + const std::vector &processes() const { return theProcesses; } /// returns list of cores - const Vector &cores() const { return theCores; } + const std::vector &cores() const { return theCores; } private: - Vector theProcesses; ///< list of process numbers - Vector theCores; ///< list of cores + std::vector theProcesses; ///< list of process numbers + std::vector theCores; ///< list of cores }; #endif // SQUID_CPU_AFFINITY_MAP_H diff --git a/src/DelayPools.h b/src/DelayPools.h index f7748e262a..182df498a8 100644 --- a/src/DelayPools.h +++ b/src/DelayPools.h @@ -32,7 +32,7 @@ #ifndef SQUID_DELAYPOOLS_H #define SQUID_DELAYPOOLS_H -#include "base/Vector.h" +#include class DelayPool; class Updateable; @@ -75,7 +75,7 @@ private: static time_t LastUpdate; static unsigned short pools_; static void FreeDelayData (); - static Vector toUpdate; + static std::vector toUpdate; static void RegisterWithCacheManager(void); }; diff --git a/src/DelayTagged.h b/src/DelayTagged.h index 61b6e4c620..f0c15d6a69 100644 --- a/src/DelayTagged.h +++ b/src/DelayTagged.h @@ -37,7 +37,6 @@ #if USE_DELAY_POOLS #include "auth/Gadgets.h" -#include "base/Vector.h" #include "CompositePoolNode.h" #include "DelayBucket.h" #include "DelayIdComposite.h" diff --git a/src/DelayUser.h b/src/DelayUser.h index 6ac274791c..9bc88f411d 100644 --- a/src/DelayUser.h +++ b/src/DelayUser.h @@ -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" diff --git a/src/DelayVector.h b/src/DelayVector.h index f0cb9a72d6..33bc2c5834 100644 --- a/src/DelayVector.h +++ b/src/DelayVector.h @@ -72,16 +72,16 @@ private: private: RefCount theVector; - Vector ids; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + std::vector ids; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; }; friend class Id; - Vector pools; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + std::vector pools; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; }; #endif /* USE_DELAY_POOLS */ diff --git a/src/DiskIO/DiskIOModule.cc b/src/DiskIO/DiskIOModule.cc index 0bc3278ac0..8d151b20b7 100644 --- a/src/DiskIO/DiskIOModule.cc +++ b/src/DiskIO/DiskIOModule.cc @@ -35,7 +35,7 @@ #include "squid.h" #include "DiskIOModule.h" -Vector *DiskIOModule::_Modules = NULL; +std::vector *DiskIOModule::_Modules = NULL; //DiskIOModule() : initialised (false) {} @@ -70,17 +70,17 @@ DiskIOModule::ModuleAdd(DiskIOModule &instance) GetModules().push_back (&instance); } -Vector const & +std::vector const & DiskIOModule::Modules() { return GetModules(); } -Vector & +std::vector & DiskIOModule::GetModules() { if (!_Modules) - _Modules = new Vector; + _Modules = new std::vector; return *_Modules; } @@ -92,7 +92,7 @@ DiskIOModule::GetModules() void DiskIOModule::FreeAllModules() { - while (GetModules().size()) { + while (!GetModules().empty()) { DiskIOModule *fs = GetModules().back(); GetModules().pop_back(); fs->gracefulShutdown(); diff --git a/src/DiskIO/DiskIOModule.h b/src/DiskIO/DiskIOModule.h index ad05153c94..a7696d5557 100644 --- a/src/DiskIO/DiskIOModule.h +++ b/src/DiskIO/DiskIOModule.h @@ -32,7 +32,7 @@ #ifndef SQUID_DISKIOMODULE_H #define SQUID_DISKIOMODULE_H -#include "base/Vector.h" +#include /* forward decls */ @@ -57,9 +57,9 @@ public: * available module for this system. */ static DiskIOModule *FindDefault(); - static Vector const &Modules(); - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + static std::vector const &Modules(); + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; DiskIOModule(); virtual ~DiskIOModule() {} @@ -78,8 +78,8 @@ protected: static void RegisterAllModulesWithCacheManager(void); private: - static Vector &GetModules(); - static Vector *_Modules; + static std::vector &GetModules(); + static std::vector *_Modules; }; #endif /* SQUID_DISKIOMODULE_H */ diff --git a/src/EventLoop.h b/src/EventLoop.h index 3070051053..a2778f618e 100644 --- a/src/EventLoop.h +++ b/src/EventLoop.h @@ -31,7 +31,7 @@ #ifndef SQUID_EVENTLOOP_H #define SQUID_EVENTLOOP_H -#include "base/Vector.h" +#include #define EVENT_LOOP_TIMEOUT 1000 /* 1s timeout */ @@ -104,7 +104,7 @@ private: bool dispatchCalls(); bool last_loop; - typedef Vector engine_vector; + typedef std::vector engine_vector; engine_vector engines; TimeEngine * timeService; AsyncEngine * primaryEngine; diff --git a/src/ExternalACLEntry.cc b/src/ExternalACLEntry.cc index a8a459cd07..6e3a969e16 100644 --- a/src/ExternalACLEntry.cc +++ b/src/ExternalACLEntry.cc @@ -70,7 +70,7 @@ ExternalACLEntry::update(ExternalACLEntryData const &someData) result = someData.result; // replace all notes. not combine - notes.entries.clean(); + notes.entries.clear(); notes.append(&someData.notes); #if USE_AUTH diff --git a/src/FadingCounter.h b/src/FadingCounter.h index 9430ef14f6..ee65f92e4d 100644 --- a/src/FadingCounter.h +++ b/src/FadingCounter.h @@ -1,7 +1,7 @@ #ifndef SQUID_FADING_COUNTER_H #define SQUID_FADING_COUNTER_H -#include "base/Vector.h" +#include /// Counts events, forgetting old ones. Usefull for "3 errors/minute" limits. class FadingCounter @@ -25,7 +25,7 @@ private: double delta; ///< sub-interval duration = horizon/precision double lastTime; ///< time of the last update - Vector counters; ///< events per delta (possibly stale) + std::vector counters; ///< events per delta (possibly stale) int total; ///< number of remembered events (possibly stale) }; diff --git a/src/FwdState.cc b/src/FwdState.cc index 6847fed133..3a8d11e82b 100644 --- a/src/FwdState.cc +++ b/src/FwdState.cc @@ -112,7 +112,7 @@ FwdState::abort(void* d) } else { debugs(17, 7, HERE << "store entry aborted; no connection to close"); } - fwd->serverDestinations.clean(); + fwd->serverDestinations.clear(); fwd->self = NULL; } @@ -277,7 +277,7 @@ FwdState::~FwdState() serverConn->close(); } - serverDestinations.clean(); + serverDestinations.clear(); debugs(17, 3, HERE << "FwdState destructor done"); } @@ -472,7 +472,7 @@ FwdState::complete() entry->reset(); // drop the last path off the selection list. try the next one. - serverDestinations.shift(); + serverDestinations.erase(serverDestinations.begin()); startConnectionOrFail(); } else { @@ -611,7 +611,7 @@ FwdState::retryOrBail() if (pconnRace == raceHappened) debugs(17, 4, HERE << "retrying the same destination"); else - serverDestinations.shift(); // last one failed. try another. + serverDestinations.erase(serverDestinations.begin()); // last one failed. try another. startConnectionOrFail(); return; } diff --git a/src/FwdState.h b/src/FwdState.h index 5472b5164b..88b5775088 100644 --- a/src/FwdState.h +++ b/src/FwdState.h @@ -2,7 +2,6 @@ #define SQUID_FORWARD_H #include "base/RefCount.h" -#include "base/Vector.h" #include "comm.h" #include "comm/Connection.h" #include "err_type.h" diff --git a/src/Generic.h b/src/Generic.h index 5e3329abd1..1f7fbbf99b 100644 --- a/src/Generic.h +++ b/src/Generic.h @@ -58,18 +58,6 @@ T& for_each(dlink_list const &collection, T& visitor) 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 */ diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index bea0c7a42c..541a23e1de 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -266,8 +266,10 @@ HttpHdrRange::parseInit(const String * range_spec) * at least one syntactically invalid byte-range-specs. */ if (!spec) { - while (!specs.empty()) - delete specs.pop_back(); + while (!specs.empty()) { + delete specs.back(); + specs.pop_back(); + } debugs(64, 2, "ignoring invalid range field: '" << range_spec << "'"); break; } @@ -281,8 +283,10 @@ HttpHdrRange::parseInit(const String * range_spec) HttpHdrRange::~HttpHdrRange() { - while (specs.size()) - delete specs.pop_back(); + while (!specs.empty()) { + delete specs.back(); + specs.pop_back(); + } } HttpHdrRange::HttpHdrRange(HttpHdrRange const &old) : @@ -338,10 +342,10 @@ HttpHdrRange::packInto(Packer * packer) const } void -HttpHdrRange::merge (Vector &basis) +HttpHdrRange::merge (std::vector &basis) { /* reset old array */ - specs.clean(); + specs.clear(); /* merge specs: * take one spec from "goods" and merge it with specs from * "specs" (if any) until there is no overlap */ @@ -350,7 +354,8 @@ HttpHdrRange::merge (Vector &basis) while (i != basis.end()) { if (specs.size() && (*i)->mergeWith(specs.back())) { /* merged with current so get rid of the prev one */ - delete specs.pop_back(); + delete specs.back(); + specs.pop_back(); continue; /* re-iterate */ } @@ -363,7 +368,7 @@ HttpHdrRange::merge (Vector &basis) } void -HttpHdrRange::getCanonizedSpecs (Vector ©) +HttpHdrRange::getCanonizedSpecs(std::vector ©) { /* canonize each entry and destroy bad ones if any */ @@ -374,8 +379,7 @@ HttpHdrRange::getCanonizedSpecs (Vector ©) delete (*pos); } - debugs(64, 3, "HttpHdrRange::getCanonizedSpecs: found " << - specs.size() - copy.size() << " bad specs"); + debugs(64, 3, "found " << specs.size() - copy.size() << " bad specs"); } #include "HttpHdrContRange.h" @@ -404,14 +408,14 @@ int HttpHdrRange::canonize (int64_t newClen) { clen = newClen; - debugs(64, 3, "HttpHdrRange::canonize: started with " << specs.count << + debugs(64, 3, "HttpHdrRange::canonize: started with " << specs.size() << " specs, clen: " << clen); - Vector goods; + std::vector goods; getCanonizedSpecs(goods); merge (goods); - debugs(64, 3, "HttpHdrRange::canonize: finished with " << specs.count << + debugs(64, 3, "HttpHdrRange::canonize: finished with " << specs.size() << " specs"); - return specs.count > 0; + return specs.size() > 0; // fixme, should return bool } /* hack: returns true if range specs are too "complex" for Squid to handle */ @@ -574,7 +578,7 @@ HttpHdrRange::contains(HttpHdrRangeSpec& r) const const HttpHdrRangeSpec * HttpHdrRangeIter::currentSpec() const { - if (pos.incrementable()) + if (pos != end) return *pos; return NULL; @@ -586,7 +590,7 @@ HttpHdrRangeIter::updateSpec() assert (debt_size == 0); assert (valid); - if (pos.incrementable()) { + if (pos != end) { debt(currentSpec()->length); } } diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index bd6c0eb08e..56eb4b32e6 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -50,6 +50,12 @@ #include "StrList.h" #include "TimeOrTag.h" +#include + +/* XXX: the whole set of API managing the entries vector should be rethought + * after the parse4r-ng effort is complete. + */ + /* * On naming conventions: * @@ -435,8 +441,6 @@ HttpHeader::operator =(const HttpHeader &other) void HttpHeader::clean() { - HttpHeaderPos pos = HttpHeaderInitPos; - HttpHeaderEntry *e; assert(owner > hoNone && owner < hoEnd); debugs(55, 7, "cleaning hdr: " << this << " owner: " << owner); @@ -454,27 +458,28 @@ HttpHeader::clean() * has been used. As a hack, just never count zero-sized header * arrays. */ - if (0 != entries.count) - HttpHeaderStats[owner].hdrUCountDistr.count(entries.count); + if (!entries.empty()) + HttpHeaderStats[owner].hdrUCountDistr.count(entries.size()); ++ HttpHeaderStats[owner].destroyedCount; - HttpHeaderStats[owner].busyDestroyedCount += entries.count > 0; + 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.clean(); + + entries.clear(); httpHeaderMaskInit(&mask, 0); len = 0; PROF_stop(HttpHeaderClean); @@ -748,11 +753,11 @@ HttpHeaderEntry * HttpHeader::getEntry(HttpHeaderPos * pos) const { assert(pos); - assert(*pos >= HttpHeaderInitPos && *pos < (ssize_t)entries.count); + assert(*pos >= HttpHeaderInitPos && *pos < static_cast(entries.size())); - for (++(*pos); *pos < (ssize_t)entries.count; ++(*pos)) { - if (entries.items[*pos]) - return (HttpHeaderEntry*)entries.items[*pos]; + for (++(*pos); *pos < static_cast(entries.size()); ++(*pos)) { + if (entries[*pos]) + return static_cast(entries[*pos]); } return NULL; @@ -871,9 +876,9 @@ void HttpHeader::delAt(HttpHeaderPos pos, int &headers_deleted) { HttpHeaderEntry *e; - assert(pos >= HttpHeaderInitPos && pos < (ssize_t)entries.count); - e = (HttpHeaderEntry*)entries.items[pos]; - entries.items[pos] = NULL; + assert(pos >= HttpHeaderInitPos && pos < static_cast(entries.size())); + e = static_cast(entries[pos]); + entries[pos] = NULL; /* decrement header length, allow for ": " and crlf */ len -= e->name.size() + 2 + e->value.size() + 2; assert(len >= 0); @@ -887,7 +892,10 @@ HttpHeader::delAt(HttpHeaderPos pos, int &headers_deleted) void HttpHeader::compact() { - entries.prune(NULL); + // TODO: optimize removal, or possibly make it so that's not needed. + std::vector::iterator newend; + newend = std::remove(entries.begin(), entries.end(), static_cast(NULL)); + entries.resize(newend-entries.begin()); } /* @@ -914,7 +922,7 @@ HttpHeader::addEntry(HttpHeaderEntry * e) assert_eid(e->id); assert(e->name.size()); - debugs(55, 7, HERE << this << " adding entry: " << e->id << " at " << entries.count); + debugs(55, 7, this << " adding entry: " << e->id << " at " << entries.size()); if (CBIT_TEST(mask, e->id)) ++ Headers[e->id].stat.repCount; @@ -936,14 +944,14 @@ HttpHeader::insertEntry(HttpHeaderEntry * e) assert(e); assert_eid(e->id); - debugs(55, 7, HERE << this << " adding entry: " << e->id << " at " << entries.count); + debugs(55, 7, this << " adding entry: " << e->id << " at " << entries.size()); if (CBIT_TEST(mask, e->id)) ++ Headers[e->id].stat.repCount; else CBIT_SET(mask, e->id); - entries.insert(e); + entries.insert(entries.begin(),e); /* increment header length, allow for ": " and crlf */ len += e->name.size() + 2 + e->value.size() + 2; diff --git a/src/HttpHeader.h b/src/HttpHeader.h index 8681d1aaca..7f08ee8a01 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -36,6 +36,8 @@ #include "MemPool.h" #include "SquidString.h" +#include + /* class forward declarations */ class HttpHdrCc; class HttpHdrContRange; @@ -283,7 +285,7 @@ public: inline bool chunked() const; ///< whether message uses chunked Transfer-Encoding /* protected, do not use these, use interface functions instead */ - Vector entries; /**< parsed fields in raw format */ + std::vector entries; /**< parsed fields in raw format */ HttpHeaderMask mask; /**< bit set <=> entry present */ http_hdr_owner_type owner; /**< request or reply */ int len; /**< length when packed, not counting terminating null-byte */ diff --git a/src/HttpHeaderRange.h b/src/HttpHeaderRange.h index 0a66b83d06..2c20633e7c 100644 --- a/src/HttpHeaderRange.h +++ b/src/HttpHeaderRange.h @@ -1,4 +1,3 @@ - /* * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -32,12 +31,13 @@ #ifndef SQUID_HTTPHEADERRANGE_H #define SQUID_HTTPHEADERRANGE_H -#include "base/Vector.h" #include "MemPool.h" #include "Packer.h" #include "Range.h" #include "SquidString.h" +#include + class HttpReply; /* http byte-range-spec */ @@ -83,8 +83,8 @@ public: ~HttpHdrRange(); HttpHdrRange &operator= (HttpHdrRange const &); - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; iterator begin(); const_iterator begin () const; iterator end(); @@ -103,11 +103,11 @@ public: int64_t lowestOffset(int64_t) const; bool offsetLimitExceeded(const int64_t limit) const; bool contains(HttpHdrRangeSpec& r) const; - Vector specs; + std::vector specs; private: - void getCanonizedSpecs (Vector ©); - void merge (Vector &basis); + void getCanonizedSpecs (std::vector ©); + void merge (std::vector &basis); int64_t clen; }; @@ -121,6 +121,7 @@ class HttpHdrRangeIter public: HttpHdrRange::iterator pos; + HttpHdrRange::iterator end; const HttpHdrRangeSpec *currentSpec() const; void updateSpec(); int64_t debt() const; diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index d43b23df46..764e71f909 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -479,7 +479,7 @@ HttpRequest::adaptHistoryImport(const HttpRequest &them) bool HttpRequest::multipartRangeRequest() const { - return (range && range->specs.count > 1); + return (range && range->specs.size() > 1); } bool diff --git a/src/Makefile.am b/src/Makefile.am index 400f3153d5..c0568c1ead 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1077,8 +1077,7 @@ check_PROGRAMS+=\ tests/testSBuf \ tests/testSBufList \ tests/testConfigParser \ - tests/testStatHist \ - tests/testVector + tests/testStatHist if HAVE_FS_ROCK check_PROGRAMS += tests/testRock @@ -3826,21 +3825,6 @@ tests_testStatHist_LDADD = \ $(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 diff --git a/src/Notes.cc b/src/Notes.cc index ad84e0ea6b..3a93ee3e5c 100644 --- a/src/Notes.cc +++ b/src/Notes.cc @@ -146,13 +146,15 @@ Notes::dump(StoreEntry *entry, const char *key) void Notes::clean() { - notes.clean(); + notes.clear(); } NotePairs::~NotePairs() { - while (!entries.empty()) - delete entries.pop_back(); + while (!entries.empty()) { + delete entries.back(); + entries.pop_back(); + } } const char * @@ -160,7 +162,7 @@ NotePairs::find(const char *noteKey) const { static String value; value.clean(); - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { if ((*i)->name.cmp(noteKey) == 0) { if (value.size()) value.append(", "); @@ -175,7 +177,7 @@ NotePairs::toString(const char *sep) const { static String value; value.clean(); - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { value.append((*i)->name); value.append(": "); value.append(ConfigParser::QuoteString((*i)->value)); @@ -187,7 +189,7 @@ NotePairs::toString(const char *sep) const const char * NotePairs::findFirst(const char *noteKey) const { - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { if ((*i)->name.cmp(noteKey) == 0) return (*i)->value.termedBuf(); } @@ -217,7 +219,7 @@ NotePairs::addStrList(const char *key, const char *values) bool NotePairs::hasPair(const char *key, const char *value) const { - for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { + for (std::vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { if ((*i)->name.cmp(key) == 0 && (*i)->value.cmp(value) == 0) return true; } @@ -227,7 +229,7 @@ NotePairs::hasPair(const char *key, const char *value) const void NotePairs::append(const NotePairs *src) { - for (Vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { + for (std::vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { entries.push_back(new NotePairs::Entry((*i)->name.termedBuf(), (*i)->value.termedBuf())); } } @@ -235,7 +237,7 @@ NotePairs::append(const NotePairs *src) void NotePairs::appendNewOnly(const NotePairs *src) { - for (Vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { + for (std::vector::const_iterator i = src->entries.begin(); i != src->entries.end(); ++i) { if (!hasPair((*i)->name.termedBuf(), (*i)->value.termedBuf())) entries.push_back(new NotePairs::Entry((*i)->name.termedBuf(), (*i)->value.termedBuf())); } diff --git a/src/Notes.h b/src/Notes.h index b6c60af009..274d3bb145 100644 --- a/src/Notes.h +++ b/src/Notes.h @@ -3,7 +3,6 @@ #include "acl/forward.h" #include "base/RefCount.h" -#include "base/Vector.h" #include "CbDataList.h" #include "format/Format.h" #include "MemPool.h" @@ -11,6 +10,7 @@ #include "typedefs.h" #include +#include class HttpRequest; class HttpReply; @@ -38,7 +38,7 @@ public: explicit Value(const String &aVal) : value(aVal), aclList(NULL), valueFormat(NULL) {} ~Value(); }; - typedef Vector Values; + typedef std::vector Values; explicit Note(const String &aKey): key(aKey) {} @@ -68,13 +68,13 @@ class ConfigParser; class Notes { public: - typedef Vector NotesList; + typedef std::vector NotesList; typedef NotesList::iterator iterator; ///< iterates over the notes list typedef NotesList::const_iterator const_iterator; ///< iterates over the notes list Notes(const char *aDescr, const char **metasBlacklist, bool allowFormatted = false): descr(aDescr), blacklisted(metasBlacklist), formattedValues(allowFormatted) {} Notes(): descr(NULL), blacklisted(NULL) {} - ~Notes() { notes.clean(); } + ~Notes() { notes.clear(); } /** * Parse a notes line and returns a pointer to the * parsed Note object. @@ -182,7 +182,7 @@ public: */ bool empty() const {return entries.empty();} - Vector entries; ///< The key/value pair entries + std::vector entries; ///< The key/value pair entries private: NotePairs &operator = (NotePairs const &); // Not implemented diff --git a/src/PeerSelectState.h b/src/PeerSelectState.h index f58885edec..3bd6bd196b 100644 --- a/src/PeerSelectState.h +++ b/src/PeerSelectState.h @@ -35,7 +35,6 @@ #include "AccessLogEntry.h" #include "acl/Checklist.h" -#include "base/Vector.h" #include "cbdata.h" #include "comm/forward.h" #include "hier_code.h" diff --git a/src/StoreFileSystem.cc b/src/StoreFileSystem.cc index 7b3497ed22..fb73ae921c 100644 --- a/src/StoreFileSystem.cc +++ b/src/StoreFileSystem.cc @@ -35,7 +35,7 @@ #include "squid.h" #include "StoreFileSystem.h" -Vector *StoreFileSystem::_FileSystems = NULL; +std::vector *StoreFileSystem::_FileSystems = NULL; void StoreFileSystem::RegisterAllFsWithCacheManager(void) @@ -65,17 +65,17 @@ StoreFileSystem::FsAdd(StoreFileSystem &instance) GetFileSystems().push_back (&instance); } -Vector const & +std::vector const & StoreFileSystem::FileSystems() { return GetFileSystems(); } -Vector & +std::vector & StoreFileSystem::GetFileSystems() { if (!_FileSystems) - _FileSystems = new Vector; + _FileSystems = new std::vector; return *_FileSystems; } @@ -87,7 +87,7 @@ StoreFileSystem::GetFileSystems() void StoreFileSystem::FreeAllFs() { - while (GetFileSystems().size()) { + while (!GetFileSystems().empty()) { StoreFileSystem *fs = GetFileSystems().back(); GetFileSystems().pop_back(); fs->done(); diff --git a/src/StoreFileSystem.h b/src/StoreFileSystem.h index 81dd906bb6..a5410b3c54 100644 --- a/src/StoreFileSystem.h +++ b/src/StoreFileSystem.h @@ -31,7 +31,7 @@ #ifndef SQUID_STOREFILESYSTEM_H #define SQUID_STOREFILESYSTEM_H -#include "base/Vector.h" +#include /* ****** DOCUMENTATION ***** */ @@ -116,9 +116,9 @@ public: static void SetupAllFs(); static void FsAdd(StoreFileSystem &); static void FreeAllFs(); - static Vector const &FileSystems(); - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + static std::vector const &FileSystems(); + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; StoreFileSystem() : initialised(false) {} virtual ~StoreFileSystem() {} @@ -136,8 +136,8 @@ protected: virtual void registerWithCacheManager(void); private: - static Vector &GetFileSystems(); - static Vector *_FileSystems; + static std::vector &GetFileSystems(); + static std::vector *_FileSystems; static void RegisterAllFsWithCacheManager(void); }; diff --git a/src/StoreHashIndex.h b/src/StoreHashIndex.h index 5a33860f48..22460566c7 100644 --- a/src/StoreHashIndex.h +++ b/src/StoreHashIndex.h @@ -117,7 +117,7 @@ private: void *cbdata; bool _done; int bucket; - Vector entries; + std::vector entries; // keep this last. it plays with private/public CBDATA_CLASS2(StoreSearchHashIndex); diff --git a/src/acl/Acl.cc b/src/acl/Acl.cc index 1e925e7542..574d66a9ed 100644 --- a/src/acl/Acl.cc +++ b/src/acl/Acl.cc @@ -41,6 +41,8 @@ #include "profiler/Profiler.h" #include "SquidConfig.h" +#include + const ACLFlag ACLFlags::NoFlags[1] = {ACL_F_END}; const char *AclMatchedName = NULL; @@ -405,7 +407,7 @@ ACL::Prototype::Prototype (ACL const *aPrototype, char const *aType) : prototype registerMe (); } -Vector * ACL::Prototype::Registry; +std::vector * ACL::Prototype::Registry; void *ACL::Prototype::Initialized; bool @@ -429,7 +431,7 @@ ACL::Prototype::registerMe () if (!Registry || (Initialized != ((char *)Registry - 5)) ) { /* TODO: extract this */ /* Not initialised */ - Registry = new Vector ; + Registry = new std::vector; Initialized = (char *)Registry - 5; } diff --git a/src/acl/Acl.h b/src/acl/Acl.h index 1fb45dbe7d..cbefd6423e 100644 --- a/src/acl/Acl.h +++ b/src/acl/Acl.h @@ -34,7 +34,6 @@ #define SQUID_ACL_H #include "acl/forward.h" -#include "base/Vector.h" #include "cbdata.h" #include "defines.h" #include "dlink.h" @@ -42,6 +41,7 @@ #include #include +#include class ConfigParser; @@ -153,10 +153,10 @@ public: char const *typeString; private: - static Vector * Registry; + static std::vector * Registry; static void *Initialized; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; void registerMe(); }; diff --git a/src/acl/NoteData.cc b/src/acl/NoteData.cc index ab4e4cfb67..cb8b032207 100644 --- a/src/acl/NoteData.cc +++ b/src/acl/NoteData.cc @@ -29,7 +29,7 @@ ACLNoteData::matchNotes(NotePairs *note) if (values->empty()) return (note->findFirst(name.termedBuf()) != NULL); - for (Vector::iterator i = note->entries.begin(); i!= note->entries.end(); ++i) { + for (std::vector::iterator i = note->entries.begin(); i!= note->entries.end(); ++i) { if ((*i)->name.cmp(name.termedBuf()) == 0) { if (values->match((*i)->value.termedBuf())) return true; diff --git a/src/adaptation/AccessCheck.cc b/src/adaptation/AccessCheck.cc index 3e50fc67c8..deb36118f9 100644 --- a/src/adaptation/AccessCheck.cc +++ b/src/adaptation/AccessCheck.cc @@ -102,7 +102,7 @@ Adaptation::AccessCheck::check() AccessRule *r = *i; if (isCandidate(*r)) { debugs(93, 5, HERE << "check: rule '" << r->id << "' is a candidate"); - candidates += r->id; + candidates.push_back(r->id); } } @@ -131,7 +131,7 @@ Adaptation::AccessCheck::checkCandidates() return; } - candidates.shift(); // the rule apparently went away (reconfigure) + candidates.erase(candidates.begin()); // the rule apparently went away (reconfigure) } debugs(93, 4, HERE << "NO candidates left"); @@ -176,7 +176,7 @@ Adaptation::AccessCheck::noteAnswer(allow_t answer) } // no match or the group disappeared during reconfiguration - candidates.shift(); + candidates.erase(candidates.begin()); checkCandidates(); } diff --git a/src/adaptation/AccessCheck.h b/src/adaptation/AccessCheck.h index 3a931a8324..ba3add39e4 100644 --- a/src/adaptation/AccessCheck.h +++ b/src/adaptation/AccessCheck.h @@ -39,7 +39,7 @@ private: ACLFilledChecklist *acl_checklist; typedef int Candidate; - typedef Vector Candidates; + typedef std::vector Candidates; Candidates candidates; Candidate topCandidate() const { return *candidates.begin(); } ServiceGroupPointer topGroup() const; // may return nil diff --git a/src/adaptation/AccessRule.h b/src/adaptation/AccessRule.h index 9fae4ded79..a8a2d1a7d6 100644 --- a/src/adaptation/AccessRule.h +++ b/src/adaptation/AccessRule.h @@ -5,6 +5,8 @@ #include "adaptation/forward.h" #include "SquidString.h" +#include + class ConfigParser; namespace Adaptation @@ -34,7 +36,7 @@ private: static Id LastId; }; -typedef Vector AccessRules; +typedef std::vector AccessRules; AccessRules &AllRules(); AccessRule *FindRule(const AccessRule::Id &id); AccessRule *FindRuleByGroupId(const String &groupId); diff --git a/src/adaptation/Config.cc b/src/adaptation/Config.cc index 2794a4cdd2..62f68c3ee5 100644 --- a/src/adaptation/Config.cc +++ b/src/adaptation/Config.cc @@ -36,13 +36,14 @@ #include "adaptation/History.h" #include "adaptation/Service.h" #include "adaptation/ServiceGroups.h" -#include "base/Vector.h" #include "ConfigParser.h" #include "globals.h" #include "HttpReply.h" #include "HttpRequest.h" #include "Store.h" +#include + bool Adaptation::Config::Enabled = false; char *Adaptation::Config::masterx_shared_name = NULL; int Adaptation::Config::service_iteration_limit = 16; @@ -87,15 +88,19 @@ Adaptation::Config::removeService(const String& service) for (SGSI it = services.begin(); it != services.end(); ++it) { if (*it == service) { group->removedServices.push_back(service); - group->services.prune(service); - debugs(93, 5, HERE << "adaptation service " << service << + ServiceGroup::Store::iterator newend; + newend = std::remove(group->services.begin(), group->services.end(), service); + group->services.resize(newend-group->services.begin()); + debugs(93, 5, "adaptation service " << service << " removed from group " << group->id); break; } } if (services.empty()) { removeRule(group->id); - AllGroups().prune(group); + Groups::iterator newend; + newend = std::remove(AllGroups().begin(), AllGroups().end(), group); + AllGroups().resize(newend-AllGroups().begin()); } else { ++i; } @@ -122,8 +127,10 @@ Adaptation::Config::removeRule(const String& id) for (ARI it = rules.begin(); it != rules.end(); ++it) { AccessRule* rule = *it; if (rule->groupId == id) { - debugs(93, 5, HERE << "removing access rules for:" << id); - AllRules().prune(rule); + debugs(93, 5, "removing access rules for:" << id); + AccessRules::iterator newend; + newend = std::remove(AllRules().begin(), AllRules().end(), rule); + AllRules().resize(newend-AllRules().begin()); delete (rule); break; } @@ -139,7 +146,7 @@ Adaptation::Config::clear() const ServiceConfigs& configs = serviceConfigs; for (SCI cfg = configs.begin(); cfg != configs.end(); ++cfg) removeService((*cfg)->key); - serviceConfigs.clean(); + serviceConfigs.clear(); debugs(93, 3, HERE << "rules: " << AllRules().size() << ", groups: " << AllGroups().size() << ", services: " << serviceConfigs.size()); } @@ -163,7 +170,7 @@ Adaptation::Config::freeService() DetachServices(); - serviceConfigs.clean(); + serviceConfigs.clear(); } void @@ -210,7 +217,7 @@ Adaptation::Config::finalize() debugs(93,3, HERE << "Created " << created << " adaptation services"); // services remember their configs; we do not have to - serviceConfigs.clean(); + serviceConfigs.clear(); return true; } diff --git a/src/adaptation/Config.h b/src/adaptation/Config.h index 5da85bebb7..f744ad27f6 100644 --- a/src/adaptation/Config.h +++ b/src/adaptation/Config.h @@ -51,7 +51,7 @@ public: static bool needHistory; ///< HttpRequest adaptation history should recorded - typedef Vector ServiceConfigs; + typedef std::vector ServiceConfigs; ServiceConfigs serviceConfigs; Config(); diff --git a/src/adaptation/DynamicGroupCfg.cc b/src/adaptation/DynamicGroupCfg.cc index f5ebf4a3d7..5d06f78fdd 100644 --- a/src/adaptation/DynamicGroupCfg.cc +++ b/src/adaptation/DynamicGroupCfg.cc @@ -18,5 +18,5 @@ void Adaptation::DynamicGroupCfg::clear() { id.clean(); - services.clean(); + services.clear(); } diff --git a/src/adaptation/DynamicGroupCfg.h b/src/adaptation/DynamicGroupCfg.h index 8f70ee4bf4..efd1523fa2 100644 --- a/src/adaptation/DynamicGroupCfg.h +++ b/src/adaptation/DynamicGroupCfg.h @@ -1,9 +1,10 @@ #ifndef SQUID_ADAPTATION__DYNAMIC_GROUP_CFG_H #define SQUID_ADAPTATION__DYNAMIC_GROUP_CFG_H -#include "base/Vector.h" #include "SquidString.h" +#include + namespace Adaptation { @@ -11,7 +12,7 @@ namespace Adaptation class DynamicGroupCfg { public: - typedef Vector Store; + typedef std::vector Store; typedef String Id; Id id; ///< group id diff --git a/src/adaptation/History.h b/src/adaptation/History.h index b502838b89..614a875c92 100644 --- a/src/adaptation/History.h +++ b/src/adaptation/History.h @@ -3,7 +3,6 @@ #include "adaptation/DynamicGroupCfg.h" #include "base/RefCount.h" -#include "base/Vector.h" #include "HttpHeader.h" #include "Notes.h" #include "SBuf.h" @@ -57,7 +56,7 @@ public: /// AccessLogEntry::notes when ALE becomes available NotePairs::Pointer metaHeaders; - typedef Vector AdaptationServices; + typedef std::vector AdaptationServices; AdaptationServices theAdaptationServices; ///< The service groups used /// sets future services for the Adaptation::AccessCheck to notice @@ -87,7 +86,7 @@ private: bool retried; ///< whether the xaction was replaced by another }; - typedef Vector Entries; + typedef std::vector Entries; Entries theEntries; ///< historical record, in the order of xact starts // theXx* will become a map, but we only support one record diff --git a/src/adaptation/Service.cc b/src/adaptation/Service.cc index 33b60a8b9f..10f1e642e8 100644 --- a/src/adaptation/Service.cc +++ b/src/adaptation/Service.cc @@ -71,6 +71,8 @@ Adaptation::FindService(const Service::Id& key) void Adaptation::DetachServices() { - while (!AllServices().empty()) - AllServices().pop_back()->detach(); + while (!AllServices().empty()) { + AllServices().back()->detach(); + AllServices().pop_back(); + } } diff --git a/src/adaptation/Service.h b/src/adaptation/Service.h index f149ce1f2f..7a020ff4d9 100644 --- a/src/adaptation/Service.h +++ b/src/adaptation/Service.h @@ -61,7 +61,7 @@ private: typedef Service::Pointer ServicePointer; -typedef Vector Services; +typedef std::vector Services; Services &AllServices(); ServicePointer FindService(const Service::Id &key); diff --git a/src/adaptation/ServiceGroups.cc b/src/adaptation/ServiceGroups.cc index ad196bc1a9..28e7d83763 100644 --- a/src/adaptation/ServiceGroups.cc +++ b/src/adaptation/ServiceGroups.cc @@ -48,7 +48,7 @@ Adaptation::ServiceGroup::finalize() } s.cut(s.size() - 1); debugs(93, DBG_IMPORTANT, "Adaptation group '" << id << "' contains disabled member(s) after reconfiguration: " << s); - removedServices.clean(); + removedServices.clear(); } String baselineKey; diff --git a/src/adaptation/ServiceGroups.h b/src/adaptation/ServiceGroups.h index ab7bc6f711..33d56024e1 100644 --- a/src/adaptation/ServiceGroups.h +++ b/src/adaptation/ServiceGroups.h @@ -4,9 +4,10 @@ #include "adaptation/Elements.h" #include "adaptation/forward.h" #include "base/RefCount.h" -#include "base/Vector.h" #include "SquidString.h" +#include + namespace Adaptation { @@ -17,9 +18,9 @@ class ServiceGroup: public RefCountable public: typedef RefCount Pointer; - typedef Vector Store; + typedef std::vector Store; typedef String Id; - typedef unsigned int Pos; // Vector<>::poistion_type + typedef unsigned int Pos; // vector<>::position_type friend class ServicePlan; public: @@ -113,7 +114,7 @@ public: class ServicePlan { public: - typedef unsigned int Pos; // Vector<>::poistion_type + typedef unsigned int Pos; // vector<>::position_type public: ServicePlan(); @@ -141,7 +142,7 @@ std::ostream &operator <<(std::ostream &os, const ServicePlan &p) return p.print(os); } -typedef Vector Groups; +typedef std::vector Groups; Groups &AllGroups(); ServiceGroupPointer FindGroup(const ServiceGroup::Id &id); diff --git a/src/adaptation/icap/Config.cc b/src/adaptation/icap/Config.cc index d66c3f67c9..74506632e0 100644 --- a/src/adaptation/icap/Config.cc +++ b/src/adaptation/icap/Config.cc @@ -33,7 +33,6 @@ #include "squid.h" #include "adaptation/icap/Config.h" #include "adaptation/icap/ServiceRep.h" -#include "base/Vector.h" #include "ConfigParser.h" #include "HttpReply.h" #include "HttpRequest.h" diff --git a/src/adaptation/icap/Options.cc b/src/adaptation/icap/Options.cc index e219a3751c..9524a1ec49 100644 --- a/src/adaptation/icap/Options.cc +++ b/src/adaptation/icap/Options.cc @@ -125,7 +125,7 @@ void Adaptation::Icap::Options::configure(const HttpReply *reply) void Adaptation::Icap::Options::cfgMethod(ICAP::Method m) { Must(m != ICAP::methodNone); - methods += m; + methods.push_back(m); } // TODO: HttpHeader should provide a general method for this type of conversion diff --git a/src/adaptation/icap/Options.h b/src/adaptation/icap/Options.h index 0a0f772cb3..0d7e96c4f3 100644 --- a/src/adaptation/icap/Options.h +++ b/src/adaptation/icap/Options.h @@ -71,7 +71,7 @@ public: const char *error; // human-readable information; set iff !valid() // ICAP server MUST supply this info - Vector methods; + std::vector methods; String istag; // ICAP server MAY supply this info. If not, Squid supplies defaults. diff --git a/src/adaptation/icap/ServiceRep.cc b/src/adaptation/icap/ServiceRep.cc index 16b86f030b..4c4136c04c 100644 --- a/src/adaptation/icap/ServiceRep.cc +++ b/src/adaptation/icap/ServiceRep.cc @@ -375,7 +375,8 @@ void Adaptation::Icap::ServiceRep::noteTimeToNotify() Pointer us = NULL; while (!theClients.empty()) { - Client i = theClients.pop_back(); + Client i = theClients.back(); + theClients.pop_back(); ScheduleCallHere(i.callback); i.callback = 0; } @@ -469,7 +470,7 @@ void Adaptation::Icap::ServiceRep::checkOptions() if (!theOptions->methods.empty()) { bool method_found = false; String method_list; - Vector ::iterator iter = theOptions->methods.begin(); + std::vector ::iterator iter = theOptions->methods.begin(); while (iter != theOptions->methods.end()) { diff --git a/src/adaptation/icap/ServiceRep.h b/src/adaptation/icap/ServiceRep.h index fad4d76eac..2843bff6bd 100644 --- a/src/adaptation/icap/ServiceRep.h +++ b/src/adaptation/icap/ServiceRep.h @@ -140,7 +140,7 @@ private: AsyncCall::Pointer callback; }; - typedef Vector Clients; + typedef std::vector Clients; // TODO: rename to theUpWaiters Clients theClients; // all clients waiting for a call back diff --git a/src/auth/Config.h b/src/auth/Config.h index aa731adfa3..ad4da18ab9 100644 --- a/src/auth/Config.h +++ b/src/auth/Config.h @@ -150,7 +150,7 @@ public: Format::Format *keyExtras; ///< The compiled request format }; -typedef Vector ConfigVector; +typedef std::vector ConfigVector; extern ConfigVector TheConfig; diff --git a/src/auth/Gadgets.cc b/src/auth/Gadgets.cc index f31c9049cd..03c1c2e930 100644 --- a/src/auth/Gadgets.cc +++ b/src/auth/Gadgets.cc @@ -133,7 +133,7 @@ authenticateReset(void) authenticateRotate(); /* free current global config details too. */ - Auth::TheConfig.clean(); + Auth::TheConfig.clear(); } AuthUserHashPointer::AuthUserHashPointer(Auth::User::Pointer anAuth_user): diff --git a/src/auth/Scheme.cc b/src/auth/Scheme.cc index bce72370c4..996f1908d1 100644 --- a/src/auth/Scheme.cc +++ b/src/auth/Scheme.cc @@ -37,7 +37,7 @@ #include "auth/Scheme.h" #include "globals.h" -Vector *Auth::Scheme::_Schemes = NULL; +std::vector *Auth::Scheme::_Schemes = NULL; void Auth::Scheme::AddScheme(Auth::Scheme::Pointer instance) @@ -63,11 +63,11 @@ Auth::Scheme::Find(const char *typestr) return Auth::Scheme::Pointer(NULL); } -Vector & +std::vector & Auth::Scheme::GetSchemes() { if (!_Schemes) - _Schemes = new Vector; + _Schemes = new std::vector; return *_Schemes; } diff --git a/src/auth/Scheme.h b/src/auth/Scheme.h index f5d22fa01f..19d592a375 100644 --- a/src/auth/Scheme.h +++ b/src/auth/Scheme.h @@ -34,7 +34,8 @@ #if USE_AUTH #include "base/RefCount.h" -#include "base/Vector.h" + +#include /** \defgroup AuthSchemeAPI Authentication Scheme API @@ -60,8 +61,8 @@ class Scheme : public RefCountable { public: typedef RefCount Pointer; - typedef Vector::iterator iterator; - typedef Vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; public: Scheme() : initialised (false) {}; @@ -93,13 +94,13 @@ public: Scheme(Scheme const &); Scheme &operator=(Scheme const&); - static Vector &GetSchemes(); + static std::vector &GetSchemes(); protected: bool initialised; private: - static Vector *_Schemes; + static std::vector *_Schemes; }; } // namespace Auth diff --git a/src/base/Makefile.am b/src/base/Makefile.am index 80533ad426..3591294cf8 100644 --- a/src/base/Makefile.am +++ b/src/base/Makefile.am @@ -23,9 +23,7 @@ libbase_la_SOURCES = \ RunnersRegistry.h \ Subscription.h \ TextException.cc \ - TextException.h \ - Vector.cc \ - Vector.h + TextException.h EXTRA_PROGRAMS = \ testCharacterSet diff --git a/src/base/Vector.cc b/src/base/Vector.cc deleted file mode 100644 index afc420aec9..0000000000 --- a/src/base/Vector.cc +++ /dev/null @@ -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 diff --git a/src/base/Vector.h b/src/base/Vector.h deleted file mode 100644 index 5f430955b0..0000000000 --- a/src/base/Vector.h +++ /dev/null @@ -1,455 +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 CLEANUP: this file should be called Vector.h at least, and probably be replaced by STL Vector - */ - -#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; - - void *operator new (size_t); - void operator delete (void *); - - Vector(); - ~Vector(); - Vector(Vector const &); - Vector &operator = (Vector const &); - void clean(); - void reserve (size_t capacity); - void push_back (E); - Vector &operator += (E item) {push_back(item); return *this;}; - - void insert (E); - const E &front() const; - E &front(); - E &back(); - E pop_back(); - E shift(); // aka pop_front - void prune(E); - void preAppend(int app_count); - bool empty() const; - size_t size() const; - iterator begin(); - const_iterator begin () const; - iterator end(); - const_iterator end () const; - E& operator [] (unsigned i); - const E& operator [] (unsigned i) const; - - /* Do not change these, until the entry C struct is removed */ - 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() -{ - clean(); -} - -template -void -Vector::clean() -{ - /* 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 -E -Vector::pop_back() -{ - assert (size()); - value_type result = items[--count]; - items[count] = value_type(); - return result; -} - -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) -{ - clean(); - 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::operator [] (unsigned i) -{ - assert (size() > i); - return items[i]; -} - -template -const E & -Vector::operator [] (unsigned i) const -{ - assert (size() > i); - 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 */ diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 66a1cac899..425e13011d 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -245,7 +245,7 @@ static void free_sslproxy_ssl_bump(acl_access **ssl_bump); static void parse_b_size_t(size_t * var); static void parse_b_int64_t(int64_t * var); -static bool parseNamedIntList(const char *data, const String &name, Vector &list); +static bool parseNamedIntList(const char *data, const String &name, std::vector &list); static void parse_CpuAffinityMap(CpuAffinityMap **const cpuAffinityMap); static void dump_CpuAffinityMap(StoreEntry *const entry, const char *const name, const CpuAffinityMap *const cpuAffinityMap); @@ -462,7 +462,7 @@ parseOneConfigFile(const char *file_name, unsigned int depth) config_lineno = 0; - Vector if_states; + std::vector if_states; while (fgets(config_input_line, BUFSIZ, fp)) { ++config_lineno; @@ -1843,12 +1843,7 @@ static void free_authparam(Auth::ConfigVector * cfg) { /* Wipe the Auth globals and Detach/Destruct component config + state. */ - cfg->clean(); - - /* remove our pointers to the probably-dead sub-configs */ - while (cfg->size()) { - cfg->pop_back(); - } + cfg->clear(); /* on reconfigure initialize new auth schemes for the new config. */ if (reconfiguring) { @@ -1869,7 +1864,7 @@ static int find_fstype(char *type) { for (size_t i = 0; i < StoreFileSystem::FileSystems().size(); ++i) - if (strcasecmp(type, StoreFileSystem::FileSystems().items[i]->type()) == 0) + if (strcasecmp(type, StoreFileSystem::FileSystems().at(i)->type()) == 0) return (int)i; return (-1); @@ -1912,7 +1907,7 @@ parse_cachedir(SquidConfig::_cacheSwap * swap) sd = dynamic_cast(swap->swapDirs[i].getRaw()); - if (strcmp(sd->type(), StoreFileSystem::FileSystems().items[fs]->type()) != 0) { + if (strcmp(sd->type(), StoreFileSystem::FileSystems().at(fs)->type()) != 0) { debugs(3, DBG_CRITICAL, "ERROR: Can't change type of existing cache_dir " << sd->type() << " " << sd->path << " to " << type_str << ". Restart required"); return; @@ -1934,7 +1929,7 @@ parse_cachedir(SquidConfig::_cacheSwap * swap) allocate_new_swapdir(swap); - swap->swapDirs[swap->n_configured] = StoreFileSystem::FileSystems().items[fs]->createSwapDir(); + swap->swapDirs[swap->n_configured] = StoreFileSystem::FileSystems().at(fs)->createSwapDir(); sd = dynamic_cast(swap->swapDirs[swap->n_configured].getRaw()); @@ -4247,7 +4242,7 @@ free_access_log(CustomLog ** definitions) /// parses list of integers form name=N1,N2,N3,... static bool -parseNamedIntList(const char *data, const String &name, Vector &list) +parseNamedIntList(const char *data, const String &name, std::vector &list) { if (data && (strncmp(data, name.rawBuf(), name.size()) == 0)) { data += name.size(); @@ -4280,7 +4275,7 @@ parse_CpuAffinityMap(CpuAffinityMap **const cpuAffinityMap) const char *const pToken = ConfigParser::NextToken(); const char *const cToken = ConfigParser::NextToken(); - Vector processes, cores; + std::vector processes, cores; if (!parseNamedIntList(pToken, "process_numbers", processes)) { debugs(3, DBG_CRITICAL, "FATAL: bad 'process_numbers' parameter " << "in 'cpu_affinity_map'"); diff --git a/src/cbdata.cc b/src/cbdata.cc index a0cf24acb3..ae2827bf1d 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -50,12 +50,13 @@ #include "cbdata.h" #include "mgr/Registration.h" #include "Store.h" -#if USE_CBDATA_DEBUG -#include "Stack.h" -#endif #include "Generic.h" #include +#if USE_CBDATA_DEBUG +#include +#include +#endif #if WITH_VALGRIND #define HASHED_CBDATA 1 @@ -122,7 +123,7 @@ public: 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 */ @@ -207,10 +208,11 @@ cbdata_hash(const void *p, unsigned int mod) cbdata::~cbdata() { #if USE_CBDATA_DEBUG - CBDataCall *aCall; - while ((aCall = calls.pop())) - delete aCall; + while (!calls.empty()) { + delete calls.back(); + calls.pop_back(); + } #endif @@ -314,7 +316,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); @@ -612,8 +614,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; @@ -626,7 +628,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"); } diff --git a/src/client_side.cc b/src/client_side.cc index 115393fc95..a0f95eed00 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1353,7 +1353,7 @@ ClientSocketContext::buildRangeHeader(HttpReply * rep) bool replyMatchRequest = rep->content_range != NULL ? request->range->contains(rep->content_range->spec) : true; - const int spec_count = http->request->range->specs.count; + const int spec_count = http->request->range->specs.size(); int64_t actual_clen = -1; debugs(33, 3, "clientBuildRangeHeader: range spec count: " << @@ -1705,7 +1705,7 @@ ClientSocketContext::canPackMoreRanges() const if (!http->range_iter.debt()) { debugs(33, 5, HERE << "At end of current range spec for " << clientConnection); - if (http->range_iter.pos.incrementable()) + if (http->range_iter.pos != http->range_iter.end) ++http->range_iter.pos; http->range_iter.updateSpec(); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 3125b1e2ca..b2f2beb8f2 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1140,6 +1140,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http) */ node->readBuffer.offset = request->range->lowestOffset(0); http->range_iter.pos = request->range->begin(); + http->range_iter.end = request->range->end(); http->range_iter.valid = true; } } diff --git a/src/comm/AcceptLimiter.cc b/src/comm/AcceptLimiter.cc index 7af4beaaf8..6e144f9308 100644 --- a/src/comm/AcceptLimiter.cc +++ b/src/comm/AcceptLimiter.cc @@ -47,7 +47,8 @@ Comm::AcceptLimiter::kick() debugs(5, 5, "size=" << deferred_.size()); while (deferred_.size() > 0 && fdNFree() >= RESERVED_FD) { /* NP: shift() is equivalent to pop_front(). Giving us a FIFO queue. */ - TcpAcceptor::Pointer temp = deferred_.shift(); + TcpAcceptor::Pointer temp = deferred_.front(); + deferred_.erase(deferred_.begin()); if (temp.valid()) { debugs(5, 5, "doing one."); -- temp->isLimited; diff --git a/src/comm/AcceptLimiter.h b/src/comm/AcceptLimiter.h index 50689efaed..d6c28f3cb6 100644 --- a/src/comm/AcceptLimiter.h +++ b/src/comm/AcceptLimiter.h @@ -1,9 +1,10 @@ #ifndef _SQUID_SRC_COMM_ACCEPT_LIMITER_H #define _SQUID_SRC_COMM_ACCEPT_LIMITER_H -#include "base/Vector.h" #include "comm/TcpAcceptor.h" +#include + namespace Comm { @@ -24,7 +25,7 @@ namespace Comm * or to NULL an entry while scanning the list for empty spaces. * Side effect: TcpAcceptor->kick() becomes allowed to pull off multiple accept()'s in bunches * - * 2) re-implement as a list instead of vector? + * 2) re-implement as a std::queue instead of std::vector * storing head/tail pointers for fast push/pop and avoiding the whole shift() overhead */ class AcceptLimiter @@ -47,7 +48,7 @@ private: static AcceptLimiter Instance_; /** FIFO queue */ - Vector deferred_; + std::vector deferred_; }; }; // namepace Comm diff --git a/src/comm/forward.h b/src/comm/forward.h index 711c546814..caa4e2c6b8 100644 --- a/src/comm/forward.h +++ b/src/comm/forward.h @@ -2,7 +2,8 @@ #define _SQUID_COMM_FORWARD_H #include "base/RefCount.h" -#include "base/Vector.h" + +#include namespace Comm { @@ -11,7 +12,7 @@ class Connection; typedef RefCount ConnectionPointer; -typedef Vector ConnectionList; +typedef std::vector ConnectionList; bool IsConnOpen(const Comm::ConnectionPointer &conn); diff --git a/src/delay_pools.cc b/src/delay_pools.cc index 96489686eb..78b7628946 100644 --- a/src/delay_pools.cc +++ b/src/delay_pools.cc @@ -42,7 +42,6 @@ #include "squid.h" #if USE_DELAY_POOLS -#include "base/Vector.h" #include "client_side_request.h" #include "comm/Connection.h" #include "CommonPool.h" @@ -592,7 +591,7 @@ DelayPools::Update(void *unused) LastUpdate = squid_curtime; - Vector::iterator pos = toUpdate.begin(); + std::vector::iterator pos = toUpdate.begin(); while (pos != toUpdate.end()) { (*pos)->update(incr); @@ -610,7 +609,7 @@ DelayPools::registerForUpdates(Updateable *anObject) void DelayPools::deregisterForUpdates (Updateable *anObject) { - Vector::iterator pos = toUpdate.begin(); + std::vector::iterator pos = toUpdate.begin(); while (pos != toUpdate.end() && *pos != anObject) { ++pos; @@ -618,7 +617,7 @@ DelayPools::deregisterForUpdates (Updateable *anObject) if (pos != toUpdate.end()) { /* move all objects down one */ - Vector::iterator temp = pos; + std::vector::iterator temp = pos; ++pos; while (pos != toUpdate.end()) { @@ -631,7 +630,7 @@ DelayPools::deregisterForUpdates (Updateable *anObject) } } -Vector DelayPools::toUpdate; +std::vector DelayPools::toUpdate; void DelayPools::Stats(StoreEntry * sentry) diff --git a/src/errorpage.cc b/src/errorpage.cc index 4d98ba2e18..c93ffd9d0d 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -119,7 +119,7 @@ error_hard_text[] = { }; /// \ingroup ErrorPageInternal -static Vector ErrorDynamicPages; +static std::vector ErrorDynamicPages; /* local prototypes */ @@ -204,7 +204,7 @@ errorInitialize(void) /** \par * Index any unknown file names used by deny_info. */ - ErrorDynamicPageInfo *info = ErrorDynamicPages.items[i - ERR_MAX]; + ErrorDynamicPageInfo *info = ErrorDynamicPages.at(i - ERR_MAX); assert(info && info->id == i && info->page_name); const char *pg = info->page_name; @@ -245,8 +245,10 @@ errorClean(void) safe_free(error_text); } - while (ErrorDynamicPages.size()) - errorDynamicPageInfoDestroy(ErrorDynamicPages.pop_back()); + while (!ErrorDynamicPages.empty()) { + errorDynamicPageInfoDestroy(ErrorDynamicPages.back()); + ErrorDynamicPages.pop_back(); + } error_page_count = 0; @@ -531,7 +533,7 @@ errorPageId(const char *page_name) } for (size_t j = 0; j < ErrorDynamicPages.size(); ++j) { - if (strcmp(ErrorDynamicPages.items[j]->page_name, page_name) == 0) + if (strcmp(ErrorDynamicPages[j]->page_name, page_name) == 0) return j + ERR_MAX; } @@ -561,7 +563,7 @@ errorPageName(int pageId) return err_type_str[pageId]; if (pageId >= ERR_MAX && pageId - ERR_MAX < (ssize_t)ErrorDynamicPages.size()) - return ErrorDynamicPages.items[pageId - ERR_MAX]->page_name; + return ErrorDynamicPages[pageId - ERR_MAX]->page_name; return "ERR_UNKNOWN"; /* should not happen */ } @@ -593,8 +595,8 @@ ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req) : { memset(&ftp, 0, sizeof(ftp)); - if (page_id >= ERR_MAX && ErrorDynamicPages.items[page_id - ERR_MAX]->page_redirect != Http::scNone) - httpStatus = ErrorDynamicPages.items[page_id - ERR_MAX]->page_redirect; + if (page_id >= ERR_MAX && ErrorDynamicPages[page_id - ERR_MAX]->page_redirect != Http::scNone) + httpStatus = ErrorDynamicPages[page_id - ERR_MAX]->page_redirect; if (req != NULL) { request = req; diff --git a/src/esi/CustomParser.cc b/src/esi/CustomParser.cc index 8f632ca79f..90143b6781 100644 --- a/src/esi/CustomParser.cc +++ b/src/esi/CustomParser.cc @@ -32,12 +32,14 @@ */ #include "squid.h" -#include "base/Vector.h" #include "Debug.h" #include "esi/CustomParser.h" +#include "fatal.h" #include "libTrie/Trie.h" #include "libTrie/TrieCharTransform.h" +#include + Trie *ESICustomParser::SearchTrie=NULL; EsiParserDefinition(ESICustomParser); @@ -147,7 +149,7 @@ ESICustomParser::parse(char const *dataToParse, size_t const lengthOfData, bool *tagEnd = '\0'; - Vectorattributes; + std::vectorattributes; char *attribute = const_cast(endofName + 1); @@ -205,7 +207,8 @@ ESICustomParser::parse(char const *dataToParse, size_t const lengthOfData, bool attribute = end + 1; } - theClient->start (tag + 1, (const char **)attributes.items, attributes.size() >> 1); + // TODO: after c++11, replace &attributes.front() with attributes.data() + theClient->start (tag + 1, const_cast(&attributes.front()), attributes.size() >> 1); /* TODO: attributes */ if (*(tagEnd - 1) == '/') diff --git a/src/esi/VarState.cc b/src/esi/VarState.cc index 13e4f73109..59eddddfab 100644 --- a/src/esi/VarState.cc +++ b/src/esi/VarState.cc @@ -167,8 +167,10 @@ ESIVarState::~ESIVarState() { freeResources(); - while (variablesForCleanup.size()) - delete variablesForCleanup.pop_back(); + while (!variablesForCleanup.empty()) { + delete variablesForCleanup.back(); + variablesForCleanup.pop_back(); + } delete defaultVariable; } diff --git a/src/esi/VarState.h b/src/esi/VarState.h index 7a00daf244..87b4b53ef6 100644 --- a/src/esi/VarState.h +++ b/src/esi/VarState.h @@ -32,11 +32,12 @@ #ifndef SQUID_ESIVARSTATE_H #define SQUID_ESIVARSTATE_H -#include "base/Vector.h" #include "esi/Segment.h" #include "HttpHeader.h" #include "libTrie/Trie.h" +#include + class HttpReply; /* esi variable replacement logic */ @@ -117,7 +118,7 @@ private: void doIt (); void setupUserAgent(); Trie variables; - Vector variablesForCleanup; + std::vector variablesForCleanup; Variable *defaultVariable; }; diff --git a/src/event.h b/src/event.h index 41b7895891..b6d61aea22 100644 --- a/src/event.h +++ b/src/event.h @@ -33,7 +33,6 @@ #define SQUID_EVENT_H #include "AsyncEngine.h" -#include "base/Vector.h" #include "MemPool.h" class StoreEntry; diff --git a/src/fs/rock/RockSwapDir.h b/src/fs/rock/RockSwapDir.h index 22f58493a5..d3d1109a9b 100644 --- a/src/fs/rock/RockSwapDir.h +++ b/src/fs/rock/RockSwapDir.h @@ -145,8 +145,8 @@ protected: virtual void create(); private: - Vector mapOwners; - Vector< Ipc::Mem::Owner *> freeSlotsOwners; + std::vector mapOwners; + std::vector< Ipc::Mem::Owner *> freeSlotsOwners; }; } // namespace Rock diff --git a/src/fs/ufs/UFSSwapDir.cc b/src/fs/ufs/UFSSwapDir.cc index db883a1728..fdd49f30bd 100644 --- a/src/fs/ufs/UFSSwapDir.cc +++ b/src/fs/ufs/UFSSwapDir.cc @@ -226,8 +226,10 @@ Fs::Ufs::UFSSwapDir::changeIO(DiskIOModule *module) IO->io = anIO; /* Change the IO Options */ - if (currentIOOptions && currentIOOptions->options.size() > 2) - delete currentIOOptions->options.pop_back(); + if (currentIOOptions && currentIOOptions->options.size() > 2) { + delete currentIOOptions->options.back(); + currentIOOptions->options.pop_back(); + } /* TODO: factor out these 4 lines */ ConfigOption *ioOptions = IO->io->getOptionTree(); diff --git a/src/ipc/Coordinator.h b/src/ipc/Coordinator.h index 69631380a6..507fe90b21 100644 --- a/src/ipc/Coordinator.h +++ b/src/ipc/Coordinator.h @@ -6,7 +6,6 @@ #ifndef SQUID_IPC_COORDINATOR_H #define SQUID_IPC_COORDINATOR_H -#include "base/Vector.h" #include "ipc/Messages.h" #include "ipc/Port.h" #include "ipc/SharedListen.h" diff --git a/src/ipc/Kids.cc b/src/ipc/Kids.cc index 17c1465144..ffb773a8c9 100644 --- a/src/ipc/Kids.cc +++ b/src/ipc/Kids.cc @@ -19,8 +19,7 @@ Kids::Kids() /// maintain n kids void Kids::init() { - if (storage.size() > 0) - storage.clean(); + storage.clear(); storage.reserve(NumberOfKids()); diff --git a/src/ipc/Kids.h b/src/ipc/Kids.h index 2263189b60..052ae64686 100644 --- a/src/ipc/Kids.h +++ b/src/ipc/Kids.h @@ -4,9 +4,10 @@ #ifndef SQUID_IPC_KIDS_H #define SQUID_IPC_KIDS_H -#include "base/Vector.h" #include "ipc/Kid.h" +#include + /// a collection of kids class Kids { @@ -46,7 +47,7 @@ public: size_t count() const; private: - Vector storage; + std::vector storage; }; extern Kids TheKids; ///< All kids being maintained diff --git a/src/ipc/Queue.h b/src/ipc/Queue.h index eca2ca477c..79a7654788 100644 --- a/src/ipc/Queue.h +++ b/src/ipc/Queue.h @@ -5,7 +5,6 @@ #define SQUID_IPC_QUEUE_H #include "base/InstanceId.h" -#include "base/Vector.h" #include "Debug.h" #include "ipc/AtomicWord.h" #include "ipc/mem/FlexibleArray.h" diff --git a/src/store.cc b/src/store.cc index 6bef925fbe..9715e48c8e 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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" @@ -72,6 +71,7 @@ #endif #include +#include #define REBUILD_TIMESTAMP_DELTA_MAX 2 @@ -124,7 +124,7 @@ static EVH storeLateRelease; /* * local variables */ -static Stack LateReleaseStack; +static std::stack LateReleaseStack; MemAllocator *StoreEntry::pool = NULL; StorePointer Store::CurrentRoot = NULL; @@ -1261,7 +1261,7 @@ StoreEntry::release() // 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 @@ -1289,7 +1289,6 @@ static void storeLateRelease(void *unused) { StoreEntry *e; - int i; static int n = 0; if (StoreController::store_dirs_rebuilding) { @@ -1297,13 +1296,14 @@ storeLateRelease(void *unused) return; } - for (i = 0; i < 10; ++i) { - e = LateReleaseStack.count ? LateReleaseStack.pop() : NULL; - - 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"); diff --git a/src/store_dir.cc b/src/store_dir.cc index 28d1c32a1f..7f9fd38277 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1366,7 +1366,7 @@ StoreSearchHashIndex::next(void (aCallback)(void *), void *aCallbackData) bool StoreSearchHashIndex::next() { - if (entries.size()) + if (!entries.empty()) entries.pop_back(); while (!isDone() && !entries.size()) diff --git a/src/tests/stub_DiskIOModule.cc b/src/tests/stub_DiskIOModule.cc index 457726bc7b..c3136e0bab 100644 --- a/src/tests/stub_DiskIOModule.cc +++ b/src/tests/stub_DiskIOModule.cc @@ -4,10 +4,13 @@ #include "tests/STUB.h" #include "DiskIO/DiskIOModule.h" + +#include + void DiskIOModule::SetupAllModules() STUB void DiskIOModule::ModuleAdd(DiskIOModule &) STUB void DiskIOModule::FreeAllModules() STUB void DiskIOModule::PokeAllModules() STUB DiskIOModule *DiskIOModule::Find(char const *) STUB_RETVAL(NULL) DiskIOModule *DiskIOModule::FindDefault() STUB_RETVAL(NULL) -Vector const &DiskIOModule::Modules() STUB_RETSTATREF(Vector) +std::vector const &DiskIOModule::Modules() STUB_RETSTATREF(std::vector) diff --git a/src/tests/stub_libauth.cc b/src/tests/stub_libauth.cc index a14c3151b7..accf8e90dc 100644 --- a/src/tests/stub_libauth.cc +++ b/src/tests/stub_libauth.cc @@ -21,10 +21,11 @@ AuthUserHashPointer::AuthUserHashPointer(Auth::User::Pointer anAuth_user) STUB Auth::User::Pointer AuthUserHashPointer::user() const STUB_RETVAL(NULL) #include "auth/Scheme.h" -Vector *Auth::Scheme::_Schemes = NULL; +#include +std::vector *Auth::Scheme::_Schemes = NULL; void Auth::Scheme::AddScheme(Auth::Scheme::Pointer) STUB Auth::Scheme::Pointer Auth::Scheme::Find(const char *) STUB_RETVAL(NULL) -Vector & Auth::Scheme::GetSchemes() STUB_RETVAL(*_Schemes); +std::vector & Auth::Scheme::GetSchemes() STUB_RETVAL(*_Schemes); void Auth::Scheme::FreeAll() STUB #include "auth/User.h" diff --git a/src/tests/testVector.cc b/src/tests/testVector.cc deleted file mode 100644 index 725700777d..0000000000 --- a/src/tests/testVector.cc +++ /dev/null @@ -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()); -} diff --git a/src/tests/testVector.h b/src/tests/testVector.h deleted file mode 100644 index f1606db217..0000000000 --- a/src/tests/testVector.h +++ /dev/null @@ -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 diff --git a/src/tests/test_http_range.cc b/src/tests/test_http_range.cc index bbf0544512..160a96beb2 100644 --- a/src/tests/test_http_range.cc +++ b/src/tests/test_http_range.cc @@ -86,7 +86,7 @@ testRangeParser(char const *rangestring) HttpHdrRange copy(*range); - assert (copy.specs.count == range->specs.count); + assert (copy.specs.size() == range->specs.size()); HttpHdrRange::iterator pos = range->begin(); @@ -111,7 +111,7 @@ void testRangeIter () { HttpHdrRange *range=rangeFromString("bytes=0-3, 1-, -2"); - assert (range->specs.count == 3); + assert (range->specs.size() == 3); size_t counter = 0; HttpHdrRange::iterator i = range->begin(); @@ -132,7 +132,7 @@ void testRangeCanonization() { HttpHdrRange *range=rangeFromString("bytes=0-3, 1-, -2"); - assert (range->specs.count == 3); + assert (range->specs.size() == 3); /* 0-3 needs a content length of 4 */ /* This passes in the extant code - but should it? */ @@ -140,13 +140,13 @@ testRangeCanonization() if (!range->canonize(3)) exit(1); - assert (range->specs.count == 3); + assert (range->specs.size() == 3); delete range; range=rangeFromString("bytes=0-3, 1-, -2"); - assert (range->specs.count == 3); + assert (range->specs.size() == 3); /* 0-3 needs a content length of 4 */ if (!range->canonize(4)) @@ -156,7 +156,7 @@ testRangeCanonization() range=rangeFromString("bytes=3-6"); - assert (range->specs.count == 1); + assert (range->specs.size() == 1); /* 3-6 needs a content length of 4 or more */ if (range->canonize(3)) @@ -166,7 +166,7 @@ testRangeCanonization() range=rangeFromString("bytes=3-6"); - assert (range->specs.count == 1); + assert (range->specs.size() == 1); /* 3-6 needs a content length of 4 or more */ if (!range->canonize(4)) @@ -176,12 +176,12 @@ testRangeCanonization() range=rangeFromString("bytes=1-1,2-3"); - assert (range->specs.count == 2); + assert (range->specs.size()== 2); if (!range->canonize(4)) exit(1); - assert (range->specs.count == 2); + assert (range->specs.size() == 2); delete range; } diff --git a/src/tunnel.cc b/src/tunnel.cc index 0ec27ee721..6f9aecd3b4 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -33,7 +33,6 @@ #include "squid.h" #include "acl/FilledChecklist.h" -#include "base/Vector.h" #include "CachePeer.h" #include "client_side.h" #include "client_side_request.h" @@ -234,7 +233,7 @@ TunnelStateData::~TunnelStateData() debugs(26, 3, "TunnelStateData destructed this=" << this); assert(noConnections()); xfree(url); - serverDestinations.clean(); + serverDestinations.clear(); delete connectRespBuf; } @@ -775,7 +774,7 @@ tunnelConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int xe /* At this point only the TCP handshake has failed. no data has been passed. * we are allowed to re-try the TCP-level connection to alternate IPs for CONNECT. */ - tunnelState->serverDestinations.shift(); + tunnelState->serverDestinations.erase(tunnelState->serverDestinations.begin()); if (status != COMM_TIMEOUT && tunnelState->serverDestinations.size() > 0) { /* Try another IP of this destination host */ diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index 010a8bb4fb..6aeb5187d4 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -31,7 +31,6 @@ endif TESTS += debug \ syntheticoperators \ VirtualDeleteOperator \ - StackTest \ splay\ MemPoolTest\ mem_node_test\ @@ -46,7 +45,6 @@ check_PROGRAMS += debug \ mem_node_test\ mem_hdr_test \ splay \ - StackTest \ syntheticoperators \ VirtualDeleteOperator @@ -89,8 +87,6 @@ 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) diff --git a/test-suite/StackTest.cc b/test-suite/StackTest.cc deleted file mode 100644 index 377d899a82..0000000000 --- a/test-suite/StackTest.cc +++ /dev/null @@ -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; -}