#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;
for (; data; data = next) {
next = data->next;
- regfree(&data->regex);
- safe_free(data->pattern);
- memFree(data, MEM_RELIST);
+ delete data;
}
}
}
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;
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)
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);