Permalink
Browse files

updated for new node buffer format

  • Loading branch information...
1 parent 10e79a1 commit 2dbea799b717e8368a0aaf719fdc5c674c5eac2b @substack substack committed Nov 20, 2010
Showing with 12 additions and 4 deletions.
  1. +12 −4 base64.cc
View
@@ -128,8 +128,11 @@ base64_encode_binding(const Arguments &args)
if (!Buffer::HasInstance(args[0]))
return VException("Argument should be a buffer");
- Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
- char *str = base64_encode((unsigned char *)buffer->data(), buffer->length());
+ v8::Handle<v8::Object> buffer = args[0]->ToObject();
+ char *str = base64_encode(
+ (unsigned char *) Buffer::Data(buffer),
+ Buffer::Length(buffer)
+ );
Local<String> ret = String::New(str);
delete [] str;
return scope.Close(ret);
@@ -146,8 +149,13 @@ base64_decode_binding(const Arguments &args)
int outlen;
unsigned char *decoded;
if (Buffer::HasInstance(args[0])) { // buffer
- Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
- decoded = base64_decode(buffer->data(), buffer->length(), &outlen);
+ v8::Handle<v8::Object> buffer = args[0]->ToObject();
+
+ decoded = base64_decode(
+ Buffer::Data(buffer),
+ Buffer::Length(buffer),
+ &outlen
+ );
}
else { // string
String::AsciiValue b64data(args[0]->ToString());

0 comments on commit 2dbea79

Please sign in to comment.