diff options
author | lloyd <[email protected]> | 2014-01-01 21:20:55 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-01 21:20:55 +0000 |
commit | 197dc467dec28a04c3b2f30da7cef122dfbb13e9 (patch) | |
tree | cdbd3ddaec051c72f0a757db461973d90c37b97a /src/engine/gnump/gmp_mem.cpp | |
parent | 62faac373c07cfe10bc8c309e89ebdd30d8e5eaa (diff) |
Shuffle things around. Add NIST X.509 test to build.
Diffstat (limited to 'src/engine/gnump/gmp_mem.cpp')
-rw-r--r-- | src/engine/gnump/gmp_mem.cpp | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src/engine/gnump/gmp_mem.cpp b/src/engine/gnump/gmp_mem.cpp deleted file mode 100644 index b5a5a303e..000000000 --- a/src/engine/gnump/gmp_mem.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* -* GNU MP Memory Handlers -* (C) 1999-2010 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/internal/gnump_engine.h> -#include <cstring> -#include <atomic> -#include <gmp.h> - -namespace Botan { - -namespace { - -/* -* For keeping track of existing GMP_Engines and only -* resetting the memory when none are in use. -*/ -std::atomic<size_t> gmp_alloc_refcnt(0); - -/* -* Allocation Function for GNU MP -*/ -void* gmp_malloc(size_t n) - { - // Maintain alignment, mlock goes for sizeof(T) alignment - if(n % 8 == 0) - return secure_allocator<u64bit>().allocate(n / 8); - else if(n % 4 == 0) - return secure_allocator<u32bit>().allocate(n / 4); - else if(n % 2 == 0) - return secure_allocator<u16bit>().allocate(n / 2); - - return secure_allocator<byte>().allocate(n); - } - -/* -* Deallocation Function for GNU MP -*/ -void gmp_free(void* ptr, size_t n) - { - secure_allocator<byte>().deallocate(static_cast<byte*>(ptr), n); - } - -/* -* Reallocation Function for GNU MP -*/ -void* gmp_realloc(void* ptr, size_t old_n, size_t new_n) - { - void* new_buf = gmp_malloc(new_n); - std::memcpy(new_buf, ptr, std::min(old_n, new_n)); - gmp_free(ptr, old_n); - return new_buf; - } - -} - -/* -* GMP_Engine Constructor -*/ -GMP_Engine::GMP_Engine() - { - /* - if(gmp_alloc_refcnt == 0) - mp_set_memory_functions(gmp_malloc, gmp_realloc, gmp_free); - - gmp_alloc_refcnt++; - */ - } - -GMP_Engine::~GMP_Engine() - { - /* - --gmp_alloc_refcnt; - - if(gmp_alloc_refcnt == 0) - mp_set_memory_functions(NULL, NULL, NULL); - */ - } - -} |