16 #ifndef KIMODEM_ARENA_H
17 #define KIMODEM_ARENA_H
25 #include "Exceptions.h"
28 #if defined(__WIN64__) || defined(__WIN32__) || defined(WIN32)
81 int SetStatic(uint8_t *mem,
size_t memSize);
99 #if defined(__posix__) || defined(__linux__) || defined(__APPLE__)
100 int MemoryMap(
int memFileDes,
size_t memSize);
104 { (void)memFileDes; (void)memSize;
throw NotImplemented(
"WIN32"); }
115 #if defined(__posix__) || defined(__linux__) || defined(__APPLE__)
116 int Create(
const char *path,
size_t fileSize);
117 #elif defined(__WIN64__) || defined(__WIN32__) || defined(WIN32)
118 int Create(
const char *path,
size_t fileSize);
137 {
return this->store; }
143 {
return this->store + this->size; }
156 {
return this->size; }
162 {
return this->arenaType; }
183 int Write(
const char *path);
216 std::ostream &
operator<<(std::ostream &os, Arena &arena);
int SetAlloc(size_t allocSize)
Definition: Arena.cc:50
int SetStatic(uint8_t *mem, size_t memSize)
Definition: Arena.cc:40
int Write(const char *path)
Definition: Arena.cc:319
uint8_t * End()
Definition: Arena.h:142
bool Ready() const
Ready returns whether the arena is initialized.
Definition: Arena.h:165
int Open(const char *path)
void Destroy()
Definition: Arena.cc:239
uint8_t & operator[](size_t index)
Definition: Arena.cc:346
void Clear()
Clear zeroizes the memory in the arena.
Definition: Arena.cc:228
ArenaType Type() const
Definition: Arena.h:161
bool CursorInArena(const uint8_t *cursor)
Definition: Arena.cc:208
size_t Size() const
Definition: Arena.h:155
Arena()
An Arena is initialized with no backing memory.
Definition: Arena.cc:27
uint8_t * Start() const
Definition: Arena.h:136
int MemoryMap(int memFileDes, size_t memSize)
Definition: Arena.h:103
Definition: Exceptions.h:19
scsl is the top-level namespace containing all the code in this library.
Definition: scsl.h:37
ArenaType
Definition: Arena.h:43
@ Static
Static is an arena backed by a static block of memory.
@ MemoryMapped
MemoryMapped is an arena backed by a memory-mapped file.
@ Uninit
Uninit is an unintialized arena.
@ Alloc
Alloc is an arena backed by allocated memory.
std::ostream & operator<<(std::ostream &os, Arena &arena)
Definition: Arena.cc:281