From: Francesco Chemolli Date: Tue, 30 Dec 2014 21:58:43 +0000 (+0100) Subject: Fixed Acl::HttpStatus X-Git-Tag: merge-candidate-3-v1~384^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ac36eabcf0be87f756b1d82022de081db9a58cd;p=thirdparty%2Fsquid.git Fixed Acl::HttpStatus --- diff --git a/src/acl/HttpStatus.cc b/src/acl/HttpStatus.cc index 5c496d5272..b55ef528d2 100644 --- a/src/acl/HttpStatus.cc +++ b/src/acl/HttpStatus.cc @@ -17,9 +17,9 @@ #include -static void aclParseHTTPStatusList(SplayNode **curlist); +static void aclParseHTTPStatusList(Splay **curlist); static int aclHTTPStatusCompare(acl_httpstatus_data * const &a, acl_httpstatus_data * const &b); -static int aclMatchHTTPStatus(SplayNode **dataptr, Http::StatusCode status); +static int aclMatchHTTPStatus(Splay **dataptr, Http::StatusCode status); acl_httpstatus_data::acl_httpstatus_data(int x) : status1(x), status2(x) { ; } @@ -75,7 +75,7 @@ ACLHTTPStatus::ACLHTTPStatus (ACLHTTPStatus const & old) : data(NULL), class_ (o ACLHTTPStatus::~ACLHTTPStatus() { if (data) - data->destroy(SplayNode::DefaultFree); + data->destroy(); } char const * @@ -113,17 +113,16 @@ ACLHTTPStatus::parse() } void -aclParseHTTPStatusList(SplayNode **curlist) +aclParseHTTPStatusList(Splay **curlist) { char *t = NULL; - SplayNode **Top = curlist; acl_httpstatus_data *q = NULL; while ((t = strtokFile())) { if ((q = aclParseHTTPStatusData(t)) == NULL) continue; - *Top = (*Top)->insert(q, acl_httpstatus_data::compare); + (*curlist)->insert(q, acl_httpstatus_data::compare); } } @@ -134,15 +133,13 @@ ACLHTTPStatus::match(ACLChecklist *checklist) } int -aclMatchHTTPStatus(SplayNode **dataptr, const Http::StatusCode status) +aclMatchHTTPStatus(Splay **dataptr, const Http::StatusCode status) { - acl_httpstatus_data X(status); - SplayNode **Top = dataptr; - *Top = Top[0]->splay(&X, aclHTTPStatusCompare); + const acl_httpstatus_data * const * result = (*dataptr)->find(&X, aclHTTPStatusCompare); - debugs(28, 3, "aclMatchHTTPStatus: '" << status << "' " << (splayLastResult ? "NOT found" : "found")); - return (0 == splayLastResult); + debugs(28, 3, "aclMatchHTTPStatus: '" << status << "' " << (result ? "found" : "NOT found")); + return (result != NULL); } static int @@ -157,18 +154,18 @@ aclHTTPStatusCompare(acl_httpstatus_data * const &a, acl_httpstatus_data * const return 0; } -static void -aclDumpHTTPStatusListWalkee(acl_httpstatus_data * const &node, void *state) -{ - // state is a SBufList* - static_cast(state)->push_back(node->toStr()); -} +struct HttpStatusAclDumpVisitor { + SBufList contents; + void operator() (const acl_httpstatus_data * node) { + contents.push_back(node->toStr()); + } +}; SBufList ACLHTTPStatus::dump() const { - SBufList w; - data->walk(aclDumpHTTPStatusListWalkee, &w); - return w; + HttpStatusAclDumpVisitor visitor; + data->visit(visitor); + return visitor.contents; } diff --git a/src/acl/HttpStatus.h b/src/acl/HttpStatus.h index 8be1302480..be1a878144 100644 --- a/src/acl/HttpStatus.h +++ b/src/acl/HttpStatus.h @@ -45,7 +45,7 @@ public: protected: static Prototype RegistryProtoype; static ACLHTTPStatus RegistryEntry_; - SplayNode *data; + Splay *data; char const *class_; };