blob: 5bce1f205d9754a11c4b3ac20f85558499b9fa95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* Allocator
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_ALLOCATOR_H__
#define BOTAN_ALLOCATOR_H__
#include <botan/types.h>
#include <string>
namespace Botan {
/**
* Allocator Interface
*/
class BOTAN_DLL Allocator
{
public:
/**
* Acquire a pointer to an allocator
* @param locking is true if the allocator should attempt to
* secure the memory (eg for using to store keys)
* @return pointer to an allocator; ownership remains with library,
* so do not delete
*/
static Allocator* get(bool locking);
/**
* Allocate a block of memory
* @param n how many bytes to allocate
* @return pointer to n bytes of memory
*/
virtual void* allocate(u32bit n) = 0;
/**
* Deallocate memory allocated with allocate()
* @param ptr the pointer returned by allocate()
* @param n the size of the block pointed to by ptr
*/
virtual void deallocate(void* ptr, u32bit n) = 0;
/**
* @return name of this allocator type
*/
virtual std::string type() const = 0;
/**
* Initialize the allocator
*/
virtual void init() {}
/**
* Shutdown the allocator
*/
virtual void destroy() {}
virtual ~Allocator() {}
};
}
#endif
|