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... | |
struct | SharedData |
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 (const MemoryPoolAllocator &rhs) RAPIDJSON_NOEXCEPT | |
MemoryPoolAllocator & | operator= (const MemoryPoolAllocator &rhs) RAPIDJSON_NOEXCEPT |
~MemoryPoolAllocator () RAPIDJSON_NOEXCEPT | |
Destructor. | |
void | Clear () RAPIDJSON_NOEXCEPT |
Deallocates all memory chunks, excluding the first/user one. | |
size_t | Capacity () const RAPIDJSON_NOEXCEPT |
Computes the total capacity of allocated memory chunks. | |
size_t | Size () const RAPIDJSON_NOEXCEPT |
Computes the memory blocks allocated. | |
bool | Shared () const RAPIDJSON_NOEXCEPT |
Whether the allocator is shared. | |
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) | |
bool | operator== (const MemoryPoolAllocator &rhs) const RAPIDJSON_NOEXCEPT |
Compare (equality) with another MemoryPoolAllocator. | |
bool | operator!= (const MemoryPoolAllocator &rhs) const RAPIDJSON_NOEXCEPT |
Compare (inequality) with another MemoryPoolAllocator. | |
Fonctions membres publiques statiques | |
static void | Free (void *ptr) RAPIDJSON_NOEXCEPT |
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) | |
static const bool | kRefCounted = true |
Tell users that this allocator is reference counted on copy. | |
Fonctions membres privées | |
bool | AddChunk (size_t capacity) |
Creates a new chunk. | |
Fonctions membres privées statiques | |
static ChunkHeader * | GetChunkHead (SharedData *shared) |
static uint8_t * | GetChunkBuffer (SharedData *shared) |
static void * | AlignBuffer (void *buf, size_t &size) |
Attributs privés | |
size_t | chunk_capacity_ |
The minimum capacity of chunk when they are allocated. | |
BaseAllocator * | baseAllocator_ |
base allocator for allocating memory chunks. | |
SharedData * | shared_ |
The shared data of the allocator. | |
Attributs privés statiques | |
static const size_t | SIZEOF_SHARED_DATA = RAPIDJSON_ALIGN(sizeof(SharedData)) |
static const size_t | SIZEOF_CHUNK_HEADER = RAPIDJSON_ALIGN(sizeof(ChunkHeader)) |
static const size_t | 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 131 du fichier allocators.h.
|
inlineexplicit |
Constructor with chunkSize.
chunkSize | The size of memory chunk. The default is kDefaultChunkSize. |
baseAllocator | The allocator for allocating memory chunks. |
Définition à la ligne 171 du fichier allocators.h.
Références baseAllocator_, chunk_capacity_, kDefaultChunkCapacity, Malloc(), RAPIDJSON_ASSERT, RAPIDJSON_NEW, et shared_.
Référencé par operator!=(), et operator==().
|
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 202 du fichier allocators.h.
Références baseAllocator_, chunk_capacity_, kDefaultChunkCapacity, RAPIDJSON_ASSERT, et shared_.
|
inline |
Définition à la ligne 217 du fichier allocators.h.
|
inline |
Destructor.
This deallocates all memory chunks, excluding the user-supplied buffer.
Définition à la ligne 260 du fichier allocators.h.
Références baseAllocator_, Clear(), RAPIDJSON_DELETE, et shared_.
|
inlineprivate |
Creates a new chunk.
capacity | Capacity of the chunk in bytes. |
Définition à la ligne 391 du fichier allocators.h.
Références baseAllocator_, RAPIDJSON_NEW, et shared_.
Référencé par Malloc().
|
inlinestaticprivate |
Définition à la ligne 405 du fichier allocators.h.
|
inline |
Computes the total capacity of allocated memory chunks.
Définition à la ligne 294 du fichier allocators.h.
Références RAPIDJSON_NOEXCEPT_ASSERT, et shared_.
|
inline |
Deallocates all memory chunks, excluding the first/user one.
Définition à la ligne 278 du fichier allocators.h.
Références baseAllocator_, MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next, RAPIDJSON_NOEXCEPT_ASSERT, et shared_.
Référencé par ~MemoryPoolAllocator().
|
inlinestatic |
Frees a memory block (concept Allocator)
Définition à la ligne 373 du fichier allocators.h.
|
inlinestaticprivate |
Définition à la ligne 155 du fichier allocators.h.
|
inlinestaticprivate |
Définition à la ligne 151 du fichier allocators.h.
|
inline |
Allocates a memory block. (concept Allocator)
Définition à la ligne 322 du fichier allocators.h.
Références AddChunk(), chunk_capacity_, RAPIDJSON_ALIGN, RAPIDJSON_NOEXCEPT_ASSERT, RAPIDJSON_UNLIKELY, et shared_.
Référencé par MemoryPoolAllocator(), et Realloc().
|
inline |
Compare (inequality) with another MemoryPoolAllocator.
Définition à la ligne 382 du fichier allocators.h.
Références MemoryPoolAllocator(), et operator==().
|
inline |
Définition à la ligne 225 du fichier allocators.h.
|
inline |
Compare (equality) with another MemoryPoolAllocator.
Définition à la ligne 376 du fichier allocators.h.
Références MemoryPoolAllocator(), RAPIDJSON_NOEXCEPT_ASSERT, et shared_.
Référencé par operator!=().
|
inline |
Resizes a memory block (concept Allocator)
Définition à la ligne 338 du fichier allocators.h.
Références Malloc(), RAPIDJSON_ALIGN, RAPIDJSON_NOEXCEPT_ASSERT, et shared_.
|
inline |
Whether the allocator is shared.
Définition à la ligne 316 du fichier allocators.h.
Références RAPIDJSON_NOEXCEPT_ASSERT, et shared_.
|
inline |
Computes the memory blocks allocated.
Définition à la ligne 305 du fichier allocators.h.
Références RAPIDJSON_NOEXCEPT_ASSERT, et shared_.
|
private |
base allocator for allocating memory chunks.
Définition à la ligne 420 du fichier allocators.h.
Référencé par AddChunk(), Clear(), MemoryPoolAllocator(), MemoryPoolAllocator(), et ~MemoryPoolAllocator().
|
private |
The minimum capacity of chunk when they are allocated.
Définition à la ligne 419 du fichier allocators.h.
Référencé par Malloc(), MemoryPoolAllocator(), et MemoryPoolAllocator().
|
staticprivate |
Default chunk capacity.
Définition à la ligne 160 du fichier allocators.h.
Référencé par MemoryPoolAllocator(), et MemoryPoolAllocator().
|
static |
Tell users that no need to call Free() with this allocator. (concept Allocator)
Définition à la ligne 163 du fichier allocators.h.
|
static |
Tell users that this allocator is reference counted on copy.
Définition à la ligne 164 du fichier allocators.h.
|
private |
The shared data of the allocator.
Définition à la ligne 421 du fichier allocators.h.
Référencé par AddChunk(), Capacity(), Clear(), Malloc(), MemoryPoolAllocator(), MemoryPoolAllocator(), operator==(), Realloc(), Shared(), Size(), et ~MemoryPoolAllocator().
|
staticprivate |
Définition à la ligne 149 du fichier allocators.h.
|
staticprivate |
Définition à la ligne 148 du fichier allocators.h.