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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 2275803002: Assign external sizes to external strings and to external typed data created by the VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 4 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 | « runtime/vm/clustered_snapshot.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 560b600dc8dcebc0570052d82638731441aed301..ccda7f0d172d6666140b1b55016e06ce5106d367 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -2557,7 +2557,7 @@ DART_EXPORT Dart_Handle Dart_StringStorageSize(Dart_Handle str,
DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str,
void* array,
- intptr_t length,
+ intptr_t external_size,
void* peer,
Dart_PeerFinalizer cback) {
DARTSCOPE(Thread::Current());
@@ -2576,9 +2576,9 @@ DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str,
RETURN_NULL_ERROR(array);
}
intptr_t str_size = (str_obj.Length() * str_obj.CharSize());
- if ((length < str_size) || (length > String::kMaxElements)) {
+ if ((external_size < str_size) || (external_size > String::kMaxElements)) {
return Api::NewError("Dart_MakeExternalString "
- "expects argument length to be in the range"
+ "expects argument external_size to be in the range"
"[%" Pd "..%" Pd "].",
str_size, String::kMaxElements);
}
@@ -2590,24 +2590,25 @@ DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str,
// the peer from the Peer table.
intptr_t copy_len = str_obj.Length();
if (str_obj.IsOneByteString()) {
- ASSERT(length >= copy_len);
+ ASSERT(external_size >= copy_len);
uint8_t* latin1_array = reinterpret_cast<uint8_t*>(array);
for (intptr_t i = 0; i < copy_len; i++) {
latin1_array[i] = static_cast<uint8_t>(str_obj.CharAt(i));
}
- OneByteString::SetPeer(str_obj, peer, cback);
+ OneByteString::SetPeer(str_obj, external_size, peer, cback);
} else {
ASSERT(str_obj.IsTwoByteString());
- ASSERT(length >= (copy_len * str_obj.CharSize()));
+ ASSERT(external_size >= (copy_len * str_obj.CharSize()));
uint16_t* utf16_array = reinterpret_cast<uint16_t*>(array);
for (intptr_t i = 0; i < copy_len; i++) {
utf16_array[i] = str_obj.CharAt(i);
}
- TwoByteString::SetPeer(str_obj, peer, cback);
+ TwoByteString::SetPeer(str_obj, external_size, peer, cback);
}
return str;
}
- return Api::NewHandle(T, str_obj.MakeExternal(array, length, peer, cback));
+ return Api::NewHandle(T, str_obj.MakeExternal(array, external_size,
+ peer, cback));
}
« no previous file with comments | « runtime/vm/clustered_snapshot.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698