File 10825.patch of Package squid-beta

---------------------
PatchSet 10825 
Date: 2007/05/22 16:40:05
Author: rousskov
Branch: HEAD
Tag: (none) 
Log:
Bug #1966 fix: Use rounded String MemPool sizes in the hard-coded pool
config to avoid warnings that the configured pool size does not match the
actual size.

Members: 
	include/MemPool.h:1.16->1.17 
	lib/MemPool.cc:1.6->1.7 
	src/mem.cc:1.104->1.105 

Index: squid3/include/MemPool.h
===================================================================
RCS file: /cvsroot/squid/squid3/include/MemPool.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- squid3/include/MemPool.h	22 May 2007 03:44:34 -0000	1.16
+++ squid3/include/MemPool.h	22 May 2007 16:40:05 -0000	1.17
@@ -112,6 +112,9 @@
     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: squid3/lib/MemPool.cc
===================================================================
RCS file: /cvsroot/squid/squid3/lib/MemPool.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- squid3/lib/MemPool.cc	20 Sep 2006 00:59:26 -0000	1.6
+++ squid3/lib/MemPool.cc	22 May 2007 16:40:06 -0000	1.7
@@ -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 @@
 {
 }
 
+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 @@
 	next(NULL),
 	alloc_calls(0),
 	free_calls(0),
-	obj_size(((aSize + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *))
+	obj_size(RoundedSize(aSize))
 {
 }
 
Index: squid3/src/mem.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/mem.cc,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- squid3/src/mem.cc	28 Apr 2007 22:26:37 -0000	1.104
+++ squid3/src/mem.cc	22 May 2007 16:40:06 -0000	1.105
@@ -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 @@
 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 */
                                     };