aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/locking_allocator
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-12-27 21:04:28 -0500
committerJack Lloyd <[email protected]>2019-01-04 21:23:25 -0500
commite2ee85c5de7df54953559d80e9889dd550550699 (patch)
tree7d2d7daa45833cc6722ed3191e6c79374b141d6d /src/lib/utils/locking_allocator
parent4b1252bc1410d9c6af61ca20f5a1e72fa2d440d4 (diff)
New Memory_Pool implementation
Quite a bit faster than the old version, and with better properties wrt alignment
Diffstat (limited to 'src/lib/utils/locking_allocator')
-rw-r--r--src/lib/utils/locking_allocator/locking_allocator.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/utils/locking_allocator/locking_allocator.cpp b/src/lib/utils/locking_allocator/locking_allocator.cpp
index 9d05cfbff..401f00848 100644
--- a/src/lib/utils/locking_allocator/locking_allocator.cpp
+++ b/src/lib/utils/locking_allocator/locking_allocator.cpp
@@ -43,20 +43,19 @@ bool mlock_allocator::deallocate(void* p, size_t num_elems, size_t elem_size) no
mlock_allocator::mlock_allocator()
{
const size_t mem_to_lock = OS::get_memory_locking_limit();
+ const size_t page_size = OS::system_page_size();
- if(mem_to_lock)
+ if(mem_to_lock > 0 && mem_to_lock % page_size == 0)
{
m_locked_pages = static_cast<uint8_t*>(OS::allocate_locked_pages(mem_to_lock));
if(m_locked_pages)
{
m_locked_pages_size = mem_to_lock;
+
m_pool.reset(new Memory_Pool(m_locked_pages,
- m_locked_pages_size,
- OS::system_page_size(),
- BOTAN_MLOCK_ALLOCATOR_MIN_ALLOCATION,
- BOTAN_MLOCK_ALLOCATOR_MAX_ALLOCATION,
- 4));
+ m_locked_pages_size / page_size,
+ page_size));
}
}
}