diff options
author | lloyd <[email protected]> | 2014-08-09 15:56:32 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-08-09 15:56:32 +0000 |
commit | 455bd2557cbb1343e59eefd97cb449f06a702c28 (patch) | |
tree | 4bb7de20fb10e198b57768d3dabd31ed093a95e7 | |
parent | 28726b93b0b9ae221f54ab7cc297d09a9af6843a (diff) |
Have clear_mem just be a plain memset and only call the (slow)
zero_mem just before a deallocation where we are actually at risk of
the compiler eliding the writes.
-rw-r--r-- | src/lib/alloc/secmem.h | 2 | ||||
-rw-r--r-- | src/lib/utils/mem_ops.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/alloc/secmem.h b/src/lib/alloc/secmem.h index 2f4d65f33..706ea037f 100644 --- a/src/lib/alloc/secmem.h +++ b/src/lib/alloc/secmem.h @@ -57,7 +57,7 @@ class secure_allocator void deallocate(pointer p, size_type n) { - clear_mem(p, n); + zero_mem(p, n); #if defined(BOTAN_HAS_LOCKING_ALLOCATOR) if(mlock_allocator::instance().deallocate(p, n, sizeof(T))) diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h index be617ff19..05b2c22a5 100644 --- a/src/lib/utils/mem_ops.h +++ b/src/lib/utils/mem_ops.h @@ -27,7 +27,7 @@ BOTAN_DLL void zero_mem(void* ptr, size_t n); */ template<typename T> inline void clear_mem(T* ptr, size_t n) { - zero_mem(ptr, sizeof(T)*n); + std::memset(ptr, 0, sizeof(T)*n); } /** |