Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: src/api.cc

Issue 2797653002: [wasm] Module Builder v8 API: bytes passed in are owned by caller. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 43c6912d5d928b28d9b0368266e34fa7957078ae..d532f34af8a3999ebc1bde7cf2409871d78b6794 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -7590,9 +7590,14 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(Isolate* isolate,
Utils::ToLocal(maybe_compiled.ToHandleChecked()));
}
-void WasmModuleObjectBuilder::OnBytesReceived(
- std::unique_ptr<const uint8_t[]>&& bytes, size_t size) {
- received_buffers_.push_back(Buffer(std::move(bytes), size));
+void WasmModuleObjectBuilder::OnBytesReceived(const uint8_t* bytes,
+ size_t size) {
+ std::unique_ptr<uint8_t[]> cloned_bytes(new uint8_t[size]);
+ memcpy(cloned_bytes.get(), bytes, size);
+ received_buffers_.push_back(
+ Buffer(std::unique_ptr<const uint8_t[]>(
+ const_cast<const uint8_t*>(cloned_bytes.release())),
+ size));
total_size_ += size;
}
« no previous file with comments | « include/v8.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698