]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert RegexList to a MEMPROXY_CLASS
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 26 Jul 2015 18:21:19 +0000 (11:21 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 26 Jul 2015 18:21:19 +0000 (11:21 -0700)
src/RegexList.h
src/acl/RegexData.cc
src/mem/forward.h
src/mem/old_api.cc

index e73965895364c9e4481660017f34f65924ac87b8..214d631ba83497d8bcd822a1c8cfc8e2e5b839ac 100644 (file)
@@ -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(&regex); delete next;}
+
     int flags;
     char *pattern;
     regex_t regex;
index 3103b3c8e0c3e22eca6d59ce0b715ceed9dcb0e9..1b1bb00901acfcdde8be729260676863dda8d296 100644 (file)
@@ -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;
 
index 619f293142bf56bd74b17ae2405d953917f48d3f..f87b789030edf31e900347f3fe9ad10a8e5c0a98 100644 (file)
@@ -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)
index bf14bdfeb475cfd0207214a555c93bc27bfa7077..d154fba8a9bd0334790502d8109bfa85c574f559 100644 (file)
@@ -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);