Commit 483c1aa5 authored by Nicolas George's avatar Nicolas George

lavu/bprint: add av_bprint_get_buffer().

It is useful to use bprint to handle a growing buffer
used with another API.
parent 8551c6be
...@@ -129,6 +129,15 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n) ...@@ -129,6 +129,15 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
av_bprint_grow(buf, 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) void av_bprint_clear(AVBPrint *buf)
{ {
if (buf->len) { if (buf->len) {
......
...@@ -125,6 +125,18 @@ void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3); ...@@ -125,6 +125,18 @@ void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
*/ */
void av_bprint_chars(AVBPrint *buf, char c, unsigned n); void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
/**
* Allocate bytes in the buffer for external use.
*
* @param[in] buf buffer structure
* @param[in] size required size
* @param[out] mem pointer to the memory area
* @param[out] actual_size size of the memory area after allocation;
* can be larger or smaller than size
*/
void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
unsigned char **mem, unsigned *actual_size);
/** /**
* Reset the string to "" but keep internal allocated data. * Reset the string to "" but keep internal allocated data.
*/ */
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 1 #define LIBAVUTIL_VERSION_MINOR 2
#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment