diff options
author | James M Snell <jasnell@gmail.com> | 2020-05-07 23:31:56 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-05-31 02:20:00 +0300 |
commit | 56ff1ee55a57b1169dc567f0f51e58a6f2ccda6d (patch) | |
tree | 581a72ccbbd7f82765943a982372f21069d5ecac /src/stream_base.cc | |
parent | c24b74a7abec0848484671771d250cfd961f128e (diff) |
src: extract AllocatedBuffer from env.h
Cleanup up env.h by removing things that are not
specific to `Environment`.
PR-URL: https://github.com/nodejs/node/pull/33291
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/stream_base.cc')
-rw-r--r-- | src/stream_base.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/stream_base.cc b/src/stream_base.cc index d8a191dc2e5..b35df39afe9 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -1,6 +1,7 @@ #include "stream_base.h" // NOLINT(build/include_inline) #include "stream_base-inl.h" #include "stream_wrap.h" +#include "allocated_buffer-inl.h" #include "node.h" #include "node_buffer.h" @@ -132,7 +133,7 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) { AllocatedBuffer storage; if (storage_size > 0) - storage = env->AllocateManaged(storage_size); + storage = AllocatedBuffer::AllocateManaged(env, storage_size); offset = 0; if (!all_buffers) { @@ -276,12 +277,12 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) { if (try_write) { // Copy partial data - data = env->AllocateManaged(buf.len); + data = AllocatedBuffer::AllocateManaged(env, buf.len); memcpy(data.data(), buf.base, buf.len); data_size = buf.len; } else { // Write it - data = env->AllocateManaged(storage_size); + data = AllocatedBuffer::AllocateManaged(env, storage_size); data_size = StringBytes::Write(env->isolate(), data.data(), storage_size, @@ -486,7 +487,7 @@ void StreamResource::ClearError() { uv_buf_t EmitToJSStreamListener::OnStreamAlloc(size_t suggested_size) { CHECK_NOT_NULL(stream_); Environment* env = static_cast<StreamBase*>(stream_)->stream_env(); - return env->AllocateManaged(suggested_size).release(); + return AllocatedBuffer::AllocateManaged(env, suggested_size).release(); } void EmitToJSStreamListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) { |