|
From: | Paul Vixie |
Subject: | Re: [Nmh-workers] GCC 8 pre-releases have escaped... |
Date: | Mon, 05 Feb 2018 17:12:33 -0800 |
User-agent: | Postbox 5.0.22 (Windows/20171208) |
Ken Hornstein wrote:
Yes, I like asprintf(), but it's not POSIX. snprintf(NULL, 0, fmt, ...) is POSIX and returns the strlen() of what would have been written, allowing a second call to do the work, again, for real this time.A quick glance suggests to me that even while asprintf() is not part of POSIX, it is on *BSD systems, newer versions of MacOS X, and is in glibc. That sounds like pretty good coverage to me.
me too. however, let it also be said that...
I'd personally be willing to live with the inefficiency of a simple {v}asprintf() implementation that just called {v}snprintf() with a size of 0 to get the real size and then called it again with a correctly-allocated buffer.
...ralph's proposal to have uvsnprintf() call snprintf() up to twice, once to get the length, and then perhaps again to get the data, is fine. we'd want the unvetted calls to be vetted a-s-a-p. so the efficiency of the unvetted versions need not concern us.
-- P Vixie
[Prev in Thread] | Current Thread | [Next in Thread] |