Botan 1.10.17

defalloc.h
Go to the documentation of this file.
1 /*
2 * Basic Allocators
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_BASIC_ALLOC_H__
9 #define BOTAN_BASIC_ALLOC_H__
10
11 #include <botan/internal/mem_pool.h>
12
13 namespace Botan {
14
15 /**
16 * Allocator using malloc
17 */
18 class Malloc_Allocator : public Allocator
19 {
20 public:
21 void* allocate(size_t);
22 void deallocate(void*, size_t);
23
24 std::string type() const { return "malloc"; }
25 };
26
27 /**
28 * Allocator using malloc plus locking
29 */
30 class Locking_Allocator : public Pooling_Allocator
31 {
32 public:
33 /**
34 * @param mutex used for internal locking
35 */
36 Locking_Allocator(Mutex* mutex) : Pooling_Allocator(mutex) {}
37
38 std::string type() const { return "locking"; }
39 private:
40 void* alloc_block(size_t);
41 void dealloc_block(void*, size_t);
42 };
43
44 }
45
46 #endif
Botan::Locking_Allocator
Definition: defalloc.h:30
Botan::Locking_Allocator::type
std::string type() const
Definition: defalloc.h:38
Botan::Allocator
Definition: allocate.h:19
Botan::Malloc_Allocator::deallocate
void deallocate(void *, size_t)
Definition: defalloc.cpp:66
Botan::Locking_Allocator::Locking_Allocator
Locking_Allocator(Mutex *mutex)
Definition: defalloc.h:36
Botan
Definition: algo_base.h:14
Botan::Malloc_Allocator::type
std::string type() const
Definition: defalloc.h:24
Botan::Malloc_Allocator::allocate
void * allocate(size_t)
Definition: defalloc.cpp:55
Botan::Mutex
Definition: mutex.h:18
Botan::Malloc_Allocator
Definition: defalloc.h:18
Botan::Pooling_Allocator
Definition: mem_pool.h:22