diff options
author | Chad Austin <chad@imvu.com> | 2013-03-01 16:21:30 -0800 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-12 14:24:45 +0300 |
commit | 50c5092c4a37565558e6ffab7602e778b6774e2a (patch) | |
tree | bf1b717e4d5f20cbdef454aaa9b8bef68fb8d21e | |
parent | 1a352601847328eb9f60b5c7068b8f18ab28ddc6 (diff) |
Kill the malloc(16) by writing a test with a 1 MB smart pointer type :)
-rwxr-xr-x | src/embind/embind.js | 6 | ||||
-rwxr-xr-x | system/include/emscripten/bind.h | 7 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index aab20b69..8da583ba 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -601,11 +601,7 @@ RegisteredPointer.prototype.toWireType = function(destructors, handle) { } var ptr = staticPointerCast(handle.$$.ptr, fromRawType, this.pointeeType.rawType); if (this.isSmartPointer) { - // todo: if ptr == handle.$$.ptr, there's no need to allocate a new smartPtr! - // todo: _malloc(16) is not big enough - var smartPtr = _malloc(16); - handle.$$.pointeeType.smartPointerType.rawConstructor(smartPtr, ptr, handle.$$.smartPtr); - ptr = smartPtr; + ptr = handle.$$.pointeeType.smartPointerType.rawConstructor(ptr, handle.$$.smartPtr); destructors.push(handle.$$.pointeeType.smartPointerType.rawDestructor); destructors.push(ptr); } diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index e8f21be4..9120a095 100755 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -275,8 +275,11 @@ namespace emscripten { } template<typename PointerType> - typename std::shared_ptr<PointerType> raw_smart_pointer_constructor(PointerType *ptr, std::shared_ptr<PointerType> basePtr, void (PointerType*)) { - return std::shared_ptr<PointerType>(basePtr, ptr); + typename std::shared_ptr<PointerType>* raw_smart_pointer_constructor( + PointerType *ptr, + std::shared_ptr<PointerType>* basePtr + ) { + return new std::shared_ptr<PointerType>(*basePtr, ptr); } template<typename ClassType> |