diff options
author | Nicolas George <nicolas.george@normalesup.org> | 2012-06-03 19:48:33 +0200 |
---|---|---|
committer | Nicolas George <nicolas.george@normalesup.org> | 2012-06-07 22:28:32 +0200 |
commit | b3e2bb08a99a81bac672f6ba3958ca175bf06007 (patch) | |
tree | 8229a860a167b75fe138032e3672624a58a71252 /libavutil/bprint.c | |
parent | 9148ae5b910b1e221ab20cd2deb8c6ceefb0e9e8 (diff) | |
download | ffmpeg-b3e2bb08a99a81bac672f6ba3958ca175bf06007.tar.gz |
bprint: add av_bprint_init_for_buffer().
Diffstat (limited to 'libavutil/bprint.c')
-rw-r--r-- | libavutil/bprint.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavutil/bprint.c b/libavutil/bprint.c index 115bf0c8de..646f0aab5d 100644 --- a/libavutil/bprint.c +++ b/libavutil/bprint.c @@ -78,6 +78,15 @@ void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max) av_bprint_alloc(buf, size_init - 1); } +void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size) +{ + buf->str = buffer; + buf->len = 0; + buf->size = size; + buf->size_max = size; + *buf->str = 0; +} + void av_bprintf(AVBPrint *buf, const char *fmt, ...) { unsigned room; @@ -178,6 +187,7 @@ static void bprint_pascal(AVBPrint *b, unsigned size) int main(void) { AVBPrint b; + char buf[256]; av_bprint_init(&b, 0, -1); bprint_pascal(&b, 5); @@ -208,6 +218,10 @@ int main(void) bprint_pascal(&b, 25); printf("Long text count only buffer: %zu/%u\n", strlen(b.str), b.len); + av_bprint_init_for_buffer(&b, buf, sizeof(buf)); + bprint_pascal(&b, 25); + printf("Long text count only buffer: %zu/%u\n", strlen(buf), b.len); + return 0; } |