Botan  2.7.0
Crypto and TLS for C++11
locking_allocator.h
Go to the documentation of this file.
1 /*
2 * Mlock Allocator
3 * (C) 2012 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_MLOCK_ALLOCATOR_H_
9 #define BOTAN_MLOCK_ALLOCATOR_H_
10 
11 #include <botan/types.h>
12 #include <vector>
13 #include <memory>
14 
15 namespace Botan {
16 
17 class Memory_Pool;
18 
20  {
21  public:
22  static mlock_allocator& instance();
23 
24  void* allocate(size_t num_elems, size_t elem_size);
25 
26  bool deallocate(void* p, size_t num_elems, size_t elem_size) BOTAN_NOEXCEPT;
27 
28  mlock_allocator(const mlock_allocator&) = delete;
29 
30  mlock_allocator& operator=(const mlock_allocator&) = delete;
31 
32  private:
34 
35  ~mlock_allocator();
36 
37  std::unique_ptr<Memory_Pool> m_pool;
38  uint8_t* m_locked_pages = nullptr;
39  size_t m_locked_pages_size = 0;
40  };
41 
42 }
43 
44 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
#define BOTAN_NOEXCEPT
Definition: compiler.h:154
Definition: alg_id.cpp:13