Created
December 4, 2010 16:26
-
-
Save edvakf/728295 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/msgpack.cc b/src/msgpack.cc | |
| index 0803d67..818fe5d 100644 | |
| --- a/src/msgpack.cc | |
| +++ b/src/msgpack.cc | |
| @@ -288,8 +288,7 @@ pack(const Arguments &args) { | |
| } | |
| } | |
| - Buffer *bp = Buffer::New(sb._sbuf.size); | |
| - memcpy(bp->data(), sb._sbuf.data, sb._sbuf.size); | |
| + Buffer *bp = Buffer::New(sb._sbuf.data, sb._sbuf.size); | |
| return scope.Close(bp->handle_); | |
| } | |
| @@ -311,19 +310,19 @@ unpack(const Arguments &args) { | |
| String::New("First argument must be a Buffer"))); | |
| } | |
| - Buffer *buf = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject()); | |
| + Handle<Object> buf = args[0]->ToObject(); | |
| MsgpackZone mz; | |
| msgpack_object mo; | |
| size_t off = 0; | |
| - switch (msgpack_unpack(buf->data(), buf->length(), &off, &mz._mz, &mo)) { | |
| + switch (msgpack_unpack(Buffer::Data(buf), Buffer::Length(buf), &off, &mz._mz, &mo)) { | |
| case MSGPACK_UNPACK_EXTRA_BYTES: | |
| case MSGPACK_UNPACK_SUCCESS: | |
| try { | |
| msgpack_unpack_template->GetFunction()->Set( | |
| msgpack_bytes_remaining_symbol, | |
| - Integer::New(buf->length() - off) | |
| + Integer::New(Buffer::Length(buf) - off) | |
| ); | |
| return scope.Close(msgpack_to_v8(&mo)); | |
| } catch (MsgpackException e) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment