File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -62,17 +62,15 @@ Handle<Value> Wrapper::ToBuffer(const Arguments& args) {
6262
6363 int len = args[0 ]->ToNumber ()->Value ();
6464
65- Buffer *slowBuffer = Buffer::New (
66- const_cast <char *>(std::string ((const char *)const_cast <void *>(ObjectWrap::Unwrap<Wrapper>(args.This ())->GetValue ())).c_str ()),
67- len);
68-
6965 Local<Function> bufferConstructor = Local<Function>::Cast (
7066 Context::GetCurrent ()->Global ()->Get (String::New (" Buffer" )));
7167
72- Handle<Value> constructorArgs[3 ] = { slowBuffer->handle_ , Integer::New (len), Integer::New (0 ) };
73- Local<Object> fastBuffer = bufferConstructor->NewInstance (3 , constructorArgs);
68+ Handle<Value> constructorArgs[1 ] = { Integer::New (len) };
69+ Local<Object> nodeBuffer = bufferConstructor->NewInstance (1 , constructorArgs);
70+
71+ memcpy (node::Buffer::Data (nodeBuffer), ObjectWrap::Unwrap<Wrapper>(args.This ())->GetValue (), len);
7472
75- return scope.Close (fastBuffer );
73+ return scope.Close (nodeBuffer );
7674}
7775
7876
You can’t perform that action at this time.
0 commit comments