Browse Source

src: rename Buffer::Use() to Buffer::New()

Fixes: https://github.com/nodejs/node/issues/2308
PR-URL: https://github.com/nodejs/node/pull/2352
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
v4.0.0-rc
Ben Noordhuis 10 years ago
parent
commit
88419479cc
  1. 4
      src/node_buffer.cc
  2. 10
      src/node_crypto.cc
  3. 2
      src/node_internals.h
  4. 2
      src/stream_wrap.cc
  5. 2
      src/tls_wrap.cc
  6. 2
      src/udp_wrap.cc

4
src/node_buffer.cc

@ -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) {

10
src/node_crypto.cc

@ -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");
@ -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);
}
@ -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);
}
@ -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);
}
@ -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();
}
}

2
src/node_internals.h

@ -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

2
src/stream_wrap.cc

@ -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);
}

2
src/tls_wrap.cc

@ -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>());
}

2
src/udp_wrap.cc

@ -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);
}

Loading…
Cancel
Save