|
(Note that these are not member functions.)
|
OPHeap * | OPHeapOpen (const char *path, int flags) |
| OPHeap constructor which opens a memory mapped file to hold the heap. More...
|
|
OPHeap * | OPHeapOpenTmp () |
| OPHeap constructor which uses a temporal file to hold the heap. More...
|
|
void | OPHeapMSync (OPHeap *heap) |
| Flushes changes in OPHeap to the file that holds the heap. More...
|
|
void | OPHeapClose (OPHeap *heap) |
| Flushes the changes in OPHeap to disk, closes the file, and un-maps the memory. More...
|
|
void | OPHeapStorePtr (OPHeap *heap, void *ptr, int pos) |
| Store a pointer to a root pointer slot in OPHeap. More...
|
|
void * | OPHeapRestorePtr (OPHeap *heap, int pos) |
| Restore a pointer from specified root pointer slot. More...
|
|
void * | OPMalloc (OPHeap *heap, size_t size) __attribute__((malloc)) |
| Allocate an object from OPHeap with given size. More...
|
|
void * | OPCalloc (OPHeap *heap, size_t num, size_t size) __attribute__((malloc)) |
| Allocate a chunk of memory filled with 0s. More...
|
|
void * | OPMallocAdviced (OPHeap *heap, size_t size, int advice) __attribute__((malloc)) |
| Allocate an object of given size with an arena hint. More...
|
|
void * | OPCallocAdviced (OPHeap *heap, size_t num, size_t size, int advice) __attribute__((malloc)) |
| Allocate a chunk of memory filled with 0s with an arena hint. More...
|
|
void | OPDealloc (void *addr) |
| Dealloc an object created by OPHeap. More...
|
|
static OPHeap * | ObtainOPHeap (void *addr) |
| Given any pointer in the OPHeap, returns the pointer to OPHeap. More...
|
|
Memory allocator object with persistent storage on disk.
OPHeap * OPHeapOpen |
( |
const char * |
path, |
|
|
int |
flags |
|
) |
| |
|
related |
OPHeap constructor which opens a memory mapped file to hold the heap.
Opens a memory mapped file to hold the heap. User can use the flags to control the behavior for opening the file. The flag must include one of the following modes: O_RDONLY
, O_WRONLY
, or O_RDWR
. These flags coresponds to read-only, write-only, or read/write. In addition, user can bitwise-or the other flags open() supports. (system dependent). See man OPEN(2) for more details.
To create an empty heap with new file, use the O_CREAT
flag. For using previous saved OPHeap file, simply specify the path to the existing OPHeap file and you're all set.
If there were any errors on opening the file, the errno would be set appropriately.
This constructor is thread safe.
- Parameters
-
path | Path to file that holds the heap. |
flags | flags passed to the open() system call. |
- Returns
- An OPHeap instance if succeeded, otherwise NULL.
heap =
OPHeapOpen(
"/path/to/my/opheap", O_RDWR | O_CREAT);