NCBI C++ ToolKit
Allocator Class Reference

Search Toolkit Book for rapidjson::Allocator

Concept for allocating, resizing and freeing memory block. More...

#include <misc/jsonwrapp/rapidjson11/allocators.h>

Detailed Description

Concept for allocating, resizing and freeing memory block.

Note that Malloc() and Realloc() are non-static but Free() is static.

So if an allocator need to support Free(), it needs to put its pointer in the header of memory block.

concept Allocator {
static const bool kNeedFree; //!< Whether this allocator needs to call Free().
// Allocate a memory block.
// \param size of the memory block in bytes.
// \returns pointer to the memory block.
void* Malloc(size_t size);
// Resize a memory block.
// \param originalPtr The pointer to current memory block. Null pointer is permitted.
// \param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.)
// \param newSize the new size in bytes.
void* Realloc(void* originalPtr, size_t originalSize, size_t newSize);
// Free a memory block.
// \param pointer to the memory block. Null pointer is permitted.
static void Free(void *ptr);
};
Concept for allocating, resizing and freeing memory block.
#define Realloc
Definition: ncbimem.hpp:121
#define Malloc
Definition: ncbimem.hpp:119
#define Free
Definition: ncbimem.hpp:122
const struct ncbi::grid::netcache::search::fields::SIZE size

The documentation for this class was generated from the following file:
Modified on Fri Sep 20 14:57:06 2024 by modify_doxy.py rev. 669887