"std:mem"Memory allocation and management. Provides the Allocator function type and functions for system memory allocation.
View source on Codeberg →type Allocator func(uintptr, uint) uintptr
Allocator is a function type representing a memory allocator. It takes a pointer and a size, and returns a pointer to the allocated memory.
func DefaultAllocator(ptr uintptr, sz uint) uintptr
The default memory allocator implementation. Takes a pointer and a size, and returns a pointer to the allocated memory.
func SetSystemAllocator(a Allocator)
Replaces the current system allocator with the provided Allocator function.
func SystemAllocate(ptr uintptr, sz uint) uintptr
Allocates memory using the current system allocator. Takes a pointer and a size, and returns a pointer to the allocated memory.
func Allocate(sz uint) uintptr
Allocates a block of memory of the given size and returns a pointer to it.
func Free(ptr any)
Frees previously allocated memory pointed to by the given pointer.
func MemCopy(dst uintptr, src uintptr, n uint)
Copies n bytes from src to dst. The memory regions must not overlap; use MemMove for overlapping regions.
func MemMove(dst uintptr, src uintptr, n uint)
Copies n bytes from src to dst, correctly handling overlapping memory regions.
func MemSet(dst uintptr, val byte, n uint)
Sets n bytes at dst to the value val.