8 #ifndef BOTAN_POOLING_ALLOCATOR_H__
9 #define BOTAN_POOLING_ALLOCATOR_H__
11 #include <botan/allocate.h>
12 #include <botan/exceptn.h>
13 #include <botan/internal/mutex.h>
36 void get_more_core(
size_t);
37 byte* allocate_blocks(
size_t);
39 virtual void* alloc_block(
size_t) = 0;
40 virtual void dealloc_block(
void*,
size_t) = 0;
47 static size_t bitmap_size() {
return BITMAP_SIZE; }
48 static size_t block_size() {
return BLOCK_SIZE; }
50 bool contains(
void*,
size_t)
const;
52 void free(
void*,
size_t);
54 bool operator<(
const Memory_Block& other)
const
56 if(buffer < other.buffer && other.buffer < buffer_end)
58 return (buffer < other.buffer);
61 typedef u64bit bitmap_type;
62 static const size_t BITMAP_SIZE = 8 *
sizeof(bitmap_type);
63 static const size_t BLOCK_SIZE = 64;
66 byte* buffer, *buffer_end;
69 std::vector<Memory_Block> blocks;
70 std::vector<Memory_Block>::iterator last_used;
71 std::vector<std::pair<void*, size_t> > allocated;
void deallocate(void *, size_t)
Pooling_Allocator(Mutex *mutex)
unsigned long long u64bit
bool BOTAN_DLL operator<(const X509_Time &, const X509_Time &)