[FFmpeg-cvslog] avutil/bprint: add av_vbprintf()
Michael Niedermayer
git at videolan.org
Sat Aug 10 17:12:33 CEST 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Aug 10 13:52:14 2013 +0200| [112c970ca62de2f43019a4cc787d12a0b88d2fbc] | committer: Michael Niedermayer
avutil/bprint: add av_vbprintf()
Reviewed-by: Nicolas George <nicolas.george at normalesup.org>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=112c970ca62de2f43019a4cc787d12a0b88d2fbc
---
libavutil/bprint.c | 23 +++++++++++++++++++++++
libavutil/bprint.h | 7 +++++++
libavutil/version.h | 2 +-
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index fd7611a..e779956 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -113,6 +113,29 @@ void av_bprintf(AVBPrint *buf, const char *fmt, ...)
av_bprint_grow(buf, extra_len);
}
+void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
+{
+ unsigned room;
+ char *dst;
+ int extra_len;
+ va_list vl;
+
+ while (1) {
+ room = av_bprint_room(buf);
+ dst = room ? buf->str + buf->len : NULL;
+ va_copy(vl, vl_arg);
+ extra_len = vsnprintf(dst, room, fmt, vl);
+ va_end(vl);
+ if (extra_len <= 0)
+ return;
+ if (extra_len < room)
+ break;
+ if (av_bprint_alloc(buf, extra_len))
+ break;
+ }
+ av_bprint_grow(buf, extra_len);
+}
+
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
{
unsigned room, real_n;
diff --git a/libavutil/bprint.h b/libavutil/bprint.h
index dc86f12..bb1de25 100644
--- a/libavutil/bprint.h
+++ b/libavutil/bprint.h
@@ -21,6 +21,8 @@
#ifndef AVUTIL_BPRINT_H
#define AVUTIL_BPRINT_H
+#include <stdarg.h>
+
#include "attributes.h"
#include "avstring.h"
@@ -122,6 +124,11 @@ void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
/**
+ * Append a formatted string to a print buffer.
+ */
+void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg);
+
+/**
* Append char c n times to a print buffer.
*/
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
diff --git a/libavutil/version.h b/libavutil/version.h
index 6eafda6..e522b79 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -75,7 +75,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 41
+#define LIBAVUTIL_VERSION_MINOR 42
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
More information about the ffmpeg-cvslog
mailing list