Default memory allocator used by the parser and DOM. Plus de détails...
#include <arcane/utils/internal/json/rapidjson/allocators.h>
Classes | |
struct | ChunkHeader |
Chunk header for perpending to each chunk. Plus de détails... | |
Fonctions membres publiques | |
MemoryPoolAllocator (size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0) | |
Constructor with chunkSize. | |
MemoryPoolAllocator (void *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0) | |
Constructor with user-supplied buffer. | |
~MemoryPoolAllocator () | |
Destructor. | |
void | Clear () |
Deallocates all memory chunks, excluding the user-supplied buffer. | |
size_t | Capacity () const |
Computes the total capacity of allocated memory chunks. | |
size_t | Size () const |
Computes the memory blocks allocated. | |
void * | Malloc (size_t size) |
Allocates a memory block. (concept Allocator) | |
void * | Realloc (void *originalPtr, size_t originalSize, size_t newSize) |
Resizes a memory block (concept Allocator) | |
Fonctions membres publiques statiques | |
static void | Free (void *ptr) |
Frees a memory block (concept Allocator) | |
Attributs publics statiques | |
static const bool | kNeedFree = false |
Tell users that no need to call Free() with this allocator. (concept Allocator) | |
Fonctions membres privées | |
MemoryPoolAllocator (const MemoryPoolAllocator &rhs) | |
Copy constructor is not permitted. | |
MemoryPoolAllocator & | operator= (const MemoryPoolAllocator &rhs) |
Copy assignment operator is not permitted. | |
bool | AddChunk (size_t capacity) |
Creates a new chunk. | |
Attributs privés | |
ChunkHeader * | chunkHead_ |
Head of the chunk linked-list. Only the head chunk serves allocation. | |
size_t | chunk_capacity_ |
The minimum capacity of chunk when they are allocated. | |
void * | userBuffer_ |
User supplied buffer. | |
BaseAllocator * | baseAllocator_ |
base allocator for allocating memory chunks. | |
BaseAllocator * | ownBaseAllocator_ |
base allocator created by this object. | |
Attributs privés statiques | |
static const int | kDefaultChunkCapacity = RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY |
Default chunk capacity. | |
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.
BaseAllocator | the allocator type for allocating memory chunks. Default is CrtAllocator. |
Définition à la ligne 116 du fichier allocators.h.
|
inline |
Constructor with chunkSize.
chunkSize | The size of memory chunk. The default is kDefaultChunkSize. |
baseAllocator | The allocator for allocating memory chunks. |
Définition à la ligne 124 du fichier allocators.h.
|
inline |
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.
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. |
Définition à la ligne 139 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::ChunkHeader::capacity, MemoryPoolAllocator< BaseAllocator >::chunkHead_, MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next, RAPIDJSON_ASSERT, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::size.
|
inline |
Destructor.
This deallocates all memory chunks, excluding the user-supplied buffer.
Définition à la ligne 153 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::Clear(), MemoryPoolAllocator< BaseAllocator >::ownBaseAllocator_, et RAPIDJSON_DELETE.
|
inlineprivate |
Creates a new chunk.
capacity | Capacity of the chunk in bytes. |
Définition à la ligne 251 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::baseAllocator_, MemoryPoolAllocator< BaseAllocator >::chunkHead_, MemoryPoolAllocator< BaseAllocator >::ownBaseAllocator_, RAPIDJSON_ALIGN, et RAPIDJSON_NEW.
Référencé par MemoryPoolAllocator< BaseAllocator >::Malloc().
|
inline |
Computes the total capacity of allocated memory chunks.
Définition à la ligne 172 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::chunkHead_, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next.
|
inline |
Deallocates all memory chunks, excluding the user-supplied buffer.
Définition à la ligne 159 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::baseAllocator_, MemoryPoolAllocator< BaseAllocator >::chunkHead_, MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next, MemoryPoolAllocator< BaseAllocator >::ChunkHeader::size, et MemoryPoolAllocator< BaseAllocator >::userBuffer_.
Référencé par MemoryPoolAllocator< BaseAllocator >::~MemoryPoolAllocator().
|
inlinestatic |
Frees a memory block (concept Allocator)
Définition à la ligne 239 du fichier allocators.h.
|
inline |
Allocates a memory block. (concept Allocator)
Définition à la ligne 190 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::AddChunk(), MemoryPoolAllocator< BaseAllocator >::ChunkHeader::capacity, MemoryPoolAllocator< BaseAllocator >::chunk_capacity_, MemoryPoolAllocator< BaseAllocator >::chunkHead_, RAPIDJSON_ALIGN, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::size.
Référencé par MemoryPoolAllocator< BaseAllocator >::Realloc().
|
inline |
Resizes a memory block (concept Allocator)
Définition à la ligne 205 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::chunkHead_, MemoryPoolAllocator< BaseAllocator >::Malloc(), RAPIDJSON_ALIGN, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::size.
|
inline |
Computes the memory blocks allocated.
Définition à la ligne 182 du fichier allocators.h.
Références MemoryPoolAllocator< BaseAllocator >::chunkHead_, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next.
|
private |
base allocator for allocating memory chunks.
Définition à la ligne 279 du fichier allocators.h.
Référencé par MemoryPoolAllocator< BaseAllocator >::AddChunk(), et MemoryPoolAllocator< BaseAllocator >::Clear().
|
private |
The minimum capacity of chunk when they are allocated.
Définition à la ligne 277 du fichier allocators.h.
Référencé par MemoryPoolAllocator< BaseAllocator >::Malloc().
|
private |
Head of the chunk linked-list. Only the head chunk serves allocation.
Définition à la ligne 276 du fichier allocators.h.
Référencé par MemoryPoolAllocator< BaseAllocator >::AddChunk(), MemoryPoolAllocator< BaseAllocator >::Capacity(), MemoryPoolAllocator< BaseAllocator >::Clear(), MemoryPoolAllocator< BaseAllocator >::Malloc(), MemoryPoolAllocator< BaseAllocator >::MemoryPoolAllocator(), MemoryPoolAllocator< BaseAllocator >::Realloc(), et MemoryPoolAllocator< BaseAllocator >::Size().
|
staticprivate |
Default chunk capacity.
Définition à la ligne 265 du fichier allocators.h.
|
static |
Tell users that no need to call Free() with this allocator. (concept Allocator)
Définition à la ligne 118 du fichier allocators.h.
|
private |
base allocator created by this object.
Définition à la ligne 280 du fichier allocators.h.
Référencé par MemoryPoolAllocator< BaseAllocator >::AddChunk(), et MemoryPoolAllocator< BaseAllocator >::~MemoryPoolAllocator().
|
private |
User supplied buffer.
Définition à la ligne 278 du fichier allocators.h.
Référencé par MemoryPoolAllocator< BaseAllocator >::Clear().