diff options
author | Jack Lloyd <[email protected]> | 2018-02-04 15:27:40 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-02-04 15:27:40 -0500 |
commit | 2cb0fa04472f4bc60f02d822daa8f4f8ad487e7e (patch) | |
tree | dc48529923d296a06b44b9730bd535f63efe16d9 /src/lib/utils | |
parent | a17f1b71254e7e4c9de1a86a246fb85a3a4f25b9 (diff) |
Alternate method of forcing allocator initialization
That doesn't require a malloc/free every time we call ec_group_data()
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/mem_ops.cpp | 7 | ||||
-rw-r--r-- | src/lib/utils/mem_ops.h | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/utils/mem_ops.cpp b/src/lib/utils/mem_ops.cpp index 3fd463195..b7ecd5326 100644 --- a/src/lib/utils/mem_ops.cpp +++ b/src/lib/utils/mem_ops.cpp @@ -41,6 +41,13 @@ void deallocate_memory(void* p, size_t elems, size_t elem_size) std::free(p); } +void initialize_allocator() + { +#if defined(BOTAN_HAS_LOCKING_ALLOCATOR) + mlock_allocator::instance(); +#endif + } + bool constant_time_compare(const uint8_t x[], const uint8_t y[], size_t len) diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h index be75da655..5fb5752fc 100644 --- a/src/lib/utils/mem_ops.h +++ b/src/lib/utils/mem_ops.h @@ -33,6 +33,11 @@ BOTAN_PUBLIC_API(2,3) BOTAN_MALLOC_FN void* allocate_memory(size_t elems, size_t BOTAN_PUBLIC_API(2,3) void deallocate_memory(void* p, size_t elems, size_t elem_size); /** +* Ensure the allocator is initialized +*/ +void initialize_allocator(); + +/** * Scrub memory contents in a way that a compiler should not elide, * using some system specific technique. Note that this function might * not zero the memory (for example, in some hypothetical |