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

Unified Diff: runtime/platform/json.cc

Issue 10392017: Support more debugger commands in the wire protocol (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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/platform/json.h ('k') | runtime/vm/os_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/json.cc
===================================================================
--- runtime/platform/json.cc (revision 7517)
+++ runtime/platform/json.cc (working copy)
@@ -312,6 +312,23 @@
}
+void JSONReader::GetValueChars(char* buf, intptr_t buflen) const {
+ if (Type() == kNone) {
+ return;
+ }
+ intptr_t max = buflen - 1;
+ if (ValueLen() < max) {
+ max = ValueLen();
+ }
+ const char* val = ValueChars();
+ intptr_t i = 0;
+ for (; i < max; i++) {
+ buf[i] = val[i];
+ }
+ buf[i] = '\0';
+}
+
+
TextBuffer::TextBuffer(intptr_t buf_size) {
ASSERT(buf_size > 0);
buf_ = reinterpret_cast<char*>(malloc(buf_size));
@@ -332,20 +349,20 @@
}
-intptr_t TextBuffer::Printf(const char* format, ...) {
- va_list args;
- va_start(args, format);
+intptr_t TextBuffer::Printf(const char* format, va_list args) {
+ va_list args1;
+ va_copy(args1, args);
intptr_t remaining = buf_size_ - msg_len_;
ASSERT(remaining >= 0);
- intptr_t len = OS::VSNPrint(buf_ + msg_len_, remaining, format, args);
- va_end(args);
+ intptr_t len = OS::VSNPrint(buf_ + msg_len_, remaining, format, args1);
+ va_end(args1);
if (len >= remaining) {
const int kBufferSpareCapacity = 64; // Somewhat arbitrary.
GrowBuffer(len + kBufferSpareCapacity);
remaining = buf_size_ - msg_len_;
ASSERT(remaining > len);
va_list args2;
- va_start(args2, format);
+ va_copy(args2, args);
intptr_t len2 = OS::VSNPrint(buf_ + msg_len_, remaining, format, args2);
va_end(args2);
ASSERT(len == len2);
@@ -356,6 +373,15 @@
}
+intptr_t TextBuffer::Printf(const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ intptr_t len = this->Printf(format, args);
+ va_end(args);
+ return len;
+}
+
+
void TextBuffer::GrowBuffer(intptr_t len) {
intptr_t new_size = buf_size_ + len;
char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size));
« no previous file with comments | « runtime/platform/json.h ('k') | runtime/vm/os_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698