memory

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtismFree

func ExtismFree(offset ExtismPointer)

extismFree releases the bytes previously allocated with `extism_alloc` at the given `offset`.

func ExtismLength

func ExtismLength(offset ExtismPointer) uint64

extismLength returns the number of bytes associated with the block of host memory located at `offset`.

func ExtismLengthUnsafe

func ExtismLengthUnsafe(ExtismPointer) uint64

func ExtismLoadU8

func ExtismLoadU8(offset ExtismPointer) uint8

func ExtismLoadU64

func ExtismLoadU64(offset ExtismPointer) uint64

extismLoadU64 returns the 64-bit unsigned integer at location `offset` in the host memory block. Note that `offset` must lie on an 8-byte boundary.

func ExtismStoreU8

func ExtismStoreU8(offset ExtismPointer, v uint8)

func ExtismStoreU64

func ExtismStoreU64(offset ExtismPointer, v uint64)

extismStoreU64 stores the 64-bit unsigned integer value `v` at location `offset` in the host memory block. Note that `offset` must lie on an 8-byte boundary.

func Load

func Load(offset ExtismPointer, buf []byte)

func Store

func Store(offset ExtismPointer, buf []byte)

Types

type ExtismPointer

type ExtismPointer uint64

func ExtismAlloc

func ExtismAlloc(length uint64) ExtismPointer

extismAlloc allocates `length` bytes of data with host memory for use by the plugin and returns its offset within the host memory block.

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory represents memory allocated by (and shared with) the host.

func Allocate

func Allocate(length int) Memory

Allocate allocates `length` uninitialized bytes on the host.

func AllocateBytes

func AllocateBytes(data []byte) Memory

AllocateBytes allocates and saves the `data` into Memory on the host.

func NewMemory

func NewMemory(offset ExtismPointer, length uint64) Memory

func (*Memory) Free

func (m *Memory) Free()

Free frees the host memory block.

func (*Memory) Length

func (m *Memory) Length() uint64

Length returns the number of bytes in the host memory block.

func (*Memory) Load

func (m *Memory) Load(buffer []byte)

Load copies the host memory block to the provided `buffer` byte slice.

func (*Memory) Offset

func (m *Memory) Offset() uint64

Offset returns the offset of the host memory block.

func (*Memory) ReadBytes

func (m *Memory) ReadBytes() []byte

ReadBytes returns the host memory block as a slice of bytes.

func (*Memory) Store

func (m *Memory) Store(data []byte)

Store copies the `data` byte slice into host memory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL