diff --git a/src/node_buffer.h b/src/node_buffer.h index ea33112..ef7cf4f 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -65,6 +65,7 @@ namespace node { class NODE_EXTERN Buffer: public ObjectWrap { public: + static v8::Persistent constructor_template; static bool HasInstance(v8::Handle val); @@ -99,8 +100,6 @@ class NODE_EXTERN Buffer: public ObjectWrap { free_callback callback, void *hint); // public constructor private: - static v8::Persistent constructor_template; - static v8::Handle New(const v8::Arguments &args); static v8::Handle BinarySlice(const v8::Arguments &args); static v8::Handle AsciiSlice(const v8::Arguments &args); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 95a19c7..b363049 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -149,13 +149,17 @@ Handle StreamWrap::ReadStop(const Arguments& args) { } -inline char* StreamWrap::NewSlab(Handle global, - Handle wrap_obj) { - Buffer* b = Buffer::New(SLAB_SIZE); - global->SetHiddenValue(slab_sym, b->handle_); +char* StreamWrap::NewSlab(Handle global, + Handle wrap_obj) { + HandleScope scope; + Local arg = Integer::NewFromUnsigned(SLAB_SIZE); + Local b = Buffer::constructor_template->GetFunction()-> + NewInstance(1, &arg); + if (b.IsEmpty()) return NULL; + global->SetHiddenValue(slab_sym, b); assert(Buffer::Length(b) == SLAB_SIZE); slab_used = 0; - wrap_obj->SetHiddenValue(slab_sym, b->handle_); + wrap_obj->SetHiddenValue(slab_sym, b); return Buffer::Data(b); }