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/text_buffer.h" | 5 #include "platform/text_buffer.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 14 matching lines...) Expand all Loading... |
25 buf_ = NULL; | 25 buf_ = NULL; |
26 } | 26 } |
27 | 27 |
28 | 28 |
29 void TextBuffer::Clear() { | 29 void TextBuffer::Clear() { |
30 msg_len_ = 0; | 30 msg_len_ = 0; |
31 buf_[0] = '\0'; | 31 buf_[0] = '\0'; |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 const char* TextBuffer::Steal() { | 35 char* TextBuffer::Steal() { |
36 const char* r = buf_; | 36 char* r = buf_; |
37 buf_ = NULL; | 37 buf_ = NULL; |
38 buf_size_ = 0; | 38 buf_size_ = 0; |
39 msg_len_ = 0; | 39 msg_len_ = 0; |
40 return r; | 40 return r; |
41 } | 41 } |
42 | 42 |
43 | 43 |
44 void TextBuffer::AddChar(char ch) { | 44 void TextBuffer::AddChar(char ch) { |
45 EnsureCapacity(sizeof(ch)); | 45 EnsureCapacity(sizeof(ch)); |
46 buf_[msg_len_] = ch; | 46 buf_[msg_len_] = ch; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // the debugger front-end. | 152 // the debugger front-end. |
153 intptr_t new_size = buf_size_ + len + kBufferSpareCapacity; | 153 intptr_t new_size = buf_size_ + len + kBufferSpareCapacity; |
154 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size)); | 154 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size)); |
155 ASSERT(new_buf != NULL); | 155 ASSERT(new_buf != NULL); |
156 buf_ = new_buf; | 156 buf_ = new_buf; |
157 buf_size_ = new_size; | 157 buf_size_ = new_size; |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 } // namespace dart | 161 } // namespace dart |
OLD | NEW |