Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index a69fe902a4293740a692416e4f4b5c0b57b08f5c..4d0b9eaef3eea6b6142c2aef331bbfe7287d360f 100755 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -2547,6 +2547,19 @@ THREADED_TEST(SymbolProperties) { |
} |
+class ScopedArrayBufferContents { |
+ public: |
+ explicit ScopedArrayBufferContents( |
+ const v8::ArrayBuffer::Contents& contents) |
+ : contents_(contents) {} |
+ ~ScopedArrayBufferContents() { free(contents_.Data()); } |
+ void* Data() const { return contents_.Data(); } |
+ size_t ByteLength() const { return contents_.ByteLength(); } |
+ private: |
+ const v8::ArrayBuffer::Contents contents_; |
+}; |
+ |
+ |
THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { |
i::FLAG_harmony_array_buffer = true; |
i::FLAG_harmony_typed_arrays = true; |
@@ -2560,8 +2573,7 @@ THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { |
CHECK(!ab->IsExternal()); |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
- v8::ArrayBufferContents ab_contents; |
- ab->Externalize(&ab_contents); |
+ ScopedArrayBufferContents ab_contents(ab->Externalize()); |
CHECK(ab->IsExternal()); |
CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); |
@@ -2603,8 +2615,7 @@ THREADED_TEST(ArrayBuffer_JSInternalToExternal) { |
Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::Cast(*result); |
CHECK_EQ(2, static_cast<int>(ab1->ByteLength())); |
CHECK(!ab1->IsExternal()); |
- v8::ArrayBufferContents ab1_contents; |
- ab1->Externalize(&ab1_contents); |
+ ScopedArrayBufferContents ab1_contents(ab1->Externalize()); |
CHECK(ab1->IsExternal()); |
result = CompileRun("ab1.byteLength"); |
@@ -2711,8 +2722,7 @@ THREADED_TEST(ArrayBuffer_NeuteringApi) { |
v8::Handle<v8::Float64Array> f64a = |
CreateAndCheck<v8::Float64Array, 8>(buffer, 8, 127); |
- v8::ArrayBufferContents contents; |
- buffer->Externalize(&contents); |
+ ScopedArrayBufferContents contents(buffer->Externalize()); |
buffer->Neuter(); |
CHECK_EQ(0, static_cast<int>(buffer->ByteLength())); |
CheckIsNeutered(u8a); |
@@ -2763,8 +2773,7 @@ THREADED_TEST(ArrayBuffer_NeuteringScript) { |
v8::Handle<v8::Float64Array> f64a( |
v8::Float64Array::Cast(*CompileRun("f64a"))); |
- v8::ArrayBufferContents contents; |
- ab->Externalize(&contents); |
+ ScopedArrayBufferContents contents(ab->Externalize()); |
ab->Neuter(); |
CHECK_EQ(0, static_cast<int>(ab->ByteLength())); |
CheckIsNeutered(u8a); |