]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: Remove custom StrList/link_list implementation
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 28 Oct 2016 01:37:51 +0000 (14:37 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 28 Oct 2016 01:37:51 +0000 (14:37 +1300)
Use FIFO queue STL container instead.

src/Makefile.am
src/SquidList.cc [deleted file]
src/SquidList.h [deleted file]
src/mem/forward.h
src/mem/old_api.cc
src/repl/heap/store_repl_heap.cc

index 4c132c9f70931fe87ee18f4ce2ffe7cf1d11482c..5d17687e15083b2f0dc59873b6d15cbfea5aff83 100644 (file)
@@ -358,8 +358,6 @@ squid_SOURCES = \
        ipcache.cc \
        ipcache.h \
        $(LEAKFINDERSOURCE) \
-       SquidList.h \
-       SquidList.cc \
        LogTags.cc \
        LogTags.h \
        lookup_t.h \
@@ -1059,8 +1057,6 @@ tests_testACLMaxUserIP_SOURCES= \
        MasterXaction.h \
        Notes.cc \
        Notes.h \
-       SquidList.h \
-       SquidList.cc \
        mem_node.cc \
        Parsing.cc \
        tests/stub_libsecurity.cc \
@@ -1296,8 +1292,6 @@ tests_testCacheManager_SOURCES = \
        internal.cc \
        LogTags.cc \
        tests/stub_libsecurity.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        multicast.h \
@@ -1479,8 +1473,6 @@ tests_testDiskIO_SOURCES = \
        HttpReply.cc \
        int.h \
        int.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        MemBuf.cc \
@@ -1725,8 +1717,6 @@ tests_testEvent_SOURCES = \
        internal.cc \
        LogTags.cc \
        tests/stub_libsecurity.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        tests/stub_libmem.cc \
@@ -1963,8 +1953,6 @@ tests_testEventLoop_SOURCES = \
        internal.h \
        internal.cc \
        LogTags.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        MemBuf.cc \
@@ -2197,8 +2185,6 @@ tests_test_http_range_SOURCES = \
        $(IPC_SOURCE) \
        ipcache.cc \
        LogTags.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        MemBuf.cc \
@@ -2511,8 +2497,6 @@ tests_testHttpRequest_SOURCES = \
        internal.cc \
        LogTags.cc \
        tests/stub_libsecurity.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        multicast.h \
@@ -2741,8 +2725,6 @@ tests_testStore_SOURCES= \
        RequestFlags.h \
        int.h \
        int.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        mem_node.cc \
@@ -2967,8 +2949,6 @@ tests_testUfs_SOURCES = \
        int.cc \
        RequestFlags.h \
        RequestFlags.cc \
-       SquidList.h \
-       SquidList.cc \
        Transients.cc \
        MasterXaction.cc \
        MasterXaction.h \
@@ -3152,8 +3132,6 @@ tests_testRock_SOURCES = \
        HttpReply.cc \
        int.h \
        int.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        MemBuf.cc \
@@ -3367,8 +3345,6 @@ tests_testURL_SOURCES = \
        internal.cc \
        tests/stub_libeui.cc \
        LogTags.cc \
-       SquidList.h \
-       SquidList.cc \
        MasterXaction.cc \
        MasterXaction.h \
        multicast.h \
diff --git a/src/SquidList.cc b/src/SquidList.cc
deleted file mode 100644 (file)
index 0e09517..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 1996-2016 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.
- */
-
-/* DEBUG: none          Linked list functions (deprecated) */
-
-#include "squid.h"
-#include "mem/forward.h"
-#include "SquidList.h"
-
-/* This should go away, in favour of the List template class */
-
-void
-linklistPush(link_list ** L, void *p)
-{
-    link_list *l = (link_list *)memAllocate(MEM_LINK_LIST);
-    l->next = NULL;
-    l->ptr = p;
-
-    while (*L)
-        L = &(*L)->next;
-
-    *L = l;
-}
-
-void *
-linklistShift(link_list ** L)
-{
-    void *p;
-    link_list *l;
-
-    if (NULL == *L)
-        return NULL;
-
-    l = *L;
-
-    p = l->ptr;
-
-    *L = (*L)->next;
-
-    memFree(l, MEM_LINK_LIST);
-
-    return p;
-}
-
diff --git a/src/SquidList.h b/src/SquidList.h
deleted file mode 100644 (file)
index 1fbeb74..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 1996-2016 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.
- */
-
-/* DEBUG: none          Linked list functions (deprecated) */
-
-#ifndef SQUID_SQUIDLIST_H_
-#define SQUID_SQUIDLIST_H_
-
-class link_list
-{
-public:
-    void *ptr;
-    link_list *next;
-};
-
-void linklistPush(link_list **, void *);
-void *linklistShift(link_list **);
-
-#endif /* SQUID_SQUIDLIST_H_ */
-
index d7adc846291870ac56e5f0ff8091910c7642a744..ed44f06189fe96a914604c81bcbc01727d3a40f6 100644 (file)
@@ -44,7 +44,6 @@ typedef enum {
     MEM_16K_BUF,
     MEM_32K_BUF,
     MEM_64K_BUF,
-    MEM_LINK_LIST,
     MEM_DREAD_CTRL,
     MEM_DWRITE_Q,
     MEM_MD5_DIGEST,
index 9ce3d444bd3a816b7138f8c6c6c530d245a086f8..1126ce27c37cc2cc01c6ed9d182ccd4bdb6ac9f9 100644 (file)
@@ -22,7 +22,6 @@
 #include "MemBuf.h"
 #include "mgr/Registration.h"
 #include "SquidConfig.h"
-#include "SquidList.h"
 #include "SquidTime.h"
 #include "Store.h"
 
@@ -440,7 +439,6 @@ Mem::Init(void)
     memDataInit(MEM_16K_BUF, "16K Buffer", 16384, 10, false);
     memDataInit(MEM_32K_BUF, "32K Buffer", 32768, 10, false);
     memDataInit(MEM_64K_BUF, "64K Buffer", 65536, 10, false);
-    memDataInit(MEM_LINK_LIST, "link_list", sizeof(link_list), 10);
     memDataInit(MEM_DREAD_CTRL, "dread_ctrl", sizeof(dread_ctrl), 0);
     memDataInit(MEM_DWRITE_Q, "dwrite_q", sizeof(dwrite_q), 0);
     memDataInit(MEM_MD5_DIGEST, "MD5 digest", SQUID_MD5_DIGEST_LENGTH, 0);
index c4e64b0607987c3749de67f9e7154b04c7f93b39..d6aa21563e5c97ed2f91680bca9f340181550b42 100644 (file)
 #include "squid.h"
 #include "heap.h"
 #include "MemObject.h"
-#include "SquidList.h"
 #include "Store.h"
 #include "store_heap_replacement.h"
 #include "wordlist.h"
 
+#include <queue>
+
 REMOVALPOLICYCREATE createRemovalPolicy_heap;
 
 static int nr_heap_policies = 0;
@@ -181,11 +182,11 @@ heap_walkInit(RemovalPolicy * policy)
 
 /** RemovalPurgeWalker **/
 
-typedef struct _HeapPurgeData HeapPurgeData;
-
-struct _HeapPurgeData {
-    link_list *locked_entries;
-    heap_key min_age;
+class HeapPurgeData
+{
+public:
+    std::queue<StoreEntry *> locked_entries;
+    heap_key min_age = 0.0;
 };
 
 static StoreEntry *
@@ -209,7 +210,7 @@ try_again:
     if (entry->locked()) {
 
         entry->lock("heap_purgeNext");
-        linklistPush(&heap_walker->locked_entries, entry);
+        heap_walker->locked_entries.push(entry);
 
         goto try_again;
     }
@@ -225,7 +226,6 @@ heap_purgeDone(RemovalPurgeWalker * walker)
     HeapPurgeData *heap_walker = (HeapPurgeData *)walker->_data;
     RemovalPolicy *policy = walker->_policy;
     HeapPolicyData *h = (HeapPolicyData *)policy->_data;
-    StoreEntry *entry;
     assert(strcmp(policy->_type, "heap") == 0);
     assert(h->nwalkers > 0);
     h->nwalkers -= 1;
@@ -235,16 +235,16 @@ heap_purgeDone(RemovalPurgeWalker * walker)
         debugs(81, 3, "Heap age set to " << h->theHeap->age);
     }
 
-    /*
-     * Reinsert the locked entries
-     */
-    while ((entry = (StoreEntry *)linklistShift(&heap_walker->locked_entries))) {
+    // Reinsert the locked entries
+    while (!heap_walker->locked_entries.empty()) {
+        StoreEntry *entry = heap_walker->locked_entries.front();
         heap_node *node = heap_insert(h->theHeap, entry);
         h->setPolicyNode(entry, node);
         entry->unlock("heap_purgeDone");
+        heap_walker->locked_entries.pop();
     }
 
-    safe_free(walker->_data);
+    delete heap_walker;
     delete walker;
 }
 
@@ -256,9 +256,7 @@ heap_purgeInit(RemovalPolicy * policy, int max_scan)
     HeapPurgeData *heap_walk;
     h->nwalkers += 1;
     walker = new RemovalPurgeWalker;
-    heap_walk = (HeapPurgeData *)xcalloc(1, sizeof(*heap_walk));
-    heap_walk->min_age = 0.0;
-    heap_walk->locked_entries = NULL;
+    heap_walk = new HeapPurgeData;
     walker->_policy = policy;
     walker->_data = heap_walk;
     walker->max_scan = max_scan;