=== modified file 'lib/MemPoolMalloc.cc' --- lib/MemPoolMalloc.cc 2013-01-14 05:01:04 +0000 +++ lib/MemPoolMalloc.cc 2014-02-02 08:37:10 +0000 @@ -110,33 +110,33 @@ MemPoolMalloc::getStats(MemPoolStats * s 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.count >> (shift ? 8 : 0); + return freelist.size() >> (shift ? 8 : 0); } void MemPoolMalloc::clean(time_t maxage) { while (void *obj = freelist.pop()) { memMeterDec(meter.idle); memMeterDec(meter.alloc); xfree(obj); } } === modified file 'src/ClientDelayConfig.cc' --- src/ClientDelayConfig.cc 2013-05-13 22:48:23 +0000 +++ src/ClientDelayConfig.cc 2014-02-02 09:21:49 +0000 @@ -13,41 +13,41 @@ void ClientDelayPool::dump(StoreEntry * dump_acl_access(entry, nom, access); storeAppendPrintf(entry, "client_delay_parameters %d %d %" PRId64 "\n", poolNumberMinusOne + 1, rate,highwatermark); storeAppendPrintf(entry, "\n"); } void ClientDelayConfig::finalize() { for (unsigned int i = 0; i < pools.size(); ++i) { /* pools require explicit 'allow' to assign a client into them */ if (!pools[i].access) { debugs(77, DBG_IMPORTANT, "client_delay_pool #" << (i+1) << " has no client_delay_access configured. " << "No client will ever use it."); } } } void ClientDelayConfig::freePoolCount() { - pools.clean(); + pools.clear(); } void ClientDelayConfig::dumpPoolCount(StoreEntry * entry, const char *name) const { if (pools.size()) { storeAppendPrintf(entry, "%s %d\n", name, (int)pools.size()); for (unsigned int i = 0; i < pools.size(); ++i) pools[i].dump(entry, i); } } void ClientDelayConfig::parsePoolCount() { if (pools.size()) { debugs(3, DBG_CRITICAL, "parse_client_delay_pool_count: multiple client_delay_pools lines, aborting all previous client_delay_pools config"); clean(); } unsigned short pools_; ConfigParser::ParseUShort(&pools_); for (int i = 0; i < pools_; ++i) { === modified file 'src/ConfigOption.cc' --- src/ConfigOption.cc 2012-09-01 14:38:36 +0000 +++ src/ConfigOption.cc 2014-02-04 18:17:01 +0000 @@ -18,41 +18,41 @@ * 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. * */ #include "squid.h" #include "ConfigOption.h" ConfigOptionVector::~ConfigOptionVector() { - while (options.size()) { + while (!options.empty()) { delete options.back(); options.pop_back(); } } bool ConfigOptionVector::parse(char const *option, const char *value, int isaReconfig) { Vector::iterator i = options.begin(); while (i != options.end()) { if ((*i)->parse(option,value, isaReconfig)) return true; ++i; } return false; } === modified file 'src/DiskIO/DiskIOModule.cc' --- src/DiskIO/DiskIOModule.cc 2013-09-03 09:05:02 +0000 +++ src/DiskIO/DiskIOModule.cc 2014-02-04 18:49:30 +0000 @@ -75,41 +75,41 @@ DiskIOModule::Modules() { return GetModules(); } Vector & DiskIOModule::GetModules() { if (!_Modules) _Modules = new Vector; return *_Modules; } /** * Called when a graceful shutdown is to occur * of each fs module. */ void DiskIOModule::FreeAllModules() { - while (GetModules().size()) { + while (!GetModules().empty()) { DiskIOModule *fs = GetModules().back(); GetModules().pop_back(); fs->gracefulShutdown(); } } DiskIOModule * DiskIOModule::Find(char const *type) { for (iterator i = GetModules().begin(); i != GetModules().end(); ++i) if (strcasecmp(type, (*i)->type()) == 0) return *i; return NULL; } DiskIOModule * DiskIOModule::FindDefault() { /** Best IO options are in order: */ === modified file 'src/ExternalACLEntry.cc' --- src/ExternalACLEntry.cc 2013-11-29 04:41:07 +0000 +++ src/ExternalACLEntry.cc 2014-02-02 09:22:27 +0000 @@ -53,31 +53,31 @@ ExternalACLEntry::ExternalACLEntry() : notes() { lru.next = lru.prev = NULL; result = ACCESS_DENIED; date = 0; def = NULL; } ExternalACLEntry::~ExternalACLEntry() { safe_free(key); } void ExternalACLEntry::update(ExternalACLEntryData const &someData) { date = squid_curtime; result = someData.result; // replace all notes. not combine - notes.entries.clean(); + notes.entries.clear(); notes.append(&someData.notes); #if USE_AUTH user = someData.user; password = someData.password; #endif message = someData.message; tag = someData.tag; log = someData.log; } === modified file 'src/FwdState.cc' --- src/FwdState.cc 2013-12-06 23:52:26 +0000 +++ src/FwdState.cc 2014-02-02 09:23:24 +0000 @@ -95,41 +95,41 @@ static OBJH fwdStats; #define MAX_FWD_STATS_IDX 9 static int FwdReplyCodes[MAX_FWD_STATS_IDX + 1][Http::scInvalidHeader + 1]; static PconnPool *fwdPconnPool = new PconnPool("server-side"); CBDATA_CLASS_INIT(FwdState); void FwdState::abort(void* d) { FwdState* fwd = (FwdState*)d; Pointer tmp = fwd; // Grab a temporary pointer to keep the object alive during our scope. if (Comm::IsConnOpen(fwd->serverConnection())) { comm_remove_close_handler(fwd->serverConnection()->fd, fwdServerClosedWrapper, fwd); debugs(17, 3, HERE << "store entry aborted; closing " << fwd->serverConnection()); fwd->serverConnection()->close(); } else { debugs(17, 7, HERE << "store entry aborted; no connection to close"); } - fwd->serverDestinations.clean(); + fwd->serverDestinations.clear(); fwd->self = NULL; } /**** PUBLIC INTERFACE ********************************************************/ FwdState::FwdState(const Comm::ConnectionPointer &client, StoreEntry * e, HttpRequest * r, const AccessLogEntryPointer &alp): al(alp) { debugs(17, 2, HERE << "Forwarding client request " << client << ", url=" << e->url() ); entry = e; clientConn = client; request = r; HTTPMSGLOCK(request); pconnRace = raceImpossible; start_t = squid_curtime; serverDestinations.reserve(Config.forward_max_tries); e->lock("FwdState"); EBIT_SET(e->flags, ENTRY_FWD_HDR_WAIT); } @@ -260,41 +260,41 @@ FwdState::~FwdState() delete err; entry->unregisterAbort(); entry->unlock("FwdState"); entry = NULL; if (calls.connector != NULL) { calls.connector->cancel("FwdState destructed"); calls.connector = NULL; } if (Comm::IsConnOpen(serverConn)) { comm_remove_close_handler(serverConnection()->fd, fwdServerClosedWrapper, this); debugs(17, 3, HERE << "closing FD " << serverConnection()->fd); serverConn->close(); } - serverDestinations.clean(); + serverDestinations.clear(); debugs(17, 3, HERE << "FwdState destructor done"); } /** * This is the entry point for client-side to start forwarding * a transaction. It is a static method that may or may not * allocate a FwdState. */ void FwdState::Start(const Comm::ConnectionPointer &clientConn, StoreEntry *entry, HttpRequest *request, const AccessLogEntryPointer &al) { /** \note * client_addr == no_addr indicates this is an "internal" request * from peer_digest.c, asn.c, netdb.c, etc and should always * be allowed. yuck, I know. */ if ( Config.accessList.miss && !request->client_addr.isNoAddr() && request->protocol != AnyP::PROTO_INTERNAL && request->protocol != AnyP::PROTO_CACHE_OBJECT) { === modified file 'src/HttpHdrRange.cc' --- src/HttpHdrRange.cc 2013-10-25 00:13:46 +0000 +++ src/HttpHdrRange.cc 2014-02-04 18:17:01 +0000 @@ -249,57 +249,61 @@ HttpHdrRange::parseInit(const String * r int ilen; assert(this && range_spec); ++ParsedCount; debugs(64, 8, "parsing range field: '" << range_spec << "'"); /* check range type */ if (range_spec->caseCmp("bytes=", 6)) return 0; /* skip "bytes="; hack! */ pos = range_spec->termedBuf() + 6; /* iterate through comma separated list */ while (strListGetItem(range_spec, ',', &item, &ilen, &pos)) { HttpHdrRangeSpec *spec = HttpHdrRangeSpec::Create(item, ilen); /* * RFC 2616 section 14.35.1: MUST ignore Range with * 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; } specs.push_back(spec); } debugs(64, 8, "got range specs: " << specs.size()); return !specs.empty(); } HttpHdrRange::~HttpHdrRange() { - while (specs.size()) - delete specs.pop_back(); + while (!specs.empty()) { + delete specs.back(); + specs.pop_back(); + } } HttpHdrRange::HttpHdrRange(HttpHdrRange const &old) : specs(), clen(HttpHdrRangeSpec::UnknownPosition) { specs.reserve(old.specs.size()); for (const_iterator i = old.begin(); i != old.end(); ++i) specs.push_back(new HttpHdrRangeSpec ( **i)); assert(old.specs.size() == specs.size()); } HttpHdrRange::iterator HttpHdrRange::begin() { return specs.begin(); } @@ -324,50 +328,51 @@ HttpHdrRange::end() const void HttpHdrRange::packInto(Packer * packer) const { const_iterator pos = begin(); assert(this); while (pos != end()) { if (pos != begin()) packerAppend(packer, ",", 1); (*pos)->packInto(packer); ++pos; } } void HttpHdrRange::merge (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 */ iterator i = basis.begin(); 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 */ } specs.push_back (*i); ++i; /* progress */ } debugs(64, 3, "HttpHdrRange::merge: had " << basis.size() << " specs, merged " << basis.size() - specs.size() << " specs"); } void HttpHdrRange::getCanonizedSpecs (Vector ©) { /* canonize each entry and destroy bad ones if any */ for (iterator pos (begin()); pos != end(); ++pos) { if ((*pos)->canonize(clen)) copy.push_back (*pos); else @@ -387,48 +392,48 @@ HttpHdrRange::getCanonizedSpecs (Vector< * - all range specs are valid and * - there is at least one range spec */ int HttpHdrRange::canonize(HttpReply *rep) { assert(this && rep); if (rep->content_range) clen = rep->content_range->elength; else clen = rep->content_length; return canonize (clen); } 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; 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 */ /* requires that specs are "canonized" first! */ bool HttpHdrRange::isComplex() const { int64_t offset = 0; assert(this); /* check that all rangers are in "strong" order */ const_iterator pos (begin()); while (pos != end()) { /* Ensure typecasts is safe */ assert ((*pos)->offset >= 0); if ((*pos)->offset < offset) return 1; offset = (*pos)->offset + (*pos)->length; === modified file 'src/HttpHeader.cc' --- src/HttpHeader.cc 2014-01-15 23:57:54 +0000 +++ src/HttpHeader.cc 2014-02-04 18:38:26 +0000 @@ -437,61 +437,61 @@ HttpHeader::clean() { HttpHeaderPos pos = HttpHeaderInitPos; HttpHeaderEntry *e; assert(owner > hoNone && owner < hoEnd); debugs(55, 7, "cleaning hdr: " << this << " owner: " << owner); PROF_start(HttpHeaderClean); if (owner <= hoReply) { /* * An unfortunate bug. The entries array is initialized * such that count is set to zero. httpHeaderClean() seems to * be called both when 'hdr' is created, and destroyed. Thus, * we accumulate a large number of zero counts for 'hdr' before * it is ever used. Can't think of a good way to fix it, except * adding a state variable that indicates whether or not 'hdr' * 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 */ if (e->id < 0 || e->id >= HDR_ENUM_END) { debugs(55, DBG_CRITICAL, "HttpHeader::clean BUG: entry[" << pos << "] is invalid (" << 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); } /* append entries (also see httpHeaderUpdate) */ void HttpHeader::append(const HttpHeader * src) { const HttpHeaderEntry *e; HttpHeaderPos pos = HttpHeaderInitPos; assert(src); assert(src != this); debugs(55, 7, "appending hdr: " << this << " += " << src); while ((e = src->getEntry(&pos))) { addEntry(e->clone()); } } @@ -731,45 +731,45 @@ HttpHeader::packInto(Packer * p, bool ma case HDR_AUTHORIZATION: case HDR_PROXY_AUTHORIZATION: packerAppend(p, e->name.rawBuf(), e->name.size()); packerAppend(p, ": ** NOT DISPLAYED **\r\n", 23); break; default: e->packInto(p); break; } } /* Pack in the "special" entries */ /* Cache-Control */ } /* returns next valid entry */ 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; } /* * returns a pointer to a specified entry if any * note that we return one entry so it does not make much sense to ask for * "list" headers */ HttpHeaderEntry * HttpHeader::findEntry(http_hdr_type id) const { HttpHeaderPos pos = HttpHeaderInitPos; HttpHeaderEntry *e; assert_eid(id); assert(!CBIT_TEST(ListHeadersMask, id)); /* check mask first */ @@ -854,106 +854,106 @@ HttpHeader::delById(http_hdr_type id) while ((e = getEntry(&pos))) { if (e->id == id) delAt(pos, count); } CBIT_CLR(mask, id); assert(count); return count; } /* * deletes an entry at pos and leaves a gap; leaving a gap makes it * possible to iterate(search) and delete fields at the same time * NOTE: Does not update the header mask. Caller must follow up with * a call to refreshMask() if headers_deleted was incremented. */ 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); delete e; ++headers_deleted; } /* * Compacts the header storage */ void HttpHeader::compact() { entries.prune(NULL); } /* * Refreshes the header mask. Required after delAt() calls. */ void HttpHeader::refreshMask() { httpHeaderMaskInit(&mask, 0); debugs(55, 7, "refreshing the mask in hdr " << this); HttpHeaderPos pos = HttpHeaderInitPos; while (HttpHeaderEntry *e = getEntry(&pos)) { CBIT_SET(mask, e->id); } } /* appends an entry; * does not call e->clone() so one should not reuse "*e" */ void HttpHeader::addEntry(HttpHeaderEntry * e) { assert(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; else CBIT_SET(mask, e->id); entries.push_back(e); /* increment header length, allow for ": " and crlf */ len += e->name.size() + 2 + e->value.size() + 2; } /* inserts an entry; * does not call e->clone() so one should not reuse "*e" */ void 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); /* increment header length, allow for ": " and crlf */ len += e->name.size() + 2 + e->value.size() + 2; } bool HttpHeader::getList(http_hdr_type id, String *s) const { HttpHeaderEntry *e; HttpHeaderPos pos = HttpHeaderInitPos; debugs(55, 9, this << " joining for id " << id); /* only fields from ListHeaders array can be "listed" */ assert(CBIT_TEST(ListHeadersMask, id)); === modified file 'src/HttpRequest.cc' --- src/HttpRequest.cc 2013-09-08 04:27:31 +0000 +++ src/HttpRequest.cc 2014-02-04 19:49:24 +0000 @@ -462,41 +462,41 @@ HttpRequest::adaptLogHistory() const { return HttpRequest::adaptHistory(Log::TheConfig.hasAdaptToken); } void HttpRequest::adaptHistoryImport(const HttpRequest &them) { if (!adaptHistory_) { adaptHistory_ = them.adaptHistory_; // may be nil } else { // check that histories did not diverge Must(!them.adaptHistory_ || them.adaptHistory_ == adaptHistory_); } } #endif bool HttpRequest::multipartRangeRequest() const { - return (range && range->specs.count > 1); + return (range && range->specs.size() > 1); } bool HttpRequest::bodyNibbled() const { return body_pipe != NULL && body_pipe->consumedSize() > 0; } void HttpRequest::detailError(err_type aType, int aDetail) { if (errType || errDetail) debugs(11, 5, HERE << "old error details: " << errType << '/' << errDetail); debugs(11, 5, HERE << "current error details: " << aType << '/' << aDetail); // checking type and detail separately may cause inconsistency, but // may result in more details available if they only become available later if (!errType) errType = aType; if (!errDetail) errDetail = aDetail; === modified file 'src/Notes.cc' --- src/Notes.cc 2013-12-05 11:04:45 +0000 +++ src/Notes.cc 2014-02-02 17:16:09 +0000 @@ -129,47 +129,49 @@ Notes::parse(ConfigParser &parser) } void Notes::dump(StoreEntry *entry, const char *key) { typedef Notes::NotesList::iterator AMLI; for (AMLI m = notes.begin(); m != notes.end(); ++m) { typedef Note::Values::iterator VLI; for (VLI v =(*m)->values.begin(); v != (*m)->values.end(); ++v ) { storeAppendPrintf(entry, "%s " SQUIDSTRINGPH " %s", key, SQUIDSTRINGPRINT((*m)->key), ConfigParser::QuoteString((*v)->value)); dump_acl_list(entry, (*v)->aclList); storeAppendPrintf(entry, "\n"); } } } 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 * NotePairs::find(const char *noteKey) const { static String value; value.clean(); for (Vector::const_iterator i = entries.begin(); i != entries.end(); ++i) { if ((*i)->name.cmp(noteKey) == 0) { if (value.size()) value.append(", "); value.append(ConfigParser::QuoteString((*i)->value)); } } return value.size() ? value.termedBuf() : NULL; } const char * NotePairs::toString(const char *sep) const { === modified file 'src/Notes.h' --- src/Notes.h 2013-12-05 11:04:45 +0000 +++ src/Notes.h 2014-02-02 09:07:11 +0000 @@ -59,41 +59,41 @@ public: */ const char *match(HttpRequest *request, HttpReply *reply, const AccessLogEntryPointer &al); String key; ///< The note key Values values; ///< The possible values list for the note }; class ConfigParser; /** * Used to store a notes configuration list. */ class Notes { public: typedef 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. */ Note::Pointer parse(ConfigParser &parser); /** * Dump the notes list to the given StoreEntry object. */ void dump(StoreEntry *entry, const char *name); void clean(); /// clean the notes list /// points to the first argument iterator begin() { return notes.begin(); } /// points to the end of list iterator end() { return notes.end(); } /// return true if the notes list is empty bool empty() { return notes.empty(); } NotesList notes; ///< The Note::Pointer objects array list const char *descr; ///< A short description for notes list === modified file 'src/StoreFileSystem.cc' --- src/StoreFileSystem.cc 2012-09-01 14:38:36 +0000 +++ src/StoreFileSystem.cc 2014-02-04 18:49:35 +0000 @@ -70,31 +70,31 @@ StoreFileSystem::FileSystems() { return GetFileSystems(); } Vector & StoreFileSystem::GetFileSystems() { if (!_FileSystems) _FileSystems = new Vector; return *_FileSystems; } /* * called when a graceful shutdown is to occur * of each fs module. */ void StoreFileSystem::FreeAllFs() { - while (GetFileSystems().size()) { + while (!GetFileSystems().empty()) { StoreFileSystem *fs = GetFileSystems().back(); GetFileSystems().pop_back(); fs->done(); } } /* no filesystem is required to export statistics */ void StoreFileSystem::registerWithCacheManager(void) {} === modified file 'src/adaptation/AccessCheck.cc' --- src/adaptation/AccessCheck.cc 2014-01-11 01:35:50 +0000 +++ src/adaptation/AccessCheck.cc 2014-02-02 08:37:10 +0000 @@ -85,41 +85,41 @@ Adaptation::AccessCheck::usedDynamicRule debugs(85,3, HERE << "using stored service-proposed rules: " << services); ServiceGroupPointer g = new DynamicServiceChain(services, filter); callBack(g); Must(done()); return true; } /// Walk the access rules list to find rules with applicable service groups void Adaptation::AccessCheck::check() { debugs(93, 4, HERE << "start checking"); typedef AccessRules::iterator ARI; for (ARI i = AllRules().begin(); i != AllRules().end(); ++i) { 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); } } checkCandidates(); } // XXX: Here and everywhere we call FindRule(topCandidate()): // Once we identified the candidate, we should not just ignore it // if reconfigure changes rules. We should either lock the rule to // prevent reconfigure from stealing it or restart the check with // new rules. Throwing an exception may also be appropriate. void Adaptation::AccessCheck::checkCandidates() { debugs(93, 4, HERE << "has " << candidates.size() << " rules"); while (!candidates.empty()) { if (AccessRule *r = FindRule(topCandidate())) { /* BUG 2526: what to do when r->acl is empty?? */ // XXX: we do not have access to conn->rfc931 here. === modified file 'src/adaptation/Config.cc' --- src/adaptation/Config.cc 2013-12-05 11:04:45 +0000 +++ src/adaptation/Config.cc 2014-02-02 09:16:51 +0000 @@ -122,65 +122,65 @@ Adaptation::Config::removeRule(const Str 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); delete (rule); break; } } } void Adaptation::Config::clear() { debugs(93, 3, HERE << "rules: " << AllRules().size() << ", groups: " << AllGroups().size() << ", services: " << serviceConfigs.size()); typedef ServiceConfigs::const_iterator SCI; 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()); } void Adaptation::Config::parseService() { ServiceConfigPointer cfg = newServiceConfig(); if (!cfg->parse()) { fatalf("%s:%d: malformed adaptation service configuration", cfg_filename, config_lineno); } serviceConfigs.push_back(cfg); } void Adaptation::Config::freeService() { FreeAccess(); FreeServiceGroups(); DetachServices(); - serviceConfigs.clean(); + serviceConfigs.clear(); } void Adaptation::Config::dumpService(StoreEntry *entry, const char *name) const { typedef Services::iterator SCI; for (SCI i = AllServices().begin(); i != AllServices().end(); ++i) { const ServiceConfig &cfg = (*i)->cfg(); storeAppendPrintf(entry, "%s " SQUIDSTRINGPH "_%s %s %d " SQUIDSTRINGPH "\n", name, SQUIDSTRINGPRINT(cfg.key), cfg.methodStr(), cfg.vectPointStr(), cfg.bypass, SQUIDSTRINGPRINT(cfg.uri)); } } bool Adaptation::Config::finalize() { if (!onoff) { @@ -193,41 +193,41 @@ Adaptation::Config::finalize() typedef ServiceConfigs::const_iterator VISCI; const ServiceConfigs &configs = serviceConfigs; for (VISCI i = configs.begin(); i != configs.end(); ++i) { const ServiceConfigPointer cfg = *i; if (FindService(cfg->key) != NULL) { debugs(93, DBG_CRITICAL, "ERROR: Duplicate adaptation service name: " << cfg->key); continue; // TODO: make fatal } ServicePointer s = createService(cfg); if (s != NULL) { AllServices().push_back(s); ++created; } } debugs(93,3, HERE << "Created " << created << " adaptation services"); // services remember their configs; we do not have to - serviceConfigs.clean(); + serviceConfigs.clear(); return true; } // poor man for_each template static void FinalizeEach(Collection &collection, const char *label) { typedef typename Collection::iterator CI; for (CI i = collection.begin(); i != collection.end(); ++i) (*i)->finalize(); debugs(93,2, HERE << "Initialized " << collection.size() << ' ' << label); } void Adaptation::Config::Finalize(bool enabled) { Enabled = enabled; debugs(93, DBG_IMPORTANT, "Adaptation support is " << (Enabled ? "on" : "off.")); === modified file 'src/adaptation/DynamicGroupCfg.cc' --- src/adaptation/DynamicGroupCfg.cc 2012-01-20 18:55:04 +0000 +++ src/adaptation/DynamicGroupCfg.cc 2014-02-02 09:17:14 +0000 @@ -1,22 +1,22 @@ #include "squid.h" #include "adaptation/DynamicGroupCfg.h" void Adaptation::DynamicGroupCfg::add(const String &item) { if (services.empty()) { // first item id = item; } else { id.append(','); id.append(item); } services.push_back(item); } void Adaptation::DynamicGroupCfg::clear() { id.clean(); - services.clean(); + services.clear(); } === modified file 'src/adaptation/Service.cc' --- src/adaptation/Service.cc 2013-10-25 00:13:46 +0000 +++ src/adaptation/Service.cc 2014-02-04 18:49:21 +0000 @@ -54,23 +54,25 @@ Adaptation::Service::wants(const Service Adaptation::Services & Adaptation::AllServices() { static Services TheServices; return TheServices; } Adaptation::ServicePointer Adaptation::FindService(const Service::Id& key) { typedef Services::iterator SI; for (SI i = AllServices().begin(); i != AllServices().end(); ++i) { if ((*i)->cfg().key == key) return *i; } return NULL; } void Adaptation::DetachServices() { - while (!AllServices().empty()) - AllServices().pop_back()->detach(); + while (!AllServices().empty()) { + AllServices().back()->detach(); + AllServices().pop_back(); + } } === modified file 'src/adaptation/ServiceGroups.cc' --- src/adaptation/ServiceGroups.cc 2013-07-21 19:24:35 +0000 +++ src/adaptation/ServiceGroups.cc 2014-02-02 09:17:50 +0000 @@ -31,41 +31,41 @@ Adaptation::ServiceGroup::parse() services.push_back(i->key); wordlistDestroy(&names); } // Note: configuration code aside, this method is called by DynamicServiceChain void Adaptation::ServiceGroup::finalize() { // 1) warn if services have different methods or vectoring point // 2) warn if all-same services have different bypass status // 3) warn if there are seemingly identical services in the group // TODO: optimize by remembering ServicePointers rather than IDs if (!removedServices.empty()) { String s; for (Store::iterator it = removedServices.begin(); it != removedServices.end(); ++it) { s.append(*it); s.append(','); } 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; bool baselineBypass = false; for (Pos pos = 0; has(pos); ++pos) { // TODO: quit on all errors const String &serviceId = services[pos]; ServicePointer service = at(pos); if (service != NULL) { if (method == methodNone) { // optimization: cache values that should be the same method = service->cfg().method; point = service->cfg().point; } else { if (method != service->cfg().method) finalizeMsg("Inconsistent service method for", serviceId, true); if (point != service->cfg().point) finalizeMsg("Inconsistent vectoring point for", serviceId, true); } === modified file 'src/adaptation/icap/Options.cc' --- src/adaptation/icap/Options.cc 2013-03-18 04:55:51 +0000 +++ src/adaptation/icap/Options.cc 2014-02-02 08:37:10 +0000 @@ -108,41 +108,41 @@ void Adaptation::Icap::Options::configur if (theTimestamp < 0) theTimestamp = squid_curtime; if (h->hasListMember(HDR_ALLOW, "204", ',')) allow204 = true; if (h->hasListMember(HDR_ALLOW, "206", ',')) allow206 = true; cfgIntHeader(h, "Preview", preview); cfgTransferList(h, theTransfers.preview); cfgTransferList(h, theTransfers.ignore); cfgTransferList(h, theTransfers.complete); } 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 void Adaptation::Icap::Options::cfgIntHeader(const HttpHeader *h, const char *fname, int &value) { const String s = h->getByName(fname); if (s.size() && xisdigit(*s.termedBuf())) value = atoi(s.termedBuf()); else value = -1; debugs(93,5, HERE << "int header: " << fname << ": " << value); } void Adaptation::Icap::Options::cfgTransferList(const HttpHeader *h, TransferList &list) { const String buf = h->getByName(list.name); bool foundStar = false; list.parse(buf, foundStar); === modified file 'src/adaptation/icap/ServiceRep.cc' --- src/adaptation/icap/ServiceRep.cc 2014-01-11 01:35:50 +0000 +++ src/adaptation/icap/ServiceRep.cc 2014-02-04 18:49:13 +0000 @@ -358,41 +358,42 @@ static void Adaptation::Icap::ServiceRep_noteTimeToNotify(void *data) { Adaptation::Icap::ServiceRep *service = static_cast(data); Must(service); service->noteTimeToNotify(); } #endif void Adaptation::Icap::ServiceRep::noteTimeToNotify() { Must(!notifying); notifying = true; debugs(93,7, HERE << "notifies " << theClients.size() << " clients " << status()); // note: we must notify even if we are invalidated Pointer us = NULL; while (!theClients.empty()) { - Client i = theClients.pop_back(); + Client i = theClients.back(); + theClients.pop_back(); ScheduleCallHere(i.callback); i.callback = 0; } notifying = false; } void Adaptation::Icap::ServiceRep::callWhenAvailable(AsyncCall::Pointer &cb, bool priority) { debugs(93,8, "ICAPServiceRep::callWhenAvailable"); Must(cb!=NULL); Must(up()); Must(!theIdleConns->count()); // or we should not be waiting Client i; i.service = Pointer(this); i.callback = cb; if (priority) theNotificationWaiters.push_front(i); else === modified file 'src/auth/Gadgets.cc' --- src/auth/Gadgets.cc 2013-12-06 14:59:47 +0000 +++ src/auth/Gadgets.cc 2014-02-02 09:10:36 +0000 @@ -116,36 +116,36 @@ authenticateRotate(void) } void authenticateReset(void) { debugs(29, 2, HERE << "Reset authentication State."); /* free all username cache entries */ hash_first(proxy_auth_username_cache); AuthUserHashPointer *usernamehash; while ((usernamehash = ((AuthUserHashPointer *) hash_next(proxy_auth_username_cache)))) { debugs(29, 5, HERE << "Clearing entry for user: " << usernamehash->user()->username()); hash_remove_link(proxy_auth_username_cache, (hash_link *)usernamehash); delete usernamehash; } /* schedule shutdown of the helpers */ authenticateRotate(); /* free current global config details too. */ - Auth::TheConfig.clean(); + Auth::TheConfig.clear(); } AuthUserHashPointer::AuthUserHashPointer(Auth::User::Pointer anAuth_user): auth_user(anAuth_user) { key = (void *)anAuth_user->userKey(); next = NULL; hash_join(proxy_auth_username_cache, (hash_link *) this); } Auth::User::Pointer AuthUserHashPointer::user() const { return auth_user; } === modified file 'src/base/Vector.h' --- src/base/Vector.h 2014-01-27 02:11:08 +0000 +++ src/base/Vector.h 2014-02-04 18:39:40 +0000 @@ -71,103 +71,106 @@ public: } 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 clean(); + void clear(); 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(); + void pop_back(); E shift(); // aka pop_front void prune(E); void preAppend(int app_count); - bool empty() const; - size_t size() const; + inline bool empty() const; + inline 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; + 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; } - /* Do not change these, until the entry C struct is removed */ +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() { - clean(); + clear(); } template void -Vector::clean() +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; @@ -223,47 +226,46 @@ Vector::insert(E obj) 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 +void 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 & @@ -297,41 +299,41 @@ 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(); + 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; @@ -350,54 +352,68 @@ 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) +Vector::at(unsigned i) { assert (size() > i); return items[i]; } template const E & -Vector::operator [] (unsigned i) const +Vector::at(unsigned i) const { assert (size() > i); return items[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 === modified file 'src/cache_cf.cc' --- src/cache_cf.cc 2014-01-27 03:06:15 +0000 +++ src/cache_cf.cc 2014-02-02 17:14:18 +0000 @@ -1854,67 +1854,62 @@ parse_authparam(Auth::ConfigVector * con if (theScheme == NULL) { debugs(3, DBG_CRITICAL, "Parsing Config File: Unknown authentication scheme '" << type_str << "'."); self_destruct(); } config->push_back(theScheme->createConfig()); schemeCfg = Auth::Config::Find(type_str); if (schemeCfg == NULL) { debugs(3, DBG_CRITICAL, "Parsing Config File: Corruption configuring authentication scheme '" << type_str << "'."); self_destruct(); } } schemeCfg->parse(schemeCfg, config->size(), param_str); } 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) { Auth::Init(); } } static void dump_authparam(StoreEntry * entry, const char *name, Auth::ConfigVector cfg) { for (Auth::ConfigVector::iterator i = cfg.begin(); i != cfg.end(); ++i) (*i)->dump(entry, name, (*i)); } #endif /* USE_AUTH */ /* TODO: just return the object, the # is irrelevant */ 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); } static void parse_cachedir(SquidConfig::_cacheSwap * swap) { char *type_str; char *path_str; RefCount sd; int i; int fs; if ((type_str = ConfigParser::NextToken()) == NULL) self_destruct(); if ((path_str = ConfigParser::NextToken()) == NULL) self_destruct(); @@ -1923,66 +1918,66 @@ parse_cachedir(SquidConfig::_cacheSwap * if (fs < 0) { debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT), "ERROR: This proxy does not support the '" << type_str << "' cache type. Ignoring."); return; } /* reconfigure existing dir */ for (i = 0; i < swap->n_configured; ++i) { assert (swap->swapDirs[i].getRaw()); if ((strcasecmp(path_str, dynamic_cast(swap->swapDirs[i].getRaw())->path)) == 0) { /* this is specific to on-fs Stores. The right * way to handle this is probably to have a mapping * from paths to stores, and have on-fs stores * register with that, and lookip in that in their * own setup logic. RBC 20041225. TODO. */ 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; } sd->reconfigure(); update_maxobjsize(); return; } } /* new cache_dir */ if (swap->n_configured > 63) { /* 7 bits, signed */ debugs(3, DBG_CRITICAL, "WARNING: There is a fixed maximum of 63 cache_dir entries Squid can handle."); debugs(3, DBG_CRITICAL, "WARNING: '" << path_str << "' is one to many."); self_destruct(); return; } 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()); /* parse the FS parameters and options */ sd->parse(swap->n_configured, path_str); ++swap->n_configured; /* Update the max object size */ update_maxobjsize(); } static const char * peer_type_str(const peer_t type) { const char * result; switch (type) { case PEER_PARENT: === modified file 'src/client_side.cc' --- src/client_side.cc 2014-01-05 19:49:23 +0000 +++ src/client_side.cc 2014-02-02 08:37:10 +0000 @@ -1344,41 +1344,41 @@ ClientSocketContext::buildRangeHeader(Ht /* get rid of our range specs on error */ if (range_err) { /* XXX We do this here because we need canonisation etc. However, this current * code will lead to incorrect store offset requests - the store will have the * offset data, but we won't be requesting it. * So, we can either re-request, or generate an error */ debugs(33, 3, "clientBuildRangeHeader: will not do ranges: " << range_err << "."); delete http->request->range; http->request->range = NULL; } else { /* XXX: TODO: Review, this unconditional set may be wrong. */ rep->sline.set(rep->sline.version, Http::scPartialContent); // web server responded with a valid, but unexpected range. // will (try-to) forward as-is. //TODO: we should cope with multirange request/responses 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: " << spec_count << " virgin clen: " << rep->content_length); assert(spec_count > 0); /* append appropriate header(s) */ if (spec_count == 1) { if (!replyMatchRequest) { hdr->delById(HDR_CONTENT_RANGE); hdr->putContRange(rep->content_range); actual_clen = rep->content_length; //http->range_iter.pos = rep->content_range->spec.begin(); (*http->range_iter.pos)->offset = rep->content_range->spec.offset; (*http->range_iter.pos)->length = rep->content_range->spec.length; } else { HttpHdrRange::iterator pos = http->request->range->begin(); assert(*pos); /* append Content-Range */ === modified file 'src/errorpage.cc' --- src/errorpage.cc 2014-01-20 01:20:40 +0000 +++ src/errorpage.cc 2014-02-04 19:51:24 +0000 @@ -189,83 +189,85 @@ errorInitialize(void) safe_free(error_text[i]); if ((text = errorFindHardText(i))) { /**\par * Index any hard-coded error text into defaults. */ error_text[i] = xstrdup(text); } else if (i < ERR_MAX) { /**\par * Index precompiled fixed template files from one of two sources: * (a) default language translation directory (error_default_language) * (b) admin specified custom directory (error_directory) */ ErrorPageFile errTmpl(err_type_str[i], i); error_text[i] = errTmpl.loadDefault() ? xstrdup(errTmpl.text()) : NULL; } else { /** \par * Index any unknown file names used by deny_info. */ - ErrorDynamicPageInfo *info = ErrorDynamicPages.items[i - ERR_MAX]; + ErrorDynamicPageInfo *info = ErrorDynamicPages[i - ERR_MAX]; assert(info && info->id == i && info->page_name); const char *pg = info->page_name; if (info->page_redirect != Http::scNone) pg = info->page_name +4; if (strchr(pg, ':') == NULL) { /** But only if they are not redirection URL. */ ErrorPageFile errTmpl(pg, ERR_MAX); error_text[i] = errTmpl.loadDefault() ? xstrdup(errTmpl.text()) : NULL; } } } error_stylesheet.reset(); // look for and load stylesheet into global MemBuf for it. if (Config.errorStylesheet) { ErrorPageFile tmpl("StylesSheet", ERR_MAX); tmpl.loadFromFile(Config.errorStylesheet); error_stylesheet.Printf("%s",tmpl.text()); } #if USE_SSL Ssl::errorDetailInitialize(); #endif } void errorClean(void) { if (error_text) { int i; for (i = ERR_NONE + 1; i < error_page_count; ++i) safe_free(error_text[i]); safe_free(error_text); } - while (ErrorDynamicPages.size()) - errorDynamicPageInfoDestroy(ErrorDynamicPages.pop_back()); + while (!ErrorDynamicPages.empty()) { + errorDynamicPageInfoDestroy(ErrorDynamicPages.back()); + ErrorDynamicPages.pop_back(); + } error_page_count = 0; #if USE_SSL Ssl::errorDetailClean(); #endif } /// \ingroup ErrorPageInternal static const char * errorFindHardText(err_type type) { int i; for (i = 0; i < error_hard_text_count; ++i) if (error_hard_text[i].type == type) return error_hard_text[i].text; return NULL; } @@ -516,104 +518,104 @@ errorDynamicPageInfoCreate(int id, const /// \ingroup ErrorPageInternal static void errorDynamicPageInfoDestroy(ErrorDynamicPageInfo * info) { assert(info); safe_free(info->page_name); delete info; } /// \ingroup ErrorPageInternal static int errorPageId(const char *page_name) { for (int i = 0; i < ERR_MAX; ++i) { if (strcmp(err_type_str[i], page_name) == 0) return i; } 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; } return ERR_NONE; } err_type errorReservePageId(const char *page_name) { ErrorDynamicPageInfo *info; int id = errorPageId(page_name); if (id == ERR_NONE) { info = errorDynamicPageInfoCreate(ERR_MAX + ErrorDynamicPages.size(), page_name); ErrorDynamicPages.push_back(info); id = info->id; } return (err_type)id; } /// \ingroup ErrorPageInternal const char * errorPageName(int pageId) { if (pageId >= ERR_NONE && pageId < ERR_MAX) /* common case */ 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 */ } ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req) : type(t), page_id(t), err_language(NULL), httpStatus(status), #if USE_AUTH auth_user_request (NULL), #endif request(NULL), url(NULL), xerrno(0), port(0), dnsError(), ttl(0), src_addr(), redirect_url(NULL), callback(NULL), callback_data(NULL), request_hdrs(NULL), err_msg(NULL), #if USE_SSL detail(NULL), #endif detailCode(ERR_DETAIL_NONE) { 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; HTTPMSGLOCK(request); src_addr = req->client_addr; } } void errorAppendEntry(StoreEntry * entry, ErrorState * err) { assert(entry->mem_obj != NULL); assert (entry->isEmpty()); debugs(4, 4, "Creating an error page for entry " << entry << " with errorstate " << err << " page id " << err->page_id); if (entry->store_status != STORE_PENDING) { debugs(4, 2, "Skipping error page due to store_status: " << entry->store_status); /* === modified file 'src/esi/CustomParser.cc' --- src/esi/CustomParser.cc 2013-10-25 00:13:46 +0000 +++ src/esi/CustomParser.cc 2014-02-04 19:55:30 +0000 @@ -188,41 +188,41 @@ ESICustomParser::parse(char const *dataT error = "Unknown identifier ("; error.append (sep); error.append (")"); return false; } char *value = equals + 1; char *end = strchr(value, sep); if (!end) { error = "Missing attribute ending separator ("; error.append(sep); error.append(")"); return false; } attributes.push_back(value); *end = '\0'; attribute = end + 1; } - theClient->start (tag + 1, (const char **)attributes.items, attributes.size() >> 1); + theClient->start (tag + 1, const_cast(attributes.data()), attributes.size() >> 1); /* TODO: attributes */ if (*(tagEnd - 1) == '/') theClient->end (tag + 1); remainingCount -= tagEnd - currentPos + 1; currentPos = tagEnd + 1; } break; case ESIENDTAG: { if (!openESITags) return false; char const *tagEnd = strchr(tag, '>'); if (!tagEnd) return false; === modified file 'src/esi/VarState.cc' --- src/esi/VarState.cc 2012-11-19 11:29:31 +0000 +++ src/esi/VarState.cc 2014-02-04 18:17:01 +0000 @@ -150,42 +150,44 @@ ESIVarState::extractChar () ESISegmentFreeList (output); debugs(86, 6, "ESIVarStateExtractList: Extracted char"); return rv; } /* ESIVarState */ void esiVarStateFree (void *data) { ESIVarState *thisNode = (ESIVarState*)data; thisNode->freeResources(); } ESIVarState::~ESIVarState() { freeResources(); - while (variablesForCleanup.size()) - delete variablesForCleanup.pop_back(); + while (!variablesForCleanup.empty()) { + delete variablesForCleanup.back(); + variablesForCleanup.pop_back(); + } delete defaultVariable; } void ESIVarState::freeResources() { input = NULL; ESISegmentFreeList (output); hdr.clean(); } void * ESIVarState::operator new(size_t byteCount) { assert (byteCount == sizeof (ESIVarState)); void *rv; CBDATA_INIT_TYPE_FREECB(ESIVarState, esiVarStateFree); rv = (void *)cbdataAlloc (ESIVarState); return rv; === modified file 'src/fs/ufs/UFSSwapDir.cc' --- src/fs/ufs/UFSSwapDir.cc 2013-12-06 23:52:26 +0000 +++ src/fs/ufs/UFSSwapDir.cc 2014-02-02 17:14:17 +0000 @@ -213,42 +213,44 @@ Fs::Ufs::UFSSwapDir::parse (int anIndex, parseSizeL1L2(); /* Initialise replacement policy stuff */ repl = createRemovalPolicy(Config.replPolicy); parseOptions(0); } void Fs::Ufs::UFSSwapDir::changeIO(DiskIOModule *module) { DiskIOStrategy *anIO = module->createStrategy(); safe_free(ioType); ioType = xstrdup(module->type()); delete IO->io; 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(); if (currentIOOptions && ioOptions) currentIOOptions->options.push_back(ioOptions); } bool Fs::Ufs::UFSSwapDir::optionIOParse(char const *option, const char *value, int isaReconfig) { if (strcmp(option, "IOEngine") != 0) return false; if (isaReconfig) /* silently ignore this */ return true; if (!value) self_destruct(); === modified file 'src/ipc/Kids.cc' --- src/ipc/Kids.cc 2013-10-25 00:13:46 +0000 +++ src/ipc/Kids.cc 2014-02-02 09:11:59 +0000 @@ -2,42 +2,41 @@ * DEBUG: section 54 Interprocess Communication */ #include "squid.h" #include "base/TextException.h" #include "globals.h" #include "ipc/Kids.h" #include "SquidConfig.h" #include "tools.h" Kids TheKids; KidName TheKidName; Kids::Kids() { } /// maintain n kids void Kids::init() { - if (storage.size() > 0) - storage.clean(); + storage.clear(); storage.reserve(NumberOfKids()); char kid_name[32]; // add Kid records for all workers for (int i = 0; i < Config.workers; ++i) { snprintf(kid_name, sizeof(kid_name), "(squid-%d)", (int)(storage.size()+1)); storage.push_back(Kid(kid_name)); } // add Kid records for all disk processes for (int i = 0; i < Config.cacheSwap.n_strands; ++i) { snprintf(kid_name, sizeof(kid_name), "(squid-disk-%d)", (int)(storage.size()+1)); storage.push_back(Kid(kid_name)); } // if coordination is needed, add a Kid record for Coordinator if (storage.size() > 1) { snprintf(kid_name, sizeof(kid_name), "(squid-coord-%d)", (int)(storage.size()+1)); === modified file 'src/store.cc' --- src/store.cc 2014-01-03 10:32:53 +0000 +++ src/store.cc 2014-02-02 08:37:10 +0000 @@ -1273,41 +1273,41 @@ StoreEntry::release() 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; } for (i = 0; i < 10; ++i) { - e = LateReleaseStack.count ? LateReleaseStack.pop() : NULL; + e = LateReleaseStack.empty() ? NULL : 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; === modified file 'src/store_dir.cc' --- src/store_dir.cc 2013-12-31 18:49:41 +0000 +++ src/store_dir.cc 2014-02-04 18:17:01 +0000 @@ -1353,41 +1353,41 @@ StoreSearchHashIndex::StoreSearchHashInd bucket(0) {} /* do not link StoreSearchHashIndex::StoreSearchHashIndex(StoreSearchHashIndex const &); */ StoreSearchHashIndex::~StoreSearchHashIndex() {} void StoreSearchHashIndex::next(void (aCallback)(void *), void *aCallbackData) { next(); aCallback (aCallbackData); } bool StoreSearchHashIndex::next() { - if (entries.size()) + if (!entries.empty()) entries.pop_back(); while (!isDone() && !entries.size()) copyBucket(); return currentItem() != NULL; } bool StoreSearchHashIndex::error() const { return false; } bool StoreSearchHashIndex::isDone() const { return bucket >= store_hash_buckets || _done; } === modified file 'src/tests/test_http_range.cc' --- src/tests/test_http_range.cc 2013-10-25 00:13:46 +0000 +++ src/tests/test_http_range.cc 2014-02-02 08:37:10 +0000 @@ -69,136 +69,136 @@ int httpHeaderHas(const HttpHeader * hdr fatal ("dummy function\n"); return 0; } void httpHeaderPutContRange(HttpHeader * hdr, const HttpHdrContRange * cr) { fatal ("dummy function\n"); } void testRangeParser(char const *rangestring) { String aString (rangestring); HttpHdrRange *range = HttpHdrRange::ParseCreate (&aString); if (!range) exit (1); HttpHdrRange copy(*range); - assert (copy.specs.count == range->specs.count); + assert (copy.specs.size() == range->specs.size()); HttpHdrRange::iterator pos = range->begin(); assert (*pos); delete range; } HttpHdrRange * rangeFromString(char const *rangestring) { String aString (rangestring); HttpHdrRange *range = HttpHdrRange::ParseCreate (&aString); if (!range) exit (1); return range; } 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(); while (i != range->end()) { ++counter; ++i; } assert (counter == 3); i = range->begin(); assert (i - range->begin() == 0); ++i; assert (i - range->begin() == 1); assert (i - range->end() == -2); } 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? */ 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)) exit(1); delete range; 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)) exit(1); delete range; 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)) exit(1); delete range; 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; } int main(int argc, char **argv) { try { Mem::Init(); /* enable for debugging to console */ // _db_init (NULL, NULL); // Debug::Levels[64] = 9; testRangeParser("bytes=0-3"); testRangeParser("bytes=-3"); testRangeParser("bytes=1-"); testRangeParser("bytes=0-3, 1-, -2"); testRangeIter(); testRangeCanonization(); } catch (const std::exception &e) { printf("Error: dying from an unhandled exception: %s\n", e.what()); === modified file 'src/tunnel.cc' --- src/tunnel.cc 2013-12-06 14:59:47 +0000 +++ src/tunnel.cc 2014-02-02 09:34:32 +0000 @@ -221,41 +221,41 @@ tunnelClientClosed(const CommCloseCbPara tunnelState->server.conn->close(); return; } } TunnelStateData::TunnelStateData() : url(NULL), request(NULL), status_ptr(NULL), connectRespBuf(NULL), connectReqWriting(false) { debugs(26, 3, "TunnelStateData constructed this=" << this); } TunnelStateData::~TunnelStateData() { debugs(26, 3, "TunnelStateData destructed this=" << this); assert(noConnections()); xfree(url); - serverDestinations.clean(); + serverDestinations.clear(); delete connectRespBuf; } TunnelStateData::Connection::~Connection() { safe_free(buf); } int TunnelStateData::Connection::bytesWanted(int lowerbound, int upperbound) const { #if USE_DELAY_POOLS return delayId.bytesWanted(lowerbound, upperbound); #else return upperbound; #endif } void