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

Unified Diff: bin/builtin_natives.cc

Issue 11275008: - Represent strings internally in UTF-16 format, this makes it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 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 | « bin/builtin.cc ('k') | bin/builtin_nolib.cc » ('j') | bin/dartutils.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/builtin_natives.cc
===================================================================
--- bin/builtin_natives.cc (revision 14155)
+++ bin/builtin_natives.cc (working copy)
@@ -103,9 +103,11 @@
// test/debug functionality in standalone dart mode.
void Builtin::PrintString(FILE* out, Dart_Handle str) {
- const uint8_t* characters = NULL;
- intptr_t length;
- Dart_Handle result = Dart_StringToBytes(str, &characters, &length);
+ intptr_t length = 0;
+ Dart_Handle result = Dart_StringLength(str, &length);
+ DART_CHECK_VALID(result);
+ uint8_t* chars = reinterpret_cast<uint8_t*>(malloc(length * sizeof(uint8_t)));
+ result = Dart_StringToUTF8(str, chars, &length);
if (Dart_IsError(result)) {
// TODO(turnidge): Consider propagating some errors here. What if
// an isolate gets interrupted by the embedder in the middle of
@@ -113,10 +115,11 @@
// interrupt.
fputs(Dart_GetError(result), out);
} else {
- fwrite(characters, sizeof(*characters), length, out);
+ fwrite(chars, sizeof(*chars), length, out);
}
fputc('\n', out);
fflush(out);
+ free(chars);
}
« no previous file with comments | « bin/builtin.cc ('k') | bin/builtin_nolib.cc » ('j') | bin/dartutils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698