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

Unified Diff: tools/parser-shell.cc

Issue 2101413002: Provide a convenience array buffer allocator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 6 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 | « test/unittests/test-utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/parser-shell.cc
diff --git a/tools/parser-shell.cc b/tools/parser-shell.cc
index 810c5b9d174c5d25497ed3c96edd1705fe67af99..f4e54402b12791c04081ac3ef30093beb149cbc4 100644
--- a/tools/parser-shell.cc
+++ b/tools/parser-shell.cc
@@ -45,16 +45,6 @@
using namespace v8::internal;
-class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
- public:
- virtual void* Allocate(size_t length) {
- void* data = AllocateUninitialized(length);
- return data == NULL ? data : memset(data, 0, length);
- }
- virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
- virtual void Free(void* data, size_t) { free(data); }
-};
-
class StringResource8 : public v8::String::ExternalOneByteStringResource {
public:
StringResource8(const char* data, int length)
@@ -168,9 +158,9 @@ int main(int argc, char* argv[]) {
fnames.push_back(std::string(argv[i]));
}
}
- ArrayBufferAllocator array_buffer_allocator;
v8::Isolate::CreateParams create_params;
- create_params.array_buffer_allocator = &array_buffer_allocator;
+ create_params.array_buffer_allocator =
+ v8::ArrayBuffer::Allocator::NewDefaultAllocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
{
v8::Isolate::Scope isolate_scope(isolate);
@@ -199,5 +189,6 @@ int main(int argc, char* argv[]) {
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
+ delete create_params.array_buffer_allocator;
return 0;
}
« no previous file with comments | « test/unittests/test-utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698