| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 561fd4e397dfeeadebe2f77e87ea7fec05db89b0..48730001ae4684417daae5a847e6cc0d1f65ef15 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -462,13 +462,13 @@ static uint16_t* AsciiToTwoByteString(const char* source) {
|
|
|
| class TestResource: public String::ExternalStringResource {
|
| public:
|
| - explicit TestResource(uint16_t* data, int* counter = NULL)
|
| - : data_(data), length_(0), counter_(counter) {
|
| + TestResource(uint16_t* data, int* counter = NULL, bool owning_data = true)
|
| + : data_(data), length_(0), counter_(counter), owning_data_(owning_data) {
|
| while (data[length_]) ++length_;
|
| }
|
|
|
| ~TestResource() {
|
| - i::DeleteArray(data_);
|
| + if (owning_data_) i::DeleteArray(data_);
|
| if (counter_ != NULL) ++*counter_;
|
| }
|
|
|
| @@ -479,10 +479,12 @@ class TestResource: public String::ExternalStringResource {
|
| size_t length() const {
|
| return length_;
|
| }
|
| +
|
| private:
|
| uint16_t* data_;
|
| size_t length_;
|
| int* counter_;
|
| + bool owning_data_;
|
| };
|
|
|
|
|
| @@ -15218,13 +15220,10 @@ TEST(CompileExternalTwoByteSource) {
|
| // Compile the sources as external two byte strings.
|
| for (int i = 0; ascii_sources[i] != NULL; i++) {
|
| uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]);
|
| - UC16VectorResource uc16_resource(
|
| - i::Vector<const uint16_t>(two_byte_string,
|
| - i::StrLength(ascii_sources[i])));
|
| + TestResource* uc16_resource = new TestResource(two_byte_string);
|
| v8::Local<v8::String> source =
|
| - v8::String::NewExternal(context->GetIsolate(), &uc16_resource);
|
| + v8::String::NewExternal(context->GetIsolate(), uc16_resource);
|
| v8::Script::Compile(source);
|
| - i::DeleteArray(two_byte_string);
|
| }
|
| }
|
|
|
| @@ -17871,12 +17870,12 @@ TEST(VisitExternalStrings) {
|
| resource[0] = new TestResource(two_byte_string);
|
| v8::Local<v8::String> string0 =
|
| v8::String::NewExternal(env->GetIsolate(), resource[0]);
|
| - resource[1] = new TestResource(two_byte_string);
|
| + resource[1] = new TestResource(two_byte_string, NULL, false);
|
| v8::Local<v8::String> string1 =
|
| v8::String::NewExternal(env->GetIsolate(), resource[1]);
|
|
|
| // Externalized symbol.
|
| - resource[2] = new TestResource(two_byte_string);
|
| + resource[2] = new TestResource(two_byte_string, NULL, false);
|
| v8::Local<v8::String> string2 = v8::String::NewFromUtf8(
|
| env->GetIsolate(), string, v8::String::kInternalizedString);
|
| CHECK(string2->MakeExternal(resource[2]));
|
|
|