MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / appendfv

Method appendfv

TheForceEngine/TFE_Ui/imGUI/imgui.cpp:2813–2837  ·  view source on GitHub ↗

Helper: Text buffer for logging/accumulating text

Source from the content-addressed store, hash-verified

2811
2812// Helper: Text buffer for logging/accumulating text
2813void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
2814{
2815 va_list args_copy;
2816 va_copy(args_copy, args);
2817
2818 int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
2819 if (len <= 0)
2820 {
2821 va_end(args_copy);
2822 return;
2823 }
2824
2825 // Add zero-terminator the first time
2826 const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
2827 const int needed_sz = write_off + len;
2828 if (write_off + len >= Buf.Capacity)
2829 {
2830 int new_capacity = Buf.Capacity * 2;
2831 Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
2832 }
2833
2834 Buf.resize(needed_sz);
2835 ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy);
2836 va_end(args_copy);
2837}
2838
2839void ImGuiTextIndex::append(const char* base, int old_size, int new_size)
2840{

Callers 2

LogTextVFunction · 0.80
DebugLogVMethod · 0.80

Calls 3

ImFormatStringVFunction · 0.85
reserveMethod · 0.80
resizeMethod · 0.45

Tested by

no test coverage detected