From 483c1aa5f114bfed36a6e1c9eeb1e647124559f7 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Sun, 28 Oct 2012 14:40:30 +0100 Subject: lavu/bprint: add av_bprint_get_buffer(). It is useful to use bprint to handle a growing buffer used with another API. --- libavutil/bprint.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libavutil/bprint.c') diff --git a/libavutil/bprint.c b/libavutil/bprint.c index 373a492af0..9d8e7c18ab 100644 --- a/libavutil/bprint.c +++ b/libavutil/bprint.c @@ -129,6 +129,15 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n) av_bprint_grow(buf, n); } +void av_bprint_get_buffer(AVBPrint *buf, unsigned size, + unsigned char **mem, unsigned *actual_size) +{ + if (size > av_bprint_room(buf)) + av_bprint_alloc(buf, size); + *actual_size = av_bprint_room(buf); + *mem = *actual_size ? buf->str + buf->len : NULL; +} + void av_bprint_clear(AVBPrint *buf) { if (buf->len) { -- cgit v1.2.3