Ok, now a stand for TR24731-2:
Yes, I've used asprintf()
/vasprintf()
ever since I've seen them in glibc, and yes I am a very strong advocate of them.
Why?
Because they deliver precisely what I need over and over again: A powerful, flexible, safe and (relatively) easy to use way to format any text into a freshly allocated string.
I am also much in favor of the memstream
functions: Like asprintf()
, open_memstream()
(not fmemopen()
!!!) allocates a sufficiently large buffer for you and gives you a FILE*
to do your printing, so your printing functions can be entirely ignorant of whether they are printing into a string or a file, and you can simply forget about how much space you will need.