diff options
author | Chad Austin <chad@imvu.com> | 2013-05-09 16:58:38 -0700 |
---|---|---|
committer | Chad Austin <chad@imvu.com> | 2013-05-17 12:58:36 -0700 |
commit | 40037cce12465baa90e642c1b3c48dcc7d1ed237 (patch) | |
tree | 0541c84b6af2cf5590f6a403d47086fa9b5687b5 /system | |
parent | 17ab8d9f57f0cb31d2d83555ae898b32b99600f8 (diff) |
Workaround a bug in LLVM? Emscripten? that causes it to generate terrible code when registering class methods and properties.
Diffstat (limited to 'system')
-rw-r--r-- | system/include/emscripten/bind.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h index 715a9713..3c5a8266 100644 --- a/system/include/emscripten/bind.h +++ b/system/include/emscripten/bind.h @@ -417,11 +417,10 @@ namespace emscripten { // TODO: This could do a reinterpret-cast if sizeof(T) === sizeof(void*) template<typename T> - inline void* getContext(const T& t) { + inline T* getContext(const T& t) { // not a leak because this is called once per binding - void* p = malloc(sizeof(T)); - assert(p); - memcpy(p, &t, sizeof(T)); + T* p = reinterpret_cast<T*>(malloc(sizeof(T))); + new(p) T(t); return p; } |