From 64c8f1777c4a634aabfd05433496f6b7f043774a Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 3 Sep 2009 10:44:13 +0000 Subject: Update estream. --- common/estream.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'common/estream.c') diff --git a/common/estream.c b/common/estream.c index c26df6323..fef9a210f 100644 --- a/common/estream.c +++ b/common/estream.c @@ -2756,7 +2756,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, out: - return err ? err : line_n; + return err ? err : (ssize_t)line_n; } @@ -2929,6 +2929,44 @@ es_fprintf (estream_t ES__RESTRICT stream, return ret; } +/* 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 * +es_asprintf (const char *ES__RESTRICT format, ...) +{ + int rc; + va_list ap; + char *buf; + + va_start (ap, format); + rc = estream_vasprintf (&buf, format, ap); + va_end (ap); + if (rc < 0) + return NULL; + return buf; +} + + +/* A variant of vasprintf. 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 * +es_vasprintf (const char *ES__RESTRICT format, va_list ap) +{ + int rc; + char *buf; + + rc = estream_vasprintf (&buf, format, ap); + if (rc < 0) + return NULL; + return buf; +} + static int tmpfd (void) -- cgit v1.2.3