Botan: src/alloc/alloc_mmap/mmap_mem.h Source File

Botan 1.10.17

mmap_mem.h
Go to the documentation of this file.
1 /*
2 * Memory Mapping Allocator
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_MMAP_ALLOCATOR_H__
9 #define BOTAN_MMAP_ALLOCATOR_H__
10
11 #include <botan/internal/mem_pool.h>
12
13 namespace Botan {
14
15 /**
16 * Allocator that uses memory maps backed by disk. We zeroize the map
17 * upon deallocation. If swap occurs, the VM will swap to the shared
18 * file backing rather than to a swap device, which means we know where
19 * it is and can zap it later.
20 */
21 class MemoryMapping_Allocator : public Pooling_Allocator
22 {
23 public:
24 /**
25 * @param mutex used for internal locking
26 */
27 MemoryMapping_Allocator(Mutex* mutex) : Pooling_Allocator(mutex) {}
28 std::string type() const { return "mmap"; }
29 private:
30 void* alloc_block(size_t);
31 void dealloc_block(void*, size_t);
32 };
33
34 }
35
36 #endif
Botan
Definition: algo_base.h:14
Botan::Mutex
Definition: mutex.h:18
Botan::MemoryMapping_Allocator::type
std::string type() const
Definition: mmap_mem.h:28
Botan::Pooling_Allocator
Definition: mem_pool.h:22
Botan::MemoryMapping_Allocator::MemoryMapping_Allocator
MemoryMapping_Allocator(Mutex *mutex)
Definition: mmap_mem.h:27
Botan::MemoryMapping_Allocator
Definition: mmap_mem.h:21