Liste des Groupes | Revenir à co vms |
On Mon, 23 Jun 2025 20:40:21 -0400, Arne Vajhøj wrote:That is a lot better than vfprintf to null.On 6/23/2025 8:37 PM, Lawrence D'Oliveiro wrote:snprintf(3) and vsnprintf(3) return the total number of bytes needed forWhat a dumb way to do it. Using the null device means making OS I/O>
calls -- needless overhead just to find out how long a string -- which
is being put together entirely in userland -- needs to be.
But if you have a simple better way of achieving it ...
the final result. So just call them once with all the right arguments and
a zero-length buffer, and use the result to allocate a buffer of the right
length, and call them again.
And of course you should be using va_end(3) and va_start(3) again beforeYes. But the argument list for vasprintf is as it is. This is
the second call. This allows for traversing the argument list multiple
times.
Les messages affichés proviennent d'usenet.