| 2483 | char ImGuiTextBuffer::EmptyString[1] = { 0 }; |
| 2484 | |
| 2485 | void ImGuiTextBuffer::append(const char* str, const char* str_end) |
| 2486 | { |
| 2487 | int len = str_end ? (int)(str_end - str) : (int)strlen(str); |
| 2488 | |
| 2489 | // Add zero-terminator the first time |
| 2490 | const int write_off = (Buf.Size != 0) ? Buf.Size : 1; |
| 2491 | const int needed_sz = write_off + len; |
| 2492 | if (write_off + len >= Buf.Capacity) |
| 2493 | { |
| 2494 | int new_capacity = Buf.Capacity * 2; |
| 2495 | Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); |
| 2496 | } |
| 2497 | |
| 2498 | Buf.resize(needed_sz); |
| 2499 | memcpy(&Buf[write_off - 1], str, (size_t)len); |
| 2500 | Buf[write_off - 1 + len] = 0; |
| 2501 | } |
| 2502 | |
| 2503 | void ImGuiTextBuffer::appendf(const char* fmt, ...) |
| 2504 | { |