Downloading the C stdlib Wasm

We need the malloc() and free() functions from C's standard library for the functionality in our C code. WebAssembly doesn't have these functions built in, so we need to provide our own implementation.

Fortunately, someone has already built that for us; we just need to download the module and include it in the instantiation step. The module can be downloaded from Guy Bedford's wasm-stdlib-hack GitHub repository at https://github.com/guybedford/wasm-stdlib-hack. You need the memory.wasm file from the /dist folder. Once the file is downloaded, create a folder named /assets in the /src folder of your project and copy the memory.wasm file there.

You can copy the memory.wasm file from the /chapter-07-cook-the-books/src/assets folder of the learn-webassembly repository instead of downloading it from GitHub.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset