20 Sep
2018
20 Sep
'18
12:36 p.m.
charleyb123 wrote:
Not to wander, but does this then suggest there might be interest in the two-call idiom to detect the buffer-size *required*, so the caller can allocate? (This has become increasingly popular such as in the Vulkan APIs, and Microsoft create-process/console functions), for example see: [...]
This is fairly idiomatic in MS land, but for this specific API, neither strerror_r nor FormatMessage give you a length, and user implementations typically won't be able to either (you compose the message with something like snprintf and it doesn't give you the final length either.) And it's not that critical. Messages are typically bounded by something reasonable and truncation is not that big of a problem.