diff options
Diffstat (limited to 'src/estream-printf.c')
-rw-r--r-- | src/estream-printf.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/estream-printf.c b/src/estream-printf.c index d2d13fc..b1eb828 100644 --- a/src/estream-printf.c +++ b/src/estream-printf.c @@ -1853,3 +1853,23 @@ _gpgrt_estream_asprintf (char **bufp, const char *format, ...) return rc; } + +/* A variant of asprintf. The function returns the allocated buffer + or NULL on error; ERRNO is set in the error case. The caller + should use es_free to release the buffer. This function actually + belongs into estream-printf but we put it here as a convenience + and because es_free is required anyway. */ +char * +_gpgrt_estream_bsprintf (const char *format, ...) +{ + int rc; + va_list ap; + char *buf; + + va_start (ap, format); + rc = _gpgrt_estream_vasprintf (&buf, format, ap); + va_end (ap); + if (rc < 0) + return NULL; + return buf; +} |