Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: removing duplicate code #1144

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,7 @@ Local<Object> New(Environment* env, size_t length) {
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);

// TODO(trevnorris): done like this to handle HasInstance since only checks
// if external array data has been set, but would like to use a better
// approach if v8 provided one.
char* data;
if (length > 0) {
data = static_cast<char*>(malloc(length));
if (data == nullptr)
FatalError("node::Buffer::New(size_t)", "Out Of Memory");
} else {
data = nullptr;
}
smalloc::Alloc(env, obj, data, length);
smalloc::Alloc(env, obj, length);

return scope.Escape(obj);
}
Expand Down