Helper: Text buffer for logging/accumulating text
| 2211 | |
| 2212 | // Helper: Text buffer for logging/accumulating text |
| 2213 | void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) |
| 2214 | { |
| 2215 | va_list args_copy; |
| 2216 | va_copy(args_copy, args); |
| 2217 | |
| 2218 | int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass. |
| 2219 | if (len <= 0) |
| 2220 | { |
| 2221 | va_end(args_copy); |
| 2222 | return; |
| 2223 | } |
| 2224 | |
| 2225 | // Add zero-terminator the first time |
| 2226 | const int write_off = (Buf.Size != 0) ? Buf.Size : 1; |
| 2227 | const int needed_sz = write_off + len; |
| 2228 | if (write_off + len >= Buf.Capacity) |
| 2229 | { |
| 2230 | int new_capacity = Buf.Capacity * 2; |
| 2231 | Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); |
| 2232 | } |
| 2233 | |
| 2234 | Buf.resize(needed_sz); |
| 2235 | ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy); |
| 2236 | va_end(args_copy); |
| 2237 | } |
| 2238 | |
| 2239 | //----------------------------------------------------------------------------- |
| 2240 | // [SECTION] ImGuiListClipper |
no test coverage detected