diff options
author | Jack Lloyd <[email protected]> | 2018-12-31 17:52:04 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-01-05 08:50:40 -0500 |
commit | 1d14dff64b4848c8df60c5498ae810d862205f3d (patch) | |
tree | 08f143e983214b1fb75eeda1b468580789b44a37 /src/lib/utils/locking_allocator | |
parent | b40d4c0e9c134a3daf9d77ce6f8a7b1271feb5ca (diff) |
Split up allocations into pages
Diffstat (limited to 'src/lib/utils/locking_allocator')
-rw-r--r-- | src/lib/utils/locking_allocator/locking_allocator.cpp | 12 | ||||
-rw-r--r-- | src/lib/utils/locking_allocator/locking_allocator.h | 3 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/lib/utils/locking_allocator/locking_allocator.cpp b/src/lib/utils/locking_allocator/locking_allocator.cpp index 401f00848..1c10c362b 100644 --- a/src/lib/utils/locking_allocator/locking_allocator.cpp +++ b/src/lib/utils/locking_allocator/locking_allocator.cpp @@ -47,15 +47,11 @@ mlock_allocator::mlock_allocator() 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)); + m_locked_pages = OS::allocate_locked_pages(mem_to_lock / page_size); - if(m_locked_pages) + if(m_locked_pages.size() > 0) { - m_locked_pages_size = mem_to_lock; - - m_pool.reset(new Memory_Pool(m_locked_pages, - m_locked_pages_size / page_size, - page_size)); + m_pool.reset(new Memory_Pool(m_locked_pages, page_size)); } } } @@ -66,7 +62,7 @@ mlock_allocator::~mlock_allocator() { m_pool.reset(); // OS::free_locked_pages scrubs the memory before free - OS::free_locked_pages(m_locked_pages, m_locked_pages_size); + OS::free_locked_pages(m_locked_pages); } } diff --git a/src/lib/utils/locking_allocator/locking_allocator.h b/src/lib/utils/locking_allocator/locking_allocator.h index 7325e79ac..21baa8ec2 100644 --- a/src/lib/utils/locking_allocator/locking_allocator.h +++ b/src/lib/utils/locking_allocator/locking_allocator.h @@ -35,8 +35,7 @@ class BOTAN_PUBLIC_API(2,0) mlock_allocator final ~mlock_allocator(); std::unique_ptr<Memory_Pool> m_pool; - uint8_t* m_locked_pages = nullptr; - size_t m_locked_pages_size = 0; + std::vector<void*> m_locked_pages; }; } |