Skip to content

How to get host memory from a host function? #936

Answered by Robbepop
orsinium asked this question in Q&A
Discussion options

You must be logged in to vote

Wasm types such as Memory, Table, Global and Func are deliberately Copy and Clone types and thus cheap to clone. This works since they are just fancy, typed indices into some tables into the Store.

Thus you can simply copy the mem before passing it to the Linker in one of your examples and even put mem into the HostState to access it via host functions amongst others.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by orsinium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants