]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Make cacheDigestChangeCap() a method
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 5 Nov 2015 16:58:09 +0000 (08:58 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 5 Nov 2015 16:58:09 +0000 (08:58 -0800)
* Rename to updateCapacity(int)

* Also, use updateCapacity() instead of *Init() to construct the digest

src/CacheDigest.cc
src/CacheDigest.h
src/store_digest.cc
src/tests/stub_CacheDigest.cc

index 7ddb78c900e2592b599436ec0361b333975ad9a8..7b59c64eae49d73b9a7ca3857c1db0478855bcc2 100644 (file)
@@ -53,12 +53,12 @@ CacheDigest::CacheDigest(int aCapacity, int bpe) :
         mask(nullptr),
         mask_size(0),
         capacity(0),
-        bits_per_entry(0),
+        bits_per_entry(bpe),
         count(0),
         del_count(0)
 {
     assert(SQUID_MD5_DIGEST_LENGTH == 16);  /* our hash functions rely on 16 byte keys */
-    cacheDigestInit(this, aCapacity, bpe);
+    updateCapacity(aCapacity);
 }
 
 CacheDigest::~CacheDigest()
@@ -85,13 +85,11 @@ CacheDigest::clear()
     memset(mask, 0, mask_size);
 }
 
-/* changes mask size, resets bits to 0, preserves "cd" pointer */
 void
-cacheDigestChangeCap(CacheDigest * cd, int new_cap)
+CacheDigest::updateCapacity(int newCapacity)
 {
-    assert(cd);
-    safe_free(cd->mask);
-    cacheDigestInit(cd, new_cap, cd->bits_per_entry); // will re-init mask and mask_size
+    safe_free(mask);
+    cacheDigestInit(this, newCapacity, bits_per_entry); // will re-init mask and mask_size
 }
 
 /* returns true if the key belongs to the digest */
index 35da804697bfe01d0b921753d1debefb7f1f09c8..2e3ad3197cfe60436e88f6453f3616f12edbb53d 100644 (file)
@@ -31,6 +31,9 @@ public:
     /// reset the digest mask and counters
     void clear();
 
+    /// changes mask size to fit newCapacity, resets bits to 0
+    void updateCapacity(int newCapacity);
+
 public:
     /* public, read-only */
     char *mask;         /* bit mask */
@@ -41,7 +44,6 @@ public:
     int del_count;      /* number of deletions performed so far */
 };
 
-void cacheDigestChangeCap(CacheDigest * cd, int new_cap);
 int cacheDigestTest(const CacheDigest * cd, const cache_key * key);
 void cacheDigestAdd(CacheDigest * cd, const cache_key * key);
 void cacheDigestDel(CacheDigest * cd, const cache_key * key);
index 07d07ca7c70ddca0ed17fd7593e757cd302a13d6..fe048e192af434a242486f13e72f489c3ec3d9f8 100644 (file)
@@ -518,7 +518,7 @@ storeDigestResize(void)
         return 0;
     } else {
         debugs(71, 2, "storeDigestResize: big change, resizing.");
-        cacheDigestChangeCap(store_digest, cap);
+        store_digest->updateCapacity(cap);
         return 1;
     }
 }
index 316f0b50756974daf9e5aa1cc152067c2b523165..f305e22c5c1aa3f553cf40206596b29df44ce402 100644 (file)
@@ -21,7 +21,7 @@ CacheDigest::CacheDigest(int, int) {STUB}
 CacheDigest::~CacheDigest() {STUB}
 CacheDigest *CacheDigest::clone() const STUB_RETVAL(nullptr)
 void CacheDigest::clear() STUB
-void cacheDigestChangeCap(CacheDigest *,int) STUB
+void CacheDigest::updateCapacity(int) STUB
 int cacheDigestTest(const CacheDigest *, const cache_key *) STUB_RETVAL(1)
 void cacheDigestAdd(CacheDigest *, const cache_key *) STUB
 void cacheDigestDel(CacheDigest *, const cache_key *) STUB