diff options
author | Jack Lloyd <[email protected]> | 2017-09-29 19:15:48 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-29 21:05:29 -0400 |
commit | 2edb12e249387a72b24f5f34efae4735d589af9f (patch) | |
tree | d2873f1f3d608c0d23869893c22a69b05489ce48 /src/lib/base | |
parent | 184ce9f93906241d1807f73c7ea20283fc6ff222 (diff) |
In secure_allocator, hide mlock/new usage in a function in mem_ops
Switch to calloc/free instead of new/delete - shouldn't matter since
we are only allocate integral types.
This change reduces the size of libbotan-2.so by ~300 Kb on my system.
Diffstat (limited to 'src/lib/base')
-rw-r--r-- | src/lib/base/secmem.h | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/lib/base/secmem.h b/src/lib/base/secmem.h index eddf37c71..80dc69c14 100644 --- a/src/lib/base/secmem.h +++ b/src/lib/base/secmem.h @@ -15,10 +15,6 @@ #include <deque> #include <type_traits> -#if defined(BOTAN_HAS_LOCKING_ALLOCATOR) - #include <botan/locking_allocator.h> -#endif - namespace Botan { template<typename T> @@ -56,26 +52,12 @@ class secure_allocator T* allocate(std::size_t n) { -#if defined(BOTAN_HAS_LOCKING_ALLOCATOR) - if(T* p = static_cast<T*>(mlock_allocator::instance().allocate(n, sizeof(T)))) - return p; -#endif - - T* p = new T[n]; - clear_mem(p, n); - return p; + return static_cast<T*>(allocate_memory(n, sizeof(T))); } void deallocate(T* p, std::size_t n) { - secure_scrub_memory(p, sizeof(T)*n); - -#if defined(BOTAN_HAS_LOCKING_ALLOCATOR) - if(mlock_allocator::instance().deallocate(p, n, sizeof(T))) - return; -#endif - - delete [] p; + deallocate_memory(p, n, sizeof(T)); } }; |