Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

How to allocate memory #48

Open
dignifiedquire opened this issue Dec 15, 2017 · 4 comments
Open

How to allocate memory #48

dignifiedquire opened this issue Dec 15, 2017 · 4 comments

Comments

@dignifiedquire
Copy link

dignifiedquire commented Dec 15, 2017

I am trying to implement a way of passing more complex data between wasm and go and was looking for something like malloc which emscripten provides to allocate a new memory block, where I can write data into from the outside, to make it available to the program. Eg

//.. load code
mystringbytes := []byte("hello")
offset, _ := vm.Malloc(len(mystringbytes))
memory := vm.Memory()
for i, b := range mystringbytes {
  memory[offset+i] = b
}

// passing the pointer to the code which now can find mystringbytes in memory be resolving the pointer + length
o, _ := vm.ExecCode(m, offset, uint64(len(mystringbytes))
@cznic
Copy link

cznic commented Dec 15, 2017

Shameless plug: perhaps something like this can be of some use?

@sbinet
Copy link
Contributor

sbinet commented Dec 16, 2017

I must admit this is an area I haven't yet dedicated too many cycles to.
Obviously, that's something we want to provide.

@cznic all your packages are on my radar :)

@dignifiedquire
Copy link
Author

dignifiedquire commented Dec 16, 2017 via email

@sbinet
Copy link
Contributor

sbinet commented Jun 28, 2018

@dignifiedquire there's some work happening in the memory allocation/manipulation area: #59

do you have some input? (here or directly on the PR.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants