Skip to content
Try Kata

native.mem

Raw allocation operations. Each call requires an unsafe block.

All modules · Writing docstrings

func alloc(capacity: Int): RawPtr

Requires an unsafe block.

Allocates an empty raw slot array with at least capacity storage.

func free(raw: RawPtr): Nil

Requires an unsafe block.

Releases a raw allocation; using an invalid or already-freed handle errors.

func read(raw: RawPtr, index: Int)

Requires an unsafe block.

Reads a slot, returning nil when index is beyond the current length; freed handles error.

func write(raw: RawPtr, index: Int, value): Nil

Requires an unsafe block.

Writes a slot, extending intervening positions with nil; freed handles error.

func capacity(raw: RawPtr): Int

Requires an unsafe block.

Returns allocation capacity; freed handles error.

func len(raw: RawPtr): Int

Requires an unsafe block.

Returns initialized slot count; freed handles error.

func bin_from_raw(raw: RawPtr, len: Int): Bin

Requires an unsafe block.

Reads exactly len Byte slots into a Bin; errors on freed handles, non-Byte values, or bounds.