cocos2d-x  2.2.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MemoryPoolAllocator< BaseAllocator > Class Template Reference

Default memory allocator used by the parser and DOM. More...

#include <rapidjson.h>

Inheritance diagram for MemoryPoolAllocator< BaseAllocator >:
Allocator

Public Member Functions

 MemoryPoolAllocator (size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
 Constructor with chunkSize. More...
 
 MemoryPoolAllocator ( var kDefaultChunkCapacity, var 0)
 Constructor with chunkSize. More...
 
 MemoryPoolAllocator ( local kDefaultChunkCapacity, local 0)
 Constructor with chunkSize. More...
 
 MemoryPoolAllocator (char *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
 Constructor with user-supplied buffer. More...
 
 MemoryPoolAllocator ( var buffer, var size, var kDefaultChunkCapacity, var 0)
 Constructor with user-supplied buffer. More...
 
 MemoryPoolAllocator ( local buffer, local size, local kDefaultChunkCapacity, local 0)
 Constructor with user-supplied buffer. More...
 
 ~MemoryPoolAllocator ()
 Destructor. More...
 
void Clear ()
 Deallocates all memory chunks, excluding the user-supplied buffer. More...
 
size_t Capacity ()
 Computes the total capacity of allocated memory chunks. More...
 
var Capacity ()
 Computes the total capacity of allocated memory chunks. More...
 
local Capacity ()
 Computes the total capacity of allocated memory chunks. More...
 
size_t Size ()
 Computes the memory blocks allocated. More...
 
local Size ()
 Computes the memory blocks allocated. More...
 
void * Malloc (size_t size)
 Allocates a memory block. (concept Allocator) More...
 
var Malloc ( var size)
 Allocates a memory block. (concept Allocator) More...
 
local Malloc ( local size)
 Allocates a memory block. (concept Allocator) More...
 
void * Realloc (void *originalPtr, size_t originalSize, size_t newSize)
 Resizes a memory block (concept Allocator) More...
 
var Realloc ( var originalPtr, var originalSize, var newSize)
 Resizes a memory block (concept Allocator) More...
 
local Realloc ( local originalPtr, local originalSize, local newSize)
 Resizes a memory block (concept Allocator) More...
 

Static Public Member Functions

static void Free (void *)
 Frees a memory block (concept Allocator) More...
 

Static Public Attributes

static const bool kNeedFree = false
 Tell users that no need to call Free() with this allocator. More...
 
var kNeedFree = false
 Tell users that no need to call Free() with this allocator. More...
 
local kNeedFree = false
 Tell users that no need to call Free() with this allocator. More...
 

Detailed Description

template<typename BaseAllocator = CrtAllocator>
class rapidjson::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
BaseAllocatorthe allocator type for allocating memory chunks. Default is CrtAllocator.

Constructor & Destructor Documentation

MemoryPoolAllocator ( size_t  chunkSize = kDefaultChunkCapacity,
BaseAllocator *  baseAllocator = 0 
)
inline

Constructor with chunkSize.

Parameters
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.
var MemoryPoolAllocator ( var  chunkSize = kDefaultChunkCapacity,
var  baseAllocator = 0 
)
inline

Constructor with chunkSize.

Parameters
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.
local MemoryPoolAllocator ( local  chunkSize = kDefaultChunkCapacity,
local  baseAllocator = 0 
)
inline

Constructor with chunkSize.

Parameters
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.
MemoryPoolAllocator ( char *  buffer,
size_t  size,
size_t  chunkSize = kDefaultChunkCapacity,
BaseAllocator *  baseAllocator = 0 
)
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.

Parameters
bufferUser supplied buffer.
sizeSize of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.
var MemoryPoolAllocator ( var  buffer,
var  size,
var  chunkSize = kDefaultChunkCapacity,
var  baseAllocator = 0 
)
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.

Parameters
bufferUser supplied buffer.
sizeSize of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.
local MemoryPoolAllocator ( local  buffer,
local  size,
local  chunkSize = kDefaultChunkCapacity,
local  baseAllocator = 0 
)
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.

Parameters
bufferUser supplied buffer.
sizeSize of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.
~MemoryPoolAllocator ( )
inline

Destructor.

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

var ~MemoryPoolAllocator ( )
inline

Destructor.

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

local ~MemoryPoolAllocator ( )
inline

Destructor.

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

Member Function Documentation

size_t Capacity ( )
inline

Computes the total capacity of allocated memory chunks.

Returns
total capacity in bytes.
var Capacity ( )
inline

Computes the total capacity of allocated memory chunks.

Returns
total capacity in bytes.
local Capacity ( )
inline

Computes the total capacity of allocated memory chunks.

Returns
total capacity in bytes.
void Clear ( )
inline

Deallocates all memory chunks, excluding the user-supplied buffer.

var Clear ( )
inline

Deallocates all memory chunks, excluding the user-supplied buffer.

local Clear ( )
inline

Deallocates all memory chunks, excluding the user-supplied buffer.

static void Free ( void *  )
inlinestatic

Frees a memory block (concept Allocator)

var Free ( var  )
inlinestatic

Frees a memory block (concept Allocator)

local Free ( local  )
inlinestatic

Frees a memory block (concept Allocator)

void* Malloc ( size_t  size)
inline

Allocates a memory block. (concept Allocator)

var Malloc ( var  size)
inline

Allocates a memory block. (concept Allocator)

local Malloc ( local  size)
inline

Allocates a memory block. (concept Allocator)

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

Resizes a memory block (concept Allocator)

var Realloc ( var  originalPtr,
var  originalSize,
var  newSize 
)
inline

Resizes a memory block (concept Allocator)

local Realloc ( local  originalPtr,
local  originalSize,
local  newSize 
)
inline

Resizes a memory block (concept Allocator)

size_t Size ( )
inline

Computes the memory blocks allocated.

Returns
total used bytes.
var Size ( )
inline

Computes the memory blocks allocated.

Returns
total used bytes.
local Size ( )
inline

Computes the memory blocks allocated.

Returns
total used bytes.

Member Data Documentation

const bool kNeedFree = false
static

Tell users that no need to call Free() with this allocator.

(concept Allocator)

var kNeedFree = false
static

Tell users that no need to call Free() with this allocator.

(concept Allocator)

local kNeedFree = false
static

Tell users that no need to call Free() with this allocator.

(concept Allocator)


The documentation for this class was generated from the following file: