Last active
February 16, 2021 22:10
-
-
Save mattdesl/3691e3fa39f3615aa0246f4d9828ac1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get a pointer to 16 bytes of WASM memory | |
const byteLength = 16; | |
const pointer = Module._malloc(byteLength); | |
// e.g. let's set all values to 0xff (255) | |
for (let i = 0; i < byteLength; i++) { | |
const idx = pointer + i; | |
Module.HEAPU8[idx] = 0xff; | |
} | |
// when we are done with the pointer, make sure to release it | |
Module._free(pointer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment