| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/json.h" | 5 #include "platform/json.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 buf_ = NULL; | 503 buf_ = NULL; |
| 504 } | 504 } |
| 505 | 505 |
| 506 | 506 |
| 507 void TextBuffer::Clear() { | 507 void TextBuffer::Clear() { |
| 508 msg_len_ = 0; | 508 msg_len_ = 0; |
| 509 buf_[0] = '\0'; | 509 buf_[0] = '\0'; |
| 510 } | 510 } |
| 511 | 511 |
| 512 | 512 |
| 513 const char* TextBuffer::Steal() { |
| 514 const char* r = buf_; |
| 515 buf_ = NULL; |
| 516 buf_size_ = 0; |
| 517 msg_len_ = 0; |
| 518 return r; |
| 519 } |
| 520 |
| 521 |
| 513 void TextBuffer::AddChar(char ch) { | 522 void TextBuffer::AddChar(char ch) { |
| 514 EnsureCapacity(sizeof(ch)); | 523 EnsureCapacity(sizeof(ch)); |
| 515 buf_[msg_len_] = ch; | 524 buf_[msg_len_] = ch; |
| 516 msg_len_++; | 525 msg_len_++; |
| 517 buf_[msg_len_] = '\0'; | 526 buf_[msg_len_] = '\0'; |
| 518 } | 527 } |
| 519 | 528 |
| 520 | 529 |
| 521 void TextBuffer::AddUTF8(uint32_t ch) { | 530 void TextBuffer::AddUTF8(uint32_t ch) { |
| 522 static const uint32_t kMaxOneByteChar = 0x7F; | 531 static const uint32_t kMaxOneByteChar = 0x7F; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // the debugger front-end. | 652 // the debugger front-end. |
| 644 intptr_t new_size = buf_size_ + len + kBufferSpareCapacity; | 653 intptr_t new_size = buf_size_ + len + kBufferSpareCapacity; |
| 645 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size)); | 654 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size)); |
| 646 ASSERT(new_buf != NULL); | 655 ASSERT(new_buf != NULL); |
| 647 buf_ = new_buf; | 656 buf_ = new_buf; |
| 648 buf_size_ = new_size; | 657 buf_size_ = new_size; |
| 649 } | 658 } |
| 650 } | 659 } |
| 651 | 660 |
| 652 } // namespace dart | 661 } // namespace dart |
| OLD | NEW |