diff options
Diffstat (limited to 'system')
-rwxr-xr-x | system/include/emscripten/wire.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/system/include/emscripten/wire.h b/system/include/emscripten/wire.h index dc612e11..10484a61 100755 --- a/system/include/emscripten/wire.h +++ b/system/include/emscripten/wire.h @@ -180,12 +180,18 @@ namespace emscripten { template<> struct BindingType<std::string> { - typedef char* WireType; + typedef struct { + size_t length; + char data[1]; // trailing data + }* WireType; static WireType toWireType(const std::string& v) { - return strdup(v.c_str()); + WireType wt = (WireType)malloc(sizeof(size_t) + v.length()); + wt->length = v.length(); + memcpy(wt->data, v.data(), v.length()); + return wt; } - static std::string fromWireType(char* v) { - return std::string(v); + static std::string fromWireType(WireType v) { + return std::string(v->data, v->length); } static void destroy(WireType v) { free(v); |