Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emscripten malloc and free across JS and C++

Suppose I allocate some memory M in Javascript via Emscripten _malloc (Javascript). Am I allowed to pass ownership of M into a marshaled C++ function that calls free (C++) on it?

like image 445
Thomas Eding Avatar asked Dec 02 '15 18:12

Thomas Eding


1 Answers

Yes. In Emscripten, the C++ version of malloc is converted to Module._malloc() in JavaScript; likewise Module._free() is the same as C++'s free().

like image 85
Charles Ofria Avatar answered Nov 14 '22 23:11

Charles Ofria