Skip to content

C API: reading and writing guest memory outside a host call #193

Description

@kadircanyildirm-crypto

spacewasm_mem_read, spacewasm_mem_write and spacewasm_mem_size all take a spacewasm_caller_t * (include/spacewasm.h:808-832), which only exists inside a host-function callback. From the embedder's side of spacewasm_invoke/spacewasm_run there is no way to touch linear memory: a component cannot stage an input buffer before invoking a guest function, or read a result buffer after spacewasm_run returns, without routing it through an extra host call. The Rust side has this (Engine::memory; Memory::load/store/size/grow in src/memory.rs:167-300).

Would an engine-level counterpart be welcome, e.g. spacewasm_engine_mem_read/_write/_size taking spacewasm_t * with the same bounds-checked semantics, plus grow? If so I can send it as a PR in crates/spacewasm_c_api with C tests in spacewasm_c_example; opening this first per CONTRIBUTING.md.

AI use per AI_POLICY.md: Claude Code assisted with reviewing the header and drafting this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions