B.3. Direct function calls
The Emscripten ccall and cwrap functions are typically the ones used when calling a function in a module because they help with things like memory management of strings when it’s not necessary for the string to be long-lived.
It’s possible to call the module’s function directly, but doing so means your code will need to handle all the necessary memory management. If your code is already doing all the necessary memory management, or the calls involve only floats and integers, which don’t require memory management, then this might be an approach for you to consider.
When the Emscripten compiler creates the WebAssembly module, it puts an underscore character in front of the function names. It’s important to remember ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access