]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: migrate AclSizeLimit to CBDATA_CLASS API
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 2 Feb 2015 20:02:55 +0000 (12:02 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 2 Feb 2015 20:02:55 +0000 (12:02 -0800)
src/acl/AclSizeLimit.cc [new file with mode: 0644]
src/acl/AclSizeLimit.h
src/acl/Makefile.am
src/cache_cf.cc

diff --git a/src/acl/AclSizeLimit.cc b/src/acl/AclSizeLimit.cc
new file mode 100644 (file)
index 0000000..0679474
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+#include "acl/AclSizeLimit.h"
+#include "acl/Gadgets.h"
+
+CBDATA_CLASS_INIT(AclSizeLimit);
+
+AclSizeLimit::~AclSizeLimit()
+{
+    aclDestroyAclList(&aclList);
+    delete next;
+}
index 9b59d649bbba266defb70ceef7d0d0867c2bfed7..3ef314b661384b1d456e383c72d2c000b77431fe 100644 (file)
 #define SQUID_ACLSIZELIMIT_H_
 
 #include "acl/forward.h"
+#include "cbdata.h"
 
 /// representation of a class of Size-limit ACLs
-// a POD. TODO: convert to new ACL framework
 class AclSizeLimit
 {
+    CBDATA_CLASS(AclSizeLimit);
+
 public:
+    AclSizeLimit() : next(NULL), aclList(NULL), size(0) {}
+   ~AclSizeLimit();
+
     AclSizeLimit *next;
     ACLList *aclList;
     int64_t size;
index a7e97f5167bc3a25c7e83b20f4a2ede50f6237af..61117c66be555fbe2e3a41f345846c715e8be67f 100644 (file)
@@ -136,6 +136,7 @@ libacls_la_SOURCES = \
        AclDenyInfoList.h \
        Gadgets.cc \
        Gadgets.h \
+       AclSizeLimit.cc \
        AclSizeLimit.h
 
 ## Add conditional sources
index 6cd55985df413e9d5d7ea7d71563386d47319656..92fc0a0deb3b98ac90e668c605799f4689d436f4 100644 (file)
@@ -1510,14 +1510,10 @@ free_acl_nfmark(acl_nfmark ** head)
 }
 #endif /* SO_MARK */
 
-CBDATA_TYPE(AclSizeLimit);
-
 static void
 dump_acl_b_size_t(StoreEntry * entry, const char *name, AclSizeLimit * head)
 {
-    AclSizeLimit *l;
-
-    for (l = head; l; l = l->next) {
+    for (AclSizeLimit *l = head; l; l = l->next) {
         if (l->size != -1)
             storeAppendPrintf(entry, "%s %d %s\n", name, (int) l->size, B_BYTES_STR);
         else
@@ -1529,27 +1525,16 @@ dump_acl_b_size_t(StoreEntry * entry, const char *name, AclSizeLimit * head)
     }
 }
 
-static void
-freed_acl_b_size_t(void *data)
-{
-    AclSizeLimit *l = static_cast<AclSizeLimit *>(data);
-    aclDestroyAclList(&l->aclList);
-}
-
 static void
 parse_acl_b_size_t(AclSizeLimit ** head)
 {
-    AclSizeLimit *l;
-    AclSizeLimit **tail = head; /* sane name below */
-
-    CBDATA_INIT_TYPE_FREECB(AclSizeLimit, freed_acl_b_size_t);
-
-    l = cbdataAlloc(AclSizeLimit);
+    AclSizeLimit *l = new AclSizeLimit;
 
     parse_b_int64_t(&l->size);
 
     aclParseAclList(LegacyParser, &l->aclList, l->size);
 
+    AclSizeLimit **tail = head; /* sane name below */
     while (*tail)
         tail = &(*tail)->next;
 
@@ -1559,12 +1544,8 @@ parse_acl_b_size_t(AclSizeLimit ** head)
 static void
 free_acl_b_size_t(AclSizeLimit ** head)
 {
-    while (*head) {
-        AclSizeLimit *l = *head;
-        *head = l->next;
-        l->next = NULL;
-        cbdataFree(l);
-    }
+    delete *head;
+    *head = NULL;
 }
 
 #if USE_DELAY_POOLS