Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
Heap arena implementation. More...
#include <heap_arena.h>
Public Member Functions | |
HeapArena () | |
Initialize. More... | |
size_t | num_allocations () const |
Get number of allocated blocks. More... | |
size_t | num_guard_failures () const |
Get number of guard failures. More... | |
virtual void * | allocate (size_t size) |
Allocate memory. More... | |
virtual void | deallocate (void *) |
Deallocate previously allocated memory. More... | |
Public Member Functions inherited from roc::core::IArena | |
template<class T > | |
void | destroy_object (T &object) |
Destroy object and deallocate its memory. More... | |
Static Public Member Functions | |
static void | set_flags (size_t flags) |
Set flags, for all instances. More... | |
Heap arena implementation.
Uses malloc() and free().
The memory is always maximum aligned.
Implements three safety measures:
Allocated chunks have the following format:
ChunkHeader contains pointer to the owning arena, checked when returning memory to arena. ChunkCanary contains magic bytes filled when returning memory to user, and checked when returning memory to arena.
Thread-safe.
Definition at line 60 of file heap_arena.h.
roc::core::HeapArena::HeapArena | ( | ) |
Initialize.
|
virtual |
Allocate memory.
Implements roc::core::IArena.
|
virtual |
Deallocate previously allocated memory.
Implements roc::core::IArena.
size_t roc::core::HeapArena::num_allocations | ( | ) | const |
Get number of allocated blocks.
size_t roc::core::HeapArena::num_guard_failures | ( | ) | const |
Get number of guard failures.
|
static |
Set flags, for all instances.
Parameters
flags
defines options to modify behaviour as indicated in HeapArenaFlags