|
size_t | Capacity () const |
| Computes the total capacity of allocated memory chunks. More...
|
|
void | Clear () |
| Deallocates all memory chunks, excluding the user-supplied buffer. More...
|
|
void * | Malloc (size_t size) |
| Allocates a memory block. (concept Allocator) More...
|
|
| MemoryPoolAllocator (size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0) |
| Constructor with chunkSize. More...
|
|
| MemoryPoolAllocator (void *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0) |
| Constructor with user-supplied buffer. More...
|
|
void * | Realloc (void *originalPtr, size_t originalSize, size_t newSize) |
| Resizes a memory block (concept Allocator) More...
|
|
size_t | Size () const |
| Computes the memory blocks allocated. More...
|
|
| ~MemoryPoolAllocator () |
| Destructor. More...
|
|
template<typename BaseAllocator = CrtAllocator>
class MemoryPoolAllocator< BaseAllocator >
Default memory allocator used by the parser and DOM.
This allocator allocate memory blocks from pre-allocated memory chunks.
It does not free memory blocks. And Realloc() only allocate new memory.
The memory chunks are allocated by BaseAllocator, which is CrtAllocator by default.
User may also supply a buffer as the first chunk.
If the user-buffer is full then additional chunks are allocated by BaseAllocator.
The user-buffer is not deallocated by this allocator.
- Template Parameters
-
BaseAllocator | the allocator type for allocating memory chunks. Default is CrtAllocator. |
- Note
- implements Allocator concept
template<typename BaseAllocator = CrtAllocator>
Constructor with user-supplied buffer.
The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size.
The user buffer will not be deallocated when this allocator is destructed.
- Parameters
-
buffer | User supplied buffer. |
size | Size of the buffer in bytes. It must at least larger than sizeof(ChunkHeader). |
chunkSize | The size of memory chunk. The default is kDefaultChunkSize. |
baseAllocator | The allocator for allocating memory chunks. |