Make stl_vsprintf return if there is an vsnprintf error
vsnprintf man page claims: "If an output error is encountered, a negative value is returned." That means we has to call vsnprintf twice at most to have whole output written to a string. But in case of error we return an empty string. The code also optimizes an expected common case of outputting single line with a small stack allocated buffer. If the stack buffer is too small then it uses std::string::resize to allocate exactly enough memory and writes directly to std::string. Second call could use vsprintf because memory is known to be large enough. But I think that difference isn't detectable outside micro benchmarks.develop
parent
69cf5756c3
commit
82e7b8300a
Loading…
Reference in New Issue