Emscripten malloc,跨JS和C ++免费发布 [英] Emscripten malloc and free across JS and C++

查看:52
本文介绍了Emscripten malloc,跨JS和C ++免费发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我通过Emscripten _malloc (Javascript)在Javascript中分配了一些内存M.我是否可以将M的所有权传递给在其上调用 free (C ++)的经过编组的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?

推荐答案

是.在Emscripten中,malloc的C ++版本在JavaScript中转换为Module._malloc().同样,Module._free()与C ++的free()相同.

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().

这篇关于Emscripten malloc,跨JS和C ++免费发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆