31#ifndef KIMODEM_ARENA_H
32#define KIMODEM_ARENA_H
43#if defined(__WIN64__) || defined(__WIN32__) || defined(WIN32)
96 int SetStatic(uint8_t *mem,
size_t memSize);
114#if defined(__posix__) || defined(__linux__) || defined(__APPLE__)
115 int MemoryMap(
int memFileDes,
size_t memSize);
119 { (void)memFileDes; (void)memSize;
throw NotImplemented(
"WIN32"); }
130 int Create(
const char *path,
size_t fileSize);
147 {
return this->store; }
153 {
return this->store + this->size; }
166 {
return this->size; }
172 {
return this->arenaType; }
193 int Write(
const char *path);
226std::ostream &
operator<<(std::ostream &os, Arena &arena);
Custom exceptions for use in SCSL used in writing test programs.
int Create(const char *path, size_t fileSize)
int SetAlloc(size_t allocSize)
Definition: Arena.cc:68
int SetStatic(uint8_t *mem, size_t memSize)
Definition: Arena.cc:58
int Write(const char *path)
Definition: Arena.cc:337
bool Ready() const
Ready returns whether the arena is initialized.
Definition: Arena.h:175
int Open(const char *path)
void Destroy()
Definition: Arena.cc:257
uint8_t * Start() const
Definition: Arena.h:146
uint8_t & operator[](size_t index)
Definition: Arena.cc:364
void Clear()
Clear zeroizes the memory in the arena.
Definition: Arena.cc:246
ArenaType Type() const
Definition: Arena.h:171
bool CursorInArena(const uint8_t *cursor)
Definition: Arena.cc:226
size_t Size() const
Definition: Arena.h:165
Arena()
An Arena is initialized with no backing memory.
Definition: Arena.cc:45
~Arena()
Definition: Arena.cc:51
uint8_t * End()
Definition: Arena.h:152
int MemoryMap(int memFileDes, size_t memSize)
Definition: Arena.h:118
Definition: Exceptions.h:37
scsl is the top-level namespace containing all the code in this library.
Definition: scsl.h:43
ArenaType
Definition: Arena.h:58
@ 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:299