25 #ifndef KIMODEM_ARENA_H
26 #define KIMODEM_ARENA_H
37 #if defined(__WIN64__) || defined(__WIN32__) || defined(WIN32)
108 #if defined(__posix__) || defined(__linux__) || defined(__APPLE__)
109 int MemoryMap(
int memFileDes,
size_t memSize);
113 { (void)memFileDes; (void)memSize;
throw NotImplemented(
"WIN32"); }
124 int Create(
const char *path,
size_t fileSize);
141 {
return this->store; }
147 {
return this->store + this->size; }
160 {
return this->size; }
166 {
return this->arenaType; }
Custom exceptions for use in SCSL used in writing test programs.
Fixed, pre-allocated memory.
Definition: Arena.h:74
int Create(const char *path, size_t fileSize)
int SetAlloc(size_t allocSize)
int SetStatic(uint8_t *mem, size_t memSize)
int Write(const char *path)
uint8_t * End()
Definition: Arena.h:146
bool Ready() const
Ready returns whether the arena is initialized.
Definition: Arena.h:169
int Open(const char *path)
void Clear()
Clear zeroizes the memory in the arena.
ArenaType Type() const
Definition: Arena.h:165
bool CursorInArena(const uint8_t *cursor)
size_t Size() const
Definition: Arena.h:159
Arena()
An Arena is initialized with no backing memory.
uint8_t & operator[](size_t index)
uint8_t * Start() const
Definition: Arena.h:140
int MemoryMap(int memFileDes, size_t memSize)
Definition: Arena.h:112
scsl is the top-level namespace containing all the code in this library.
Definition: scsl.h:43
ArenaType
Definition: Arena.h:52
@ 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)