|
CookMem 1.4.0
A C++ memory context / allocator
|
#include <mallocarena.h>
Public Member Functions | |
| MallocArena (std::size_t minSize=DEFAULT_MIN_SEGMENT_SIZE) | |
| void * | getSegment (std::size_t &size) |
| bool | freeSegment (void *ptr, std::size_t) |
| void | releaseAll () |
An malloc/free based memory arena.
This class implements the interface of MemArena without explicitly inheriting from it. This is to avoid the overhead of virtual function calls and allows inlining of the functions.
|
inline |
Constructor.
| minSize | minimum segment size. It should be noted that this value needs to be a multiple of 16. |
Free an arena segment using free.
| ptr | the pointer to be freed. |
|
inline |
Allocate an arena segment using malloc.
| size | the size of the segment. This value is updated upon successful request to indicate the actual size obtained. |
|
inline |
Release all segments held by this arena. This arena does not keep any segments, so this function does nothing.