diff options
Diffstat (limited to 'src/string_bytes.cc')
-rw-r--r-- | src/string_bytes.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/string_bytes.cc b/src/string_bytes.cc index cb8a537c71c..a00abbf3bf2 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -36,6 +36,7 @@ namespace node { +using v8::EscapableHandleScope; using v8::Handle; using v8::HandleScope; using v8::Isolate; @@ -66,35 +67,35 @@ class ExternString: public ResourceType { static Local<String> NewFromCopy(Isolate* isolate, const TypeName* data, size_t length) { - HandleScope scope(isolate); + EscapableHandleScope scope(isolate); if (length == 0) - return scope.Close(String::Empty(isolate)); + return scope.Escape(String::Empty(isolate)); TypeName* new_data = new TypeName[length]; memcpy(new_data, data, length * sizeof(*new_data)); - return scope.Close(ExternString<ResourceType, TypeName>::New(isolate, - new_data, - length)); + return scope.Escape(ExternString<ResourceType, TypeName>::New(isolate, + new_data, + length)); } // uses "data" for external resource, and will be free'd on gc static Local<String> New(Isolate* isolate, const TypeName* data, size_t length) { - HandleScope scope(isolate); + EscapableHandleScope scope(isolate); if (length == 0) - return scope.Close(String::Empty(isolate)); + return scope.Escape(String::Empty(isolate)); ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate, data, length); - Local<String> str = String::NewExternal(h_str); + Local<String> str = String::NewExternal(isolate, h_str); isolate->AdjustAmountOfExternalAllocatedMemory(length); - return scope.Close(str); + return scope.Escape(str); } inline Isolate* isolate() const { return isolate_; } @@ -676,16 +677,16 @@ Local<Value> StringBytes::Encode(Isolate* isolate, const char* buf, size_t buflen, enum encoding encoding) { - HandleScope scope(isolate); + EscapableHandleScope scope(isolate); assert(buflen <= Buffer::kMaxLength); if (!buflen && encoding != BUFFER) - return scope.Close(String::Empty(isolate)); + return scope.Escape(String::Empty(isolate)); Local<String> val; switch (encoding) { case BUFFER: - return scope.Close(Buffer::New(buf, buflen)); + return scope.Escape(Buffer::New(buf, buflen)); case ASCII: if (contains_non_ascii(buf, buflen)) { @@ -767,7 +768,7 @@ Local<Value> StringBytes::Encode(Isolate* isolate, break; } - return scope.Close(val); + return scope.Escape(val); } } // namespace node |