diff options
author | Chad Austin <chad@imvu.com> | 2013-05-03 19:15:06 -0700 |
---|---|---|
committer | Chad Austin <chad@imvu.com> | 2013-05-17 12:57:10 -0700 |
commit | 69d3621782e4b6dc131a2e5d78fdcf92047d667c (patch) | |
tree | 1e77c92de3d3610be00b52f571c638d457faca79 | |
parent | a020f7dc1d37e986a2ce26a960ec1c1be5734f97 (diff) |
We can get away with passing memory_view on the stack here...
-rw-r--r-- | src/embind/embind.js | 2 | ||||
-rw-r--r-- | system/include/emscripten/wire.h | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index 0e004e40..c3cdd23a 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -473,11 +473,9 @@ function __embind_register_memory_view(rawType, name) { var type = HEAPU32[handle >> 2]; var size = HEAPU32[(handle >> 2) + 1]; // in elements var data = HEAPU32[(handle >> 2) + 2]; // byte offset into emscripten heap - _free(handle); var TA = typeMapping[type]; return new TA(HEAP8.buffer, data, size); }, - destructorFunction: function(ptr) { _free(ptr); }, }); } diff --git a/system/include/emscripten/wire.h b/system/include/emscripten/wire.h index 32080e54..a5892216 100644 --- a/system/include/emscripten/wire.h +++ b/system/include/emscripten/wire.h @@ -377,11 +377,16 @@ namespace emscripten { namespace internal { template<> struct BindingType<memory_view> { - typedef memory_view* WireType; + // This non-word-sized WireType only works because I + // happen to know that clang will pass aggregates as + // pointers to stack elements and we never support + // converting JavaScript typed arrays back into + // memory_view. (That is, fromWireType is not implemented + // on the C++ side, nor is toWireType implemented in + // JavaScript.) + typedef memory_view WireType; static WireType toWireType(const memory_view& mv) { - WireType wt = (WireType)malloc(sizeof(memory_view)); - new(wt) memory_view(mv); - return wt; + return mv; } }; } |