abla/unsafe/memory
Generated from source.
Import with import "abla/unsafe/memory".
Source: abla/unsafe/memory/entry.ab
ablaUnsafeAllocate (fun)
@__abla_trusted_only("error")
trusted noescape fun ablaUnsafeAllocate(size: int): i64*
Allocates size bytes of runtime-tracked native storage. The caller owns the returned pointer until freeing it or transferring ownership.
ablaUnsafeFree (fun)
@__abla_trusted_only("error")
trusted noescape fun ablaUnsafeFree(pointer: i64*): void
Releases the native allocation at pointer. Pass an owned allocation and stop using it after release.
ablaUnsafeCStringAddress (extern)
trusted noescape extern:"intrinsic" fun ablaUnsafeCStringAddress(value: string): int
Returns the borrowed address of NUL-terminated string storage, which is valid while value remains live.
ablaUnsafeAdoptString (extern)
trusted noescape extern:"intrinsic" fun ablaUnsafeAdoptString(
address: i64*,
length: int
): string
Takes ownership of a platform allocation with at least length + 1 bytes.
ablaUnsafeBorrowCString (extern)
trusted noescape extern:"intrinsic" fun ablaUnsafeBorrowCString(address: i64*): string
Borrows a NUL-terminated string for the lifetime guaranteed by the caller.
NativeI64Cell (class)
@__abla_trusted_only("error: allocate one with nativeI64Cell(value)")
resource class NativeI64Cell(
val address: i64*,
var closed: bool
)
Owns an eight-byte native slot holding a signed integer. Drop or close frees the slot.
NativeI64Cell.drop (method)
trusted fun drop(): void
Frees the cell storage if it is still open.
NativePointerCell (class)
@__abla_trusted_only("error: allocate one with nativePointerCell(value)")
resource class NativePointerCell(
val address: i64*,
var closed: bool,
val ownsAllocation: bool
)
A native pointer slot with explicit ownership. Drop or close frees the slot only when ownsAllocation is true. The pointed-to object is separate.
NativePointerCell.drop (method)
trusted fun drop(): void
Frees the cell storage if the cell is open and owns its allocation.
NativeByteBuffer (class)
@__abla_trusted_only("error: allocate one with nativeByteBuffer(capacity)")
resource class NativeByteBuffer(
val address: i64*,
val capacity: int,
var closed: bool
)
An owned native byte allocation and its capacity. Drop or close releases it unless adoptString transferred ownership.
NativeByteBuffer.drop (method)
trusted fun drop(): void
Frees the buffer storage if it has not already been closed or adopted.
nativeI64Cell (fun)
trusted fun nativeI64Cell(value: int): NativeI64Cell
Allocates an owned native slot initialized to value.
NativeI64Cell.load (extension fun)
trusted fun NativeI64Cell.load(): int
Reads the integer in the slot, or zero after close.
nativeI64CellStore (fun)
trusted fun nativeI64CellStore(
var cell: NativeI64Cell,
value: int
): bool
Stores value in the cell and returns true, or returns false for a closed cell.
NativeI64Cell.store (extension fun)
trusted fun NativeI64Cell.store(value: int): bool
Stores value and returns true while the cell is open. Returns false after close.
NativeI64Cell.close (extension fun)
trusted fun NativeI64Cell.close(): bool
Frees the cell's allocation and returns true. Further closes return false.
nativePointerCell (fun)
trusted fun nativePointerCell(value: i64*): NativePointerCell
Allocates an owned native slot containing pointer value. Ownership is of the slot only.
nativeCStringAddress (fun)
@__abla_trusted_only("error")
trusted fun nativeCStringAddress(value: string): int
Creates a NUL-terminated native copy of value and returns its address as an integer. Use it immediately for a native call. Keeping only the address does not keep the copy alive.
nativeStringDataAddress (fun)
@__abla_trusted_only("error")
trusted fun nativeStringDataAddress(value: string): int
The address of the string's own bytes (value.size of them, no NUL after them), valid while the string lives: for a length-delimited write, with no copy.
adoptNativeString (fun)
@__abla_trusted_only("error")
trusted fun adoptNativeString(address: int, length: int): string
Transfers a native allocation into an Abla string without copying it. The caller must have allocated at least length + 1 bytes at address and must not use or release that allocation after this call.
nativeCString (fun)
@__abla_trusted_only("error")
trusted fun nativeCString(value: i64*): string
Copies a NUL-terminated native string into a string of its own, which stays valid after the native memory is released or reused. A null pointer reads as "".
borrowNativeCString (fun)
@__abla_trusted_only("error")
trusted fun borrowNativeCString(value: i64*): string
A NUL-terminated native string read in place, without a copy: valid only while that memory is. A string made from it can share its bytes too (a template such as "${s}", + with an empty side, a long concatenation, a stored value), so one that outlives the memory comes from nativeCString.
nativeByteBuffer (fun)
trusted fun nativeByteBuffer(capacity: int): NativeByteBuffer
Allocates a native buffer with capacity bytes. Negative capacity is treated as zero.
NativeByteBuffer.load (extension fun)
trusted fun NativeByteBuffer.load(index: int): int
Reads an unsigned byte at index, or zero for a closed buffer or an out-of-bounds index.
NativeByteBuffer.loadI64 (extension fun)
trusted fun NativeByteBuffer.loadI64(offset: int): int
Reads eight bytes as a native signed integer starting at byte offset. Returns zero when closed or the full word does not fit.
NativeByteBuffer.pointerAt (extension fun)
trusted fun NativeByteBuffer.pointerAt(offset: int): i64*
Returns the native pointer at byte offset while the buffer remains open. Allows the one-past-end address. Closed buffers and offsets outside the range 0 through capacity return null.
nativeByteBufferStore (fun)
trusted fun nativeByteBufferStore(
var buffer: NativeByteBuffer,
index: int,
value: int
): bool
Stores the low byte of value and returns true, or returns false for a closed buffer or an out-of-range index.
NativeByteBuffer.store (extension fun)
trusted fun NativeByteBuffer.store(index: int, value: int): bool
Stores the low byte of value at byte index. Returns false when closed or out of bounds.
nativeByteBufferStoreI64 (fun)
trusted fun nativeByteBufferStoreI64(
var buffer: NativeByteBuffer,
offset: int,
value: int
): bool
Stores eight native-order bytes and returns true, or returns false if the buffer is closed or the word does not fit.
NativeByteBuffer.storeI64 (extension fun)
trusted fun NativeByteBuffer.storeI64(offset: int, value: int): bool
Stores value as eight native-order bytes at byte offset. Returns false when closed or the full word does not fit.
nativeByteBufferStorePointer (fun)
trusted fun nativeByteBufferStorePointer(
var buffer: NativeByteBuffer,
offset: int,
value: i64*
): bool
Stores a native pointer and returns true, or returns false if the buffer is closed or has fewer than eight bytes at the offset.
NativeByteBuffer.storePointer (extension fun)
trusted fun NativeByteBuffer.storePointer(
offset: int,
value: i64*
): bool
Stores pointer value in eight bytes at byte offset. Returns false when closed or the full pointer does not fit.
NativeByteBuffer.adoptString (extension fun)
trusted fun NativeByteBuffer.adoptString(length: int): string
Transfers this allocation into a string of length bytes and marks the buffer closed. Returns an empty string for a closed buffer or a length below zero or at least capacity. A rejected length leaves an open buffer unchanged.
NativeByteBuffer.close (extension fun)
trusted fun NativeByteBuffer.close(): bool
Releases the native allocation and returns true. Returns false after close or successful adoption.
NativePointerCell.load (extension fun)
trusted fun NativePointerCell.load(): i64*
Reads the stored pointer, or a null pointer after close.
nativePointerCellStore (fun)
trusted fun nativePointerCellStore(
var cell: NativePointerCell,
value: i64*
): bool
Stores the pointer and returns true, or returns false for a closed cell.
NativePointerCell.store (extension fun)
trusted fun NativePointerCell.store(value: i64*): bool
Stores pointer value and returns true while open. Returns false after close.
NativePointerCell.close (extension fun)
trusted fun NativePointerCell.close(): bool
Closes the cell and returns true only when it released an owned allocation.
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.