Skip to content

Commit

Permalink
src: rename Buffer::Use() to Buffer::New()
Browse files Browse the repository at this point in the history
Fixes: #2308
PR-URL: #2352
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
bnoordhuis committed Aug 13, 2015
1 parent 9a3929d commit 8841947
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ MaybeLocal<Object> New(Isolate* isolate, char* data, size_t length) {
Environment* env = Environment::GetCurrent(isolate);
EscapableHandleScope handle_scope(env->isolate());
Local<Object> obj;
if (Buffer::Use(env, data, length).ToLocal(&obj))
if (Buffer::New(env, data, length).ToLocal(&obj))
return handle_scope.Escape(obj);
return Local<Object>();
}


MaybeLocal<Object> Use(Environment* env, char* data, size_t length) {
MaybeLocal<Object> New(Environment* env, char* data, size_t length) {
EscapableHandleScope scope(env->isolate());

if (length > 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3006,7 +3006,7 @@ void CipherBase::GetAuthTag(const FunctionCallbackInfo<Value>& args) {
unsigned int out_len = 0;

if (cipher->GetAuthTag(&out, &out_len)) {
Local<Object> buf = Buffer::Use(env, out, out_len).ToLocalChecked();
Local<Object> buf = Buffer::New(env, out, out_len).ToLocalChecked();
args.GetReturnValue().Set(buf);
} else {
env->ThrowError("Attempting to get auth tag in unsupported state");
Expand Down Expand Up @@ -4481,7 +4481,7 @@ void ECDH::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
return env->ThrowError("Failed to compute ECDH key");
}

Local<Object> buf = Buffer::Use(env, out, out_len).ToLocalChecked();
Local<Object> buf = Buffer::New(env, out, out_len).ToLocalChecked();
args.GetReturnValue().Set(buf);
}

Expand Down Expand Up @@ -4519,7 +4519,7 @@ void ECDH::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
}

Local<Object> buf =
Buffer::Use(env, reinterpret_cast<char*>(out), size).ToLocalChecked();
Buffer::New(env, reinterpret_cast<char*>(out), size).ToLocalChecked();
args.GetReturnValue().Set(buf);
}

Expand All @@ -4546,7 +4546,7 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
}

Local<Object> buf =
Buffer::Use(env, reinterpret_cast<char*>(out), size).ToLocalChecked();
Buffer::New(env, reinterpret_cast<char*>(out), size).ToLocalChecked();
args.GetReturnValue().Set(buf);
}

Expand Down Expand Up @@ -4949,7 +4949,7 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
size_t size;
req->return_memory(&data, &size);
argv[0] = Null(req->env()->isolate());
argv[1] = Buffer::Use(req->env(), data, size).ToLocalChecked();
argv[1] = Buffer::New(req->env(), data, size).ToLocalChecked();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ v8::MaybeLocal<v8::Object> New(Environment* env,
// Takes ownership of |data|. Must allocate |data| with malloc() or realloc()
// because ArrayBufferAllocator::Free() deallocates it again with free().
// Mixing operator new and free() is undefined behavior so don't do that.
v8::MaybeLocal<v8::Object> Use(Environment* env, char* data, size_t length);
v8::MaybeLocal<v8::Object> New(Environment* env, char* data, size_t length);
} // namespace Buffer

} // namespace node
Expand Down
2 changes: 1 addition & 1 deletion src/stream_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void StreamWrap::OnReadImpl(ssize_t nread,
CHECK_EQ(pending, UV_UNKNOWN_HANDLE);
}

Local<Object> obj = Buffer::Use(env, base, nread).ToLocalChecked();
Local<Object> obj = Buffer::New(env, base, nread).ToLocalChecked();
wrap->EmitData(nread, obj, pending_obj);
}

Expand Down
2 changes: 1 addition & 1 deletion src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ void TLSWrap::OnReadSelf(ssize_t nread,
TLSWrap* wrap = static_cast<TLSWrap*>(ctx);
Local<Object> buf_obj;
if (buf != nullptr)
buf_obj = Buffer::Use(wrap->env(), buf->base, buf->len).ToLocalChecked();
buf_obj = Buffer::New(wrap->env(), buf->base, buf->len).ToLocalChecked();
wrap->EmitData(nread, buf_obj, Local<Object>());
}

Expand Down
2 changes: 1 addition & 1 deletion src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
}

char* base = static_cast<char*>(realloc(buf->base, nread));
argv[2] = Buffer::Use(env, base, nread).ToLocalChecked();
argv[2] = Buffer::New(env, base, nread).ToLocalChecked();
argv[3] = AddressToJS(env, addr);
wrap->MakeCallback(env->onmessage_string(), ARRAY_SIZE(argv), argv);
}
Expand Down

0 comments on commit 8841947

Please sign in to comment.