ims: prevent memory pool size from becoming zero
refs: #4769
Change-Id: Id1c1dadf40db6f62bd684391066e7ad45ec8dcd1
diff --git a/src/ims/in-memory-storage.cpp b/src/ims/in-memory-storage.cpp
index 3db250d..cf5ca2d 100644
--- a/src/ims/in-memory-storage.cpp
+++ b/src/ims/in-memory-storage.cpp
@@ -100,7 +100,7 @@
InMemoryStorage::init()
{
// TODO consider a more suitable initial value
- m_capacity = 10;
+ m_capacity = m_initCapacity;
if (m_limit != std::numeric_limits<size_t>::max() && m_capacity > m_limit) {
m_capacity = m_limit;
@@ -131,7 +131,7 @@
InMemoryStorage::setCapacity(size_t capacity)
{
size_t oldCapacity = m_capacity;
- m_capacity = capacity;
+ m_capacity = std::max(capacity, m_initCapacity);
if (size() > m_capacity) {
ssize_t nAllowedFailures = size() - m_capacity;