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

Unified Diff: src/bootstrapper.cc

Issue 1110603005: Remove support for malloc'd typed arrays (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 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 | « samples/process.cc ('k') | src/d8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 555080fdbd5e781b94ec43bf68c56b1602b1bb59..1658d646182e674bd04275a693bf87d7f7fd7219 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1603,13 +1603,12 @@ Data* SetBuiltinTypedArray(Isolate* isolate, Handle<JSBuiltinsObject> builtins,
size_t num_elements, const char* name) {
size_t byte_length = num_elements * sizeof(*data);
Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
- bool should_be_freed = false;
- if (data == NULL) {
- data = reinterpret_cast<Data*>(malloc(byte_length));
- should_be_freed = true;
+ bool is_external = data != nullptr;
+ if (!is_external) {
+ data = reinterpret_cast<Data*>(
+ V8::ArrayBufferAllocator()->Allocate(byte_length));
}
- Runtime::SetupArrayBuffer(isolate, buffer, true, data, byte_length);
- buffer->set_should_be_freed(should_be_freed);
+ Runtime::SetupArrayBuffer(isolate, buffer, is_external, data, byte_length);
Handle<JSTypedArray> typed_array =
isolate->factory()->NewJSTypedArray(type, buffer, 0, num_elements);
« no previous file with comments | « samples/process.cc ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698