api

alloc.ch

Declarations in alloc.ch

1 declarationsstd

Declarations

Public only
std#
Publicnamespace
namespace std
alloc#
Publicnamespace
namespace alloc
Layout#
Publicstruct
struct Layout { var size : size_t var align_ : size_t }
make#
PublicfunctionConstructor
func make(s : size_t, a : size_t) : Layout
of#
Publicfunction
func of<T>() : Layout
AllocError#
Publicvariant
variant AllocError { var OutOfMemory : AllocError }
Allocator#
Publicinterface
interface Allocator
alloc#
Publicfunction
func alloc(self : &Allocator, layout : Layout) : Result<*void, AllocError>
dealloc#
Publicfunction
func dealloc(self : &Allocator, ptr : *void, layout : Layout) : void
grow#
Publicfunction
func grow(self : &Allocator, old : *void, old_layout : Layout, new_size : size_t) : Result<*void, AllocError>
shrink#
Publicfunction
func shrink(self : &Allocator, old : *void, old_layout : Layout, new_size : size_t) : Result<*void, AllocError>
AllocRecord#
struct
struct AllocRecord { var ptr : *void var size : size_t var next : *AllocRecord }
Debug tracking types
DebugTracker#
struct
struct DebugTracker { var head : *AllocRecord var count : size_t var total_bytes : size_t }
debug_tracker_create#
function
func debug_tracker_create() : *DebugTracker
debug_tracker_record_alloc#
function
func debug_tracker_record_alloc(tracker : *DebugTracker, ptr : *void, size : size_t) : void
debug_tracker_record_dealloc#
function
func debug_tracker_record_dealloc(tracker : *DebugTracker, ptr : *void) : void
debug_tracker_destroy#
function
func debug_tracker_destroy(tracker : *DebugTracker) : void
debug_tracker_print_leaks#
function
func debug_tracker_print_leaks(tracker : *DebugTracker) : void
GlobalAllocator#
Publicstruct
struct GlobalAllocator { var _debug : *void }
GlobalAllocator — wraps malloc/free with optional debug tracking
make#
PublicfunctionConstructor
func make() : GlobalAllocator
alloc#
Publicfunction
func alloc(self : &GlobalAllocator, layout : Layout) : Result<*void, AllocError>
dealloc#
Publicfunction
func dealloc(self : &GlobalAllocator, ptr : *void, layout : Layout) : void
grow#
Publicfunction
func grow(self : &GlobalAllocator, old : *void, old_layout : Layout, new_size : size_t) : Result<*void, AllocError>
shrink#
Publicfunction
func shrink(self : &GlobalAllocator, old : *void, old_layout : Layout, new_size : size_t) : Result<*void, AllocError>
alloc_zeroed#
Publicfunction
func alloc_zeroed(self : &GlobalAllocator, layout : Layout) : Result<*void, AllocError>
check_leaks#
Publicfunction
func check_leaks(self : &GlobalAllocator) : void
destroy#
Publicfunction
func destroy(self : &GlobalAllocator) : void
alloc_bytes#
Publicfunction
func alloc_bytes(size : size_t) : Result<*void, AllocError>
Convenience free functions (bypass GlobalAllocator)
dealloc_bytes#
Publicfunction
func dealloc_bytes(ptr : *void) : void
alloc_zeroed_bytes#
Publicfunction
func alloc_zeroed_bytes(size : size_t) : Result<*void, AllocError>