------------------------------------------------------------ revno: 13284 revision-id: kinkie@squid-cache.org-20140219170130-yl3x3li5pxa0vqx0 parent: squid3@treenet.co.nz-20140218135716-kto6e9s0rso04urh committer: Francesco Chemolli branch nick: trunk timestamp: Wed 2014-02-19 18:01:30 +0100 message: Fix uses of std::remove to actually resize the data structures which were cleaned-up. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kinkie@squid-cache.org-20140219170130-yl3x3li5pxa0vqx0 # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 29a7c8da652b5967c0763efdf91757e17ddb5d1c # timestamp: 2014-02-19 17:54:30 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140218135716-\ # kto6e9s0rso04urh # # Begin patch === modified file 'src/HttpHeader.cc' --- src/HttpHeader.cc 2014-02-12 08:51:26 +0000 +++ src/HttpHeader.cc 2014-02-19 17:01:30 +0000 @@ -892,7 +892,10 @@ void HttpHeader::compact() { - std::remove(entries.begin(), entries.end(), static_cast(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()); } /* === modified file 'src/adaptation/Config.cc' --- src/adaptation/Config.cc 2014-02-11 11:30:51 +0000 +++ src/adaptation/Config.cc 2014-02-19 17:01:30 +0000 @@ -88,7 +88,9 @@ for (SGSI it = services.begin(); it != services.end(); ++it) { if (*it == service) { group->removedServices.push_back(service); - std::remove(group->services.begin(), group->services.end(), 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; @@ -96,7 +98,9 @@ } if (services.empty()) { removeRule(group->id); - std::remove(AllGroups().begin(), AllGroups().end(), group); + Groups::iterator newend; + newend = std::remove(AllGroups().begin(), AllGroups().end(), group); + AllGroups().resize(newend-AllGroups().begin()); } else { ++i; } @@ -124,7 +128,9 @@ AccessRule* rule = *it; if (rule->groupId == id) { debugs(93, 5, "removing access rules for:" << id); - std::remove(AllRules().begin(), AllRules().end(), rule); + AccessRules::iterator newend; + newend = std::remove(AllRules().begin(), AllRules().end(), rule); + AllRules().resize(newend-AllRules().begin()); delete (rule); break; }