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

Unified Diff: runtime/bin/builtin_natives.cc

Issue 11361032: Fix error in debug printing from the Dart executable, introduced in r14357. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin_natives.cc
diff --git a/runtime/bin/builtin_natives.cc b/runtime/bin/builtin_natives.cc
index be9b99b2b12b93e9047375585657c91255ba53fe..995207c3d2f749db2ad6f86281255af875b8e59e 100644
--- a/runtime/bin/builtin_natives.cc
+++ b/runtime/bin/builtin_natives.cc
@@ -103,11 +103,9 @@ Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name,
// test/debug functionality in standalone dart mode.
void Builtin::PrintString(FILE* out, Dart_Handle str) {
- 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);
+ const char* chars = NULL;
+
+ Dart_Handle result = Dart_StringToCString(str, &chars);
if (Dart_IsError(result)) {
// TODO(turnidge): Consider propagating some errors here. What if
// an isolate gets interrupted by the embedder in the middle of
@@ -115,11 +113,11 @@ void Builtin::PrintString(FILE* out, Dart_Handle str) {
// interrupt.
fputs(Dart_GetError(result), out);
} else {
+ intptr_t length = strlen(chars);
fwrite(chars, sizeof(*chars), length, out);
}
fputc('\n', out);
fflush(out);
- free(chars);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698