memory

API Reference

Structs

struct Storage<Element>

A reference-counted raw allocation interpreted as contiguous Element slots.

struct ByteStorage

A reference-counted raw byte allocation used by UTF-8 and encoded tables.

Enums

enum Allocation

Describes a memory-management event exposed to the allocation effect.

Effects

effect 'alloc(allocation: Allocation) -> Void

Reports allocation and reference-count transitions to the ambient memory handler.

Functions

func _alloc<Element>(count: Int) 'alloc -> RawPtr

Allocates zero-filled raw storage sized for count values of Element.

func _store<Element>(ptr: RawPtr, consume value: Element) 'alloc -> Void

Moves value into the Element slot at ptr without dropping prior contents.

func _load<Element>(ptr: RawPtr) 'alloc -> Element

Loads and re-owns the Element bits stored at ptr.

func _swap<Element>(a: RawPtr, b: RawPtr) 'alloc -> Void

Exchanges two initialized Element slots without retaining or dropping either.

func replace<Element>(mut place: Element, consume replacement: Element) -> Element

Replaces the current value and returns the previous value.

func _free(ptr: RawPtr) 'alloc -> Void

Release one reference to a raw allocation (frees at zero). Static data is unmanaged: freeing it is a no-op.

func _retain<Element>(value: &Element) 'alloc -> Void

Add one reference to every refcounted buffer value owns — the element half of a copy-on-write buffer copy. Dispatches structurally per specialization (scalars are a no-op; static data is unmanaged), mirroring how a drop of the same value would release.

func _is_unique(ptr: RawPtr) 'alloc -> Bool

Whether this allocation has exactly one owner (refcount 1). Static data is never unique: it cannot be freed, so callers must copy before writing.

func _storage<Element>(capacity: Int) 'alloc -> Storage<Element>

Allocates typed storage with room for capacity elements.