|
CookMem 1.4.0
A C++ memory context / allocator
|
#include <mmaparena.h>
Public Member Functions | |
| MmapArena (std::size_t minSize=DEFAULT_MIN_SEGMENT_SIZE, int prot=(PROT_READ|PROT_WRITE), int flag=(MAP_PRIVATE|MAP_ANONYMOUS)) | |
| void * | getSegment (std::size_t &size) |
| bool | freeSegment (void *ptr, std::size_t size) |
| void | releaseAll () |
An mmap/munmap 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. |
| prot | mmap protection flag |
| flag | mmap flag |
Free an arena segment using munamp().
| ptr | the pointer to be freed. |
| size | the size of the pointer. |
|
inline |
Allocate an arena segment using mmap().
| 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.