#include <DataAllocator.h>
Inheritance diagram for base::DataAllocator:
Public Member Functions | |
DataAllocator () | |
constructor: allocate a pool | |
~DataAllocator () | |
destructor: deallocate all pools | |
void * | allocate (size_t intSize) |
allocate memory: take memory
| |
void | deallocate (void *data, size_t intSize) |
Deallocate: store in the free list. | |
void | reset () |
Deallocate all pools except the base. | |
void | printStats (FILE *out) const |
Print statistics, C style = wrapper to C++. | |
std::ostream & | printStats (std::ostream &out) const |
Print statistics. | |
allocator_t | getCAllocator () |
C wrapper allocator. | |
Private Types | |
enum | { CHUNK_SIZE = (1 << 22) } |
Memory is allocated internally by chunks. More... | |
Private Member Functions | |
bool | hasInPools (const uintptr_t *data, size_t intSize) const |
Check that a given address belongs to a pool or the free list. | |
Static Private Member Functions | |
static uintptr_t * | getNext (uintptr_t data) |
An entry in the freeMem table at i gives a free memory block of size i ints. | |
static uintptr_t | getNext (uintptr_t *data) |
Private Attributes | |
array_t< uintptr_t * > | freeMem |
Table of free memory lists. | |
Pool_t * | memPool |
current pool in use | |
uintptr_t * | freePtr |
current free mem position | |
uintptr_t * | endFree |
end of current chunk | |
Classes | |
struct | Pool_t |
Memory pool. More... |
Has the ability to deallocate all data at once.
|
Memory is allocated internally by chunks. This controls the size of these chunks. |
|
constructor: allocate a pool
|
|
destructor: deallocate all pools
|
|
allocate memory: take memory
|
|
Deallocate: store in the free list.
|
|
C wrapper allocator.
|
|
|
|
An entry in the freeMem table at i gives a free memory block of size i ints. If there are other such blocks, then this memory block contains the pointer to the next free block. This function is a convenience cast for this case. |
|
Check that a given address belongs to a pool or the free list. Used for debugging, this is not a performance critical method.
|
|
Print statistics.
|
|
Print statistics, C style = wrapper to C++.
|
|
Deallocate all pools except the base.
|
|
end of current chunk
|
|
Table of free memory lists. freeMem[i] starts a list of free memory blocks of i INT size |
|
current free mem position
|
|
current pool in use
|