From: rousskov <> Date: Tue, 22 May 2007 22:40:05 +0000 (+0000) Subject: Bug #1966 fix: Use rounded String MemPool sizes in the hard-coded pool X-Git-Tag: SQUID_3_0_PRE7~243 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb6d49845ce8ee6587df2f3b03df4486f5b5f70c;p=thirdparty%2Fsquid.git 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. --- diff --git a/include/MemPool.h b/include/MemPool.h index 9ed383dab1..251f66501b 100644 --- a/include/MemPool.h +++ b/include/MemPool.h @@ -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; }; diff --git a/lib/MemPool.cc b/lib/MemPool.cc index 26f40ae17c..6ff2a687e8 100644 --- a/lib/MemPool.cc +++ b/lib/MemPool.cc @@ -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)) { } diff --git a/src/mem.cc b/src/mem.cc index 45506bd3eb..ca0db9963c 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -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 */ };