MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / appendfv

Method appendfv

lib/imgui/imgui.cpp:2100–2124  ·  view source on GitHub ↗

Helper: Text buffer for logging/accumulating text

Source from the content-addressed store, hash-verified

2098
2099// Helper: Text buffer for logging/accumulating text
2100void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
2101{
2102 va_list args_copy;
2103 va_copy(args_copy, args);
2104
2105 int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
2106 if (len <= 0)
2107 {
2108 va_end(args_copy);
2109 return;
2110 }
2111
2112 // Add zero-terminator the first time
2113 const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
2114 const int needed_sz = write_off + len;
2115 if (write_off + len >= Buf.Capacity)
2116 {
2117 int new_capacity = Buf.Capacity * 2;
2118 Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
2119 }
2120
2121 Buf.resize(needed_sz);
2122 ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy);
2123 va_end(args_copy);
2124}
2125
2126//-----------------------------------------------------------------------------
2127// [SECTION] ImGuiListClipper

Callers 1

LogTextMethod · 0.80

Calls 3

ImFormatStringVFunction · 0.85
reserveMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected