15 #ifndef RAPIDJSON_ALLOCATORS_H_ 16 #define RAPIDJSON_ALLOCATORS_H_ 71 void*
Realloc(
void* originalPtr,
size_t originalSize,
size_t newSize) {
77 return std::realloc(originalPtr, newSize);
101 template <
typename BaseAllocator = CrtAllocator>
161 capacity +=
c->capacity;
191 void*
Realloc(
void* originalPtr,
size_t originalSize,
size_t newSize) {
192 if (originalPtr == 0)
202 if (originalSize >= newSize)
207 size_t increment =
static_cast<size_t>(newSize - originalSize);
215 if (
void* newBuffer =
Malloc(newSize)) {
241 chunk->capacity = capacity;
271 #endif // RAPIDJSON_ENCODINGS_H_ const GLvoid * ptr
Definition: nx_glsym.h:242
size_t chunk_capacity_
The minimum capacity of chunk when they are allocated.
Definition: allocators.h:263
static void Free(void *ptr)
Frees a memory block (concept Allocator)
Definition: allocators.h:225
Default memory allocator used by the parser and DOM.
Definition: allocators.h:102
common definitions and configuration
BaseAllocator * baseAllocator_
base allocator for allocating memory chunks.
Definition: allocators.h:265
GLuint buffer
Definition: glext.h:6555
static const bool kNeedFree
Tell users that no need to call Free() with this allocator. (concept Allocator)
Definition: allocators.h:104
#define RAPIDJSON_NEW(x)
! customization point for global new
Definition: rapidjson.h:586
GLsizeiptr size
Definition: glext.h:6559
C-runtime library allocator.
Definition: allocators.h:62
size_t size
Current size of allocated memory in bytes.
Definition: allocators.h:258
#define RAPIDJSON_ALIGN(x)
Data alignment of the machine.
Definition: rapidjson.h:275
ChunkHeader * chunkHead_
Head of the chunk linked-list. Only the head chunk serves allocation.
Definition: allocators.h:262
#define next(ls)
Definition: llex.c:32
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
size_t Size() const
Computes the memory blocks allocated.
Definition: allocators.h:168
~MemoryPoolAllocator()
Destructor.
Definition: allocators.h:139
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
const GLubyte * c
Definition: glext.h:9812
static const int kDefaultChunkCapacity
Default chunk capacity.
Definition: allocators.h:251
Chunk header for perpending to each chunk.
Definition: allocators.h:256
ChunkHeader * next
Next chunk in the linked list.
Definition: allocators.h:259
void * Malloc(size_t size)
Allocates a memory block. (concept Allocator)
Definition: allocators.h:176
MemoryPoolAllocator & operator=(const MemoryPoolAllocator &rhs)
Copy assignment operator is not permitted.
#define NULL
Pointer to 0.
Definition: gctypes.h:65
MemoryPoolAllocator(size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
Constructor with chunkSize.
Definition: allocators.h:110
static const bool kNeedFree
Definition: allocators.h:64
BaseAllocator * ownBaseAllocator_
base allocator created by this object.
Definition: allocators.h:266
void * Malloc(size_t size)
Definition: allocators.h:65
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
Definition: allocators.h:71
size_t Capacity() const
Computes the total capacity of allocated memory chunks.
Definition: allocators.h:158
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:402
bool AddChunk(size_t capacity)
Creates a new chunk.
Definition: allocators.h:237
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition: rapidjson.h:590
static void Free(void *ptr)
Definition: allocators.h:79
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
void * userBuffer_
User supplied buffer.
Definition: allocators.h:264
void Clear()
Deallocates all memory chunks, excluding the user-supplied buffer.
Definition: allocators.h:145
Definition: video4linux2.c:51
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
Capacity of the chunk in bytes (excluding the header itself).
Definition: allocators.h:257
void * memcpy(void *dst, const void *src, size_t len)
Definition: string.c:26
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
Resizes a memory block (concept Allocator)
Definition: allocators.h:191