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;
};
/*
- * $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
{
}
+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
next(NULL),
alloc_calls(0),
free_calls(0),
- obj_size(((aSize + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *))
+ obj_size(RoundedSize(aSize))
{
}
/*
- * $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
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 */
};