| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 | 46 |
| 47 void TextBuffer::AddChar(char ch) { | 47 void TextBuffer::AddChar(char ch) { |
| 48 EnsureCapacity(sizeof(ch)); | 48 EnsureCapacity(sizeof(ch)); |
| 49 buf_[msg_len_] = ch; | 49 buf_[msg_len_] = ch; |
| 50 msg_len_++; | 50 msg_len_++; |
| 51 buf_[msg_len_] = '\0'; | 51 buf_[msg_len_] = '\0'; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 void TextBuffer::AddRaw(const uint8_t* buffer, | 55 void TextBuffer::AddRaw(const uint8_t* buffer, intptr_t buffer_length) { |
| 56 intptr_t buffer_length) { | |
| 57 EnsureCapacity(buffer_length); | 56 EnsureCapacity(buffer_length); |
| 58 memmove(&buf_[msg_len_], buffer, buffer_length); | 57 memmove(&buf_[msg_len_], buffer, buffer_length); |
| 59 msg_len_ += buffer_length; | 58 msg_len_ += buffer_length; |
| 60 buf_[msg_len_] = '\0'; | 59 buf_[msg_len_] = '\0'; |
| 61 } | 60 } |
| 62 | 61 |
| 63 | 62 |
| 64 intptr_t TextBuffer::Printf(const char* format, ...) { | 63 intptr_t TextBuffer::Printf(const char* format, ...) { |
| 65 va_list args; | 64 va_list args; |
| 66 va_start(args, format); | 65 va_start(args, format); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size)); | 156 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size)); |
| 158 if (new_buf == NULL) { | 157 if (new_buf == NULL) { |
| 159 OUT_OF_MEMORY(); | 158 OUT_OF_MEMORY(); |
| 160 } | 159 } |
| 161 buf_ = new_buf; | 160 buf_ = new_buf; |
| 162 buf_size_ = new_size; | 161 buf_size_ = new_size; |
| 163 } | 162 } |
| 164 } | 163 } |
| 165 | 164 |
| 166 } // namespace dart | 165 } // namespace dart |
| OLD | NEW |