CoolProp  4.2.5
An open-source fluid property and humid air property database
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
rapidjson::MemoryPoolAllocator< BaseAllocator > Class Template Reference

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

#include <rapidjson.h>

Inheritance diagram for rapidjson::MemoryPoolAllocator< BaseAllocator >:
rapidjson::Allocator

Public Member Functions

 MemoryPoolAllocator (size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=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 ()
 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...
 
size_t Size ()
 Computes the memory blocks allocated. More...
 
voidMalloc (size_t size)
 Allocates a memory block. (concept Allocator) More...
 
voidRealloc (void *originalPtr, size_t originalSize, size_t 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. (concept 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.

Definition at line 160 of file rapidjson.h.

Constructor & Destructor Documentation

template<typename BaseAllocator = CrtAllocator>
rapidjson::MemoryPoolAllocator< BaseAllocator >::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.

Definition at line 168 of file rapidjson.h.

template<typename BaseAllocator = CrtAllocator>
rapidjson::MemoryPoolAllocator< BaseAllocator >::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.

\param buffer User supplied buffer.
\param size Size of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).
\param chunkSize The size of memory chunk. The default is kDefaultChunkSize.
\param baseAllocator The allocator for allocating memory chunks.

Definition at line 186 of file rapidjson.h.

template<typename BaseAllocator = CrtAllocator>
rapidjson::MemoryPoolAllocator< BaseAllocator >::~MemoryPoolAllocator ( )
inline

Destructor.

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

Definition at line 200 of file rapidjson.h.

Member Function Documentation

template<typename BaseAllocator = CrtAllocator>
size_t rapidjson::MemoryPoolAllocator< BaseAllocator >::Capacity ( )
inline

Computes the total capacity of allocated memory chunks.

Returns
total capacity in bytes.

Definition at line 217 of file rapidjson.h.

template<typename BaseAllocator = CrtAllocator>
void rapidjson::MemoryPoolAllocator< BaseAllocator >::Clear ( )
inline

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

Definition at line 206 of file rapidjson.h.

template<typename BaseAllocator = CrtAllocator>
static void rapidjson::MemoryPoolAllocator< BaseAllocator >::Free ( void )
inlinestatic

Frees a memory block (concept Allocator)

Definition at line 275 of file rapidjson.h.

template<typename BaseAllocator = CrtAllocator>
void* rapidjson::MemoryPoolAllocator< BaseAllocator >::Malloc ( size_t  size)
inline

Allocates a memory block. (concept Allocator)

Definition at line 235 of file rapidjson.h.

template<typename BaseAllocator = CrtAllocator>
void* rapidjson::MemoryPoolAllocator< BaseAllocator >::Realloc ( void originalPtr,
size_t  originalSize,
size_t  newSize 
)
inline

Resizes a memory block (concept Allocator)

Definition at line 249 of file rapidjson.h.

template<typename BaseAllocator = CrtAllocator>
size_t rapidjson::MemoryPoolAllocator< BaseAllocator >::Size ( )
inline

Computes the memory blocks allocated.

Returns
total used bytes.

Definition at line 227 of file rapidjson.h.

Member Data Documentation

template<typename BaseAllocator = CrtAllocator>
const bool rapidjson::MemoryPoolAllocator< BaseAllocator >::kNeedFree = false
static

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

Definition at line 162 of file rapidjson.h.


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