44 // \param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.)
104 static const bool kNeedFree = false; //!< Tell users that no need to call Free() with this allocator. (concept Allocator)
110 MemoryPoolAllocator(size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
116 /*! The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size.
125 MemoryPoolAllocator(void *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :
185 void *buffer = reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size;
206 if (originalPtr == reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size - originalSize) {
240 if (ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) {
Default memory allocator used by the parser and DOM.
Definition allocators.h:102
static const bool kNeedFree
Tell users that no need to call Free() with this allocator. (concept Allocator).
Definition allocators.h:104
void * Malloc(size_t size)
Allocates a memory block. (concept Allocator).
Definition allocators.h:176
MemoryPoolAllocator(size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
Constructor with chunkSize.
Definition allocators.h:110
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
Resizes a memory block (concept Allocator).
Definition allocators.h:191
static void Free(void *ptr)
Frees a memory block (concept Allocator).
Definition allocators.h:225
void Clear()
Deallocates all memory chunks, excluding the user-supplied buffer.
Definition allocators.h:145
size_t Size() const
Computes the memory blocks allocated.
Definition allocators.h:168
~MemoryPoolAllocator()
Destructor.
Definition allocators.h:139
MemoryPoolAllocator(void *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
Constructor with user-supplied buffer.
Definition allocators.h:125
size_t Capacity() const
Computes the total capacity of allocated memory chunks.
Definition allocators.h:158
common definitions and configuration
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition rapidjson.h:590