From: Amos Jeffries Date: Sun, 26 Jul 2015 18:21:19 +0000 (-0700) Subject: Convert RegexList to a MEMPROXY_CLASS X-Git-Tag: merge-candidate-3-v1~24^2~2^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d240b2bf1f7b917e92140e9304e236a9b22d3ca7;p=thirdparty%2Fsquid.git Convert RegexList to a MEMPROXY_CLASS --- diff --git a/src/RegexList.h b/src/RegexList.h index e739658953..214d631ba8 100644 --- a/src/RegexList.h +++ b/src/RegexList.h @@ -9,10 +9,20 @@ #ifndef SQUID_REGEXLIST_H_ #define SQUID_REGEXLIST_H_ -/// list of regular expressions. Currently a POD. +#include "mem/forward.h" + +/// list of regular expressions. class RegexList { + MEMPROXY_CLASS(RegexList); + public: + RegexList() = delete; + RegexList(int aFlags, const char *aPattern) : flags(aFlags), pattern(xstrdup(aPattern)), next(nullptr) {} + RegexList(const RegexList &) = delete; + RegexList(const RegexList &&) = delete; + ~RegexList() {xfree(pattern); regfree(®ex); delete next;} + int flags; char *pattern; regex_t regex; diff --git a/src/acl/RegexData.cc b/src/acl/RegexData.cc index 3103b3c8e0..1b1bb00901 100644 --- a/src/acl/RegexData.cc +++ b/src/acl/RegexData.cc @@ -30,9 +30,7 @@ aclDestroyRegexList(RegexList * data) for (; data; data = next) { next = data->next; - regfree(&data->regex); - safe_free(data->pattern); - memFree(data, MEM_RELIST); + delete data; } } @@ -151,10 +149,8 @@ compileRE(RegexList **Tail, char * RE, int flags) } debugs(28, 2, "compileRE: compiled '" << RE << "' with flags " << flags ); - q = (RegexList *) memAllocate(MEM_RELIST); - q->pattern = xstrdup(RE); + q = new RegexList(flags, RE); q->regex = comp; - q->flags = flags; *(Tail) = q; Tail = &q->next; diff --git a/src/mem/forward.h b/src/mem/forward.h index 619f293142..f87b789030 100644 --- a/src/mem/forward.h +++ b/src/mem/forward.h @@ -56,7 +56,6 @@ typedef enum { MEM_MD5_DIGEST, MEM_NETDBENTRY, MEM_NET_DB_NAME, - MEM_RELIST, // IMPORTANT: leave this here. pools above are initialized early with memInit() MEM_DONTFREE, // following pools are initialized late by their component if needed (or never) diff --git a/src/mem/old_api.cc b/src/mem/old_api.cc index bf14bdfeb4..d154fba8a9 100644 --- a/src/mem/old_api.cc +++ b/src/mem/old_api.cc @@ -445,7 +445,6 @@ Mem::Init(void) memDataInit(MEM_HTTP_HDR_CONTENT_RANGE, "HttpHdrContRange", sizeof(HttpHdrContRange), 0); memDataInit(MEM_NETDBENTRY, "netdbEntry", sizeof(netdbEntry), 0); memDataInit(MEM_NET_DB_NAME, "net_db_name", sizeof(net_db_name), 0); - memDataInit(MEM_RELIST, "RegexList", sizeof(RegexList), 0); memDataInit(MEM_CLIENT_INFO, "ClientInfo", sizeof(ClientInfo), 0); memDataInit(MEM_MD5_DIGEST, "MD5 digest", SQUID_MD5_DIGEST_LENGTH, 0); MemPools[MEM_MD5_DIGEST]->setChunkSize(512 * 1024);