I need variant of snprint that has guarantee that it never calls malloc.
That’s because this snprintf (let’s call it safe_snprint()) is going to
be called from places where malloc will fail or deadlock.
What is closer to truth, 1 or 2 ?
-
On Windows, native snprintf might call malloc. Then
i need to pull opensource snprintf.c and call it safe_snprintf(). Or -
On Windows native snprint is guaranteed to never call malloc.
I’d prefer (2) if it is documented somewhere. Thanks
The implementation of
_snprintf()in the VC libs (MSVCRT) will only call malloc on floating point conversions if and only if (iff) the format precision exceeds 163 characters. This applies to%E%G%A%e%f%gand%aformat specifiers.This should apply to all releases of MSVCRT since at least version 6.