-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
I'm trying to compile my project in such a way that I can pass a javascript typed array into an exported wasm function.
From every tutorial I read online in order to do this I have to copy the buffer of the typed array into the wasm heap like this:
var buf = Module._malloc(desiredLength);
Module.HEAPU8.set(typedArray, buf);
Module.ccall('my_function', 'number', ['number'], [buf]);
However when I try to run this code in the browser I get this error:
Module._malloc is not a function
This is what I am using to compile my c++ code:
emcc myProject.cpp -s WASM=1 -s EXPORTED_FUNCTIONS="['_processData']" -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']" -O3 -o index.js
Is there any reason for this error? Did I set something up incorrectly? Any help would be much appreciated.