8 #include <botan/internal/defalloc.h>
9 #include <botan/internal/mlock.h>
10 #include <botan/libstate.h>
21 void* do_malloc(
size_t n,
bool do_lock)
23 void* ptr = std::malloc(n);
31 std::memset(ptr, 0, n);
38 void do_free(
void* ptr,
size_t n,
bool do_lock)
43 std::memset(ptr, 0, n);
57 void* ptr = do_malloc(n,
false);
68 do_free(ptr, n,
false);
74 void* Locking_Allocator::alloc_block(
size_t n)
76 return do_malloc(n,
true);
82 void Locking_Allocator::dealloc_block(
void* ptr,
size_t n)
84 do_free(ptr, n,
true);
92 std::string
type =
"";
100 throw Internal_Error(
"Couldn't find an allocator to use in get_allocator");
static Allocator * get(bool locking)
Library_State & global_state()
Allocator * get_allocator(const std::string &name="") const
void deallocate(void *, size_t)
virtual std::string type() const =0
void unlock_mem(void *ptr, size_t bytes)
bool lock_mem(void *ptr, size_t bytes)