]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Replace AclNameList with SBufList (#327)
authorAmos Jeffries <yadij@users.noreply.github.com>
Sun, 11 Nov 2018 00:01:56 +0000 (00:01 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 11 Nov 2018 01:21:15 +0000 (01:21 +0000)
Removing a class we no longer need to simplify the deny_info code.

src/acl/AclDenyInfoList.h
src/acl/AclNameList.h [deleted file]
src/acl/Gadgets.cc
src/acl/Makefile.am
src/cache_cf.cc

index 95dfd100965454c5f04a87ca1dc4ecfbd35c7b33..5599deaec45b38374a65531d64ad5ce75e1b7e18 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef SQUID_ACLDENYINFOLIST_H_
 #define SQUID_ACLDENYINFOLIST_H_
 
-#include "acl/AclNameList.h"
+#include "acl/forward.h"
 #include "err_type.h"
 #include "errorpage.h"
 #include "mem/forward.h"
@@ -26,7 +26,6 @@ public:
     }
     ~AclDenyInfoList() {
         xfree(err_page_name);
-        delete acl_list;
         while (next) {
             auto *a = next;
             next = a->next;
@@ -36,7 +35,7 @@ public:
     }
     err_type err_page_id = ERR_NONE;
     char *err_page_name = nullptr;
-    AclNameList *acl_list = nullptr;
+    SBufList acl_list; ///< ACL names in configured order
     AclDenyInfoList *next = nullptr;
 };
 
diff --git a/src/acl/AclNameList.h b/src/acl/AclNameList.h
deleted file mode 100644 (file)
index 0f7db6a..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 1996-2018 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.
- */
-
-#ifndef SQUID_ACL_ACLNAMELIST_H_
-#define SQUID_ACL_ACLNAMELIST_H_
-
-#include "acl/forward.h"
-#include "mem/forward.h"
-
-/// list of name-based ACLs
-class AclNameList
-{
-    MEMPROXY_CLASS(AclNameList);
-
-public:
-    AclNameList(const char *t) {
-        xstrncpy(name, t, ACL_NAME_SZ-1);
-    }
-    ~AclNameList() {
-        // recursion is okay, these lists are short
-        delete next;
-    }
-
-    char name[ACL_NAME_SZ];
-    AclNameList *next = nullptr;
-};
-// TODO: convert to a std::list<string>
-
-#endif /* SQUID_ACLNAMELIST_H_ */
-
index 1b0531e75f9e8486a7b277dbfc852e1d5c1083f7..8c1933b6322d67b6b4778aa8ec2ab63ee12dbb1d 100644 (file)
@@ -49,19 +49,16 @@ aclGetDenyInfoPage(AclDenyInfoList ** head, const char *name, int redirect_allow
     debugs(28, 8, HERE << "got called for " << name);
 
     for (A = *head; A; A = A->next) {
-        AclNameList *L = NULL;
-
         if (!redirect_allowed && strchr(A->err_page_name, ':') ) {
             debugs(28, 8, HERE << "Skip '" << A->err_page_name << "' 30x redirects not allowed as response here.");
             continue;
         }
 
-        for (L = A->acl_list; L; L = L->next) {
-            if (!strcmp(name, L->name)) {
-                debugs(28, 8, HERE << "match on " << name);
+        for (const auto &aclName: A->acl_list) {
+            if (aclName.cmp(name) == 0) {
+                debugs(28, 8, "match on " << name);
                 return A->err_page_id;
             }
-
         }
     }
 
@@ -106,8 +103,6 @@ aclParseDenyInfoLine(AclDenyInfoList ** head)
     char *t = NULL;
     AclDenyInfoList *B;
     AclDenyInfoList **T;
-    AclNameList *L = NULL;
-    AclNameList **Tail = NULL;
 
     /* first expect a page name */
 
@@ -120,15 +115,11 @@ aclParseDenyInfoLine(AclDenyInfoList ** head)
     AclDenyInfoList *A = new AclDenyInfoList(t);
 
     /* next expect a list of ACL names */
-    Tail = &A->acl_list;
-
     while ((t = ConfigParser::NextToken())) {
-        L = new AclNameList(t);
-        *Tail = L;
-        Tail = &L->next;
+        A->acl_list.emplace_back(t);
     }
 
-    if (A->acl_list == NULL) {
+    if (A->acl_list.empty()) {
         debugs(28, DBG_CRITICAL, "aclParseDenyInfoLine: " << cfg_filename << " line " << config_lineno << ": " << config_input_line);
         debugs(28, DBG_CRITICAL, "aclParseDenyInfoLine: deny_info line contains no ACL's, skipping");
         delete A;
@@ -298,17 +289,10 @@ aclDestroyDenyInfoList(AclDenyInfoList ** list)
 {
     AclDenyInfoList *a = NULL;
     AclDenyInfoList *a_next = NULL;
-    AclNameList *l = NULL;
-    AclNameList *l_next = NULL;
 
     debugs(28, 8, "aclDestroyDenyInfoList: invoked");
 
     for (a = *list; a; a = a_next) {
-        for (l = a->acl_list; l; l = l_next) {
-            l_next = l->next;
-            safe_free(l);
-        }
-
         a_next = a->next;
         delete a;
     }
index 4c3c480203c75a195ed58b8e7df624dacfab79ef..89936ec63e4dff6b1d53374d8fa588019dd625cf 100644 (file)
@@ -147,7 +147,6 @@ libacls_la_SOURCES = \
        UrlPort.h \
        UserData.cc \
        UserData.h \
-       AclNameList.h \
        AclDenyInfoList.h \
        Gadgets.cc \
        Gadgets.h \
index 414be89c52fda30b3b85f60e3b44bcfdbaa804e6..d1c26d495138164e9e475f76487905915781519c 100644 (file)
@@ -2443,8 +2443,8 @@ dump_denyinfo(StoreEntry * entry, const char *name, AclDenyInfoList * var)
     while (var != NULL) {
         storeAppendPrintf(entry, "%s %s", name, var->err_page_name);
 
-        for (auto *a = var->acl_list; a != NULL; a = a->next)
-            storeAppendPrintf(entry, " %s", a->name);
+        for (const auto &aclName: var->acl_list)
+            storeAppendPrintf(entry, " " SQUIDSBUFPH, SQUIDSBUFPRINT(aclName));
 
         storeAppendPrintf(entry, "\n");