template <typename BaseAllocator = CrtAllocator>

class MemoryPoolAllocator

Defined at line 130 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

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.

Public Members

static const bool kNeedFree
static const bool kRefCounted

Public Methods

void MemoryPoolAllocator<BaseAllocator> (size_t chunkSize, BaseAllocator * baseAllocator)

Constructor with chunkSize.

Parameters

chunkSize The size of memory chunk. The default is kDefaultChunkSize.
baseAllocator The allocator for allocating memory chunks.

Defined at line 169 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void MemoryPoolAllocator<BaseAllocator> (void * buffer, size_t size, size_t chunkSize, BaseAllocator * baseAllocator)

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.

Defined at line 201 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void MemoryPoolAllocator<BaseAllocator> (const MemoryPoolAllocator<BaseAllocator> & rhs)

Defined at line 216 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

MemoryPoolAllocator<BaseAllocator> & operator= (const MemoryPoolAllocator<BaseAllocator> & rhs)

Defined at line 224 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void MemoryPoolAllocator<BaseAllocator> (MemoryPoolAllocator<BaseAllocator> && rhs)

Defined at line 236 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

MemoryPoolAllocator<BaseAllocator> & operator= (MemoryPoolAllocator<BaseAllocator> && rhs)

Defined at line 244 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void ~MemoryPoolAllocator<BaseAllocator> ()

Destructor.

This deallocates all memory chunks, excluding the user-supplied buffer.

Defined at line 259 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void Clear ()

Deallocates all memory chunks, excluding the first/user one.

Defined at line 277 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

size_t Capacity ()

Computes the total capacity of allocated memory chunks.

Returns

total capacity in bytes.

Defined at line 293 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

size_t Size ()

Computes the memory blocks allocated.

Returns

total used bytes.

Defined at line 304 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

bool Shared ()

Whether the allocator is shared.

Returns

true or false.

Defined at line 315 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void * Malloc (size_t size)

Allocates a memory block. (concept Allocator)

Defined at line 321 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void * Realloc (void * originalPtr, size_t originalSize, size_t newSize)

Resizes a memory block (concept Allocator)

Defined at line 337 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

void Free (void * ptr)

Frees a memory block (concept Allocator)

Defined at line 372 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

bool operator== (const MemoryPoolAllocator<BaseAllocator> & rhs)

Compare (equality) with another MemoryPoolAllocator

Defined at line 375 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h

bool operator!= (const MemoryPoolAllocator<BaseAllocator> & rhs)

Compare (inequality) with another MemoryPoolAllocator

Defined at line 381 of file ../../third_party/rapidjson/include/rapidjson/internal/../allocators.h