]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1966 fix: Use rounded String MemPool sizes in the hard-coded pool
authorrousskov <>
Tue, 22 May 2007 22:40:05 +0000 (22:40 +0000)
committerrousskov <>
Tue, 22 May 2007 22:40:05 +0000 (22:40 +0000)
config to avoid warnings that the configured pool size does not match the
actual size.

include/MemPool.h
lib/MemPool.cc
src/mem.cc

index 9ed383dab1b12f3dc524d8dc0a0a6ac1984ed863..251f66501b9bc2c7255dad8945b4836d610fd8c5 100644 (file)
@@ -112,6 +112,9 @@ public:
     virtual int getInUseCount() = 0;
     int inUseCount();
     virtual void setChunkSize(size_t chunksize) {}
+
+    // smallest size divisible by sizeof(void*) and at least minSize
+    static size_t RoundedSize(size_t minSize);
 private:
     const char *label;
 };
index 26f40ae17cac469bf4abecd9deb9629f3c3b7c77..6ff2a687e8d9ce2dd12d1afa9e054b53947930ec 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: MemPool.cc,v 1.6 2006/09/20 00:59:26 adrian Exp $
+ * $Id: MemPool.cc,v 1.7 2007/05/22 16:40:06 rousskov Exp $
  *
  * DEBUG: section 63    Low Level Memory Pool Management
  * AUTHOR: Alex Rousskov, Andres Kroonmaa, Robert Collins
@@ -836,6 +836,11 @@ MemAllocator::MemAllocator(char const *aLabel) : label(aLabel)
 {
 }
 
+size_t MemAllocator::RoundedSize(size_t s)
+{
+    return ((s + sizeof(void*) - 1) / sizeof(void*)) * sizeof(void*);
+}
+
 MemMalloc::MemMalloc(char const *label, size_t aSize) : MemImplementingAllocator(label, aSize) { inuse = 0; }
 
 bool
@@ -923,7 +928,7 @@ MemImplementingAllocator::MemImplementingAllocator(char const *aLabel, size_t aS
        next(NULL),
        alloc_calls(0),
        free_calls(0),
-       obj_size(((aSize + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *))
+       obj_size(RoundedSize(aSize))
 {
 }
 
index 45506bd3eb9d865f984b8d520c87ea18126ccee0..ca0db9963c5423260d8f0fcc57f4099b4887fa8e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mem.cc,v 1.104 2007/04/28 22:26:37 hno Exp $
+ * $Id: mem.cc,v 1.105 2007/05/22 16:40:06 rousskov Exp $
  *
  * DEBUG: section 13    High Level Memory Pool Management
  * AUTHOR: Harvest Derived
@@ -69,13 +69,13 @@ static const struct
 StrPoolsAttrs[mem_str_pool_count] = {
 
                                         {
-                                            "Short Strings", 36,
+                                            "Short Strings", MemAllocator::RoundedSize(36),
                                         },                             /* to fit rfc1123 and similar */
                                         {
-                                            "Medium Strings", 128,
+                                            "Medium Strings", MemAllocator::RoundedSize(128),
                                         },                             /* to fit most urls */
                                         {
-                                            "Long Strings", 512
+                                            "Long Strings", MemAllocator::RoundedSize(512)
                                         }                              /* other */
                                     };