Skip to content

Commit

Permalink
lavu/bprint: add append buffer function
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Marek <[email protected]>
Reveiwed-by: Nicolas George <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
lukaszmluki authored and michaelni committed Aug 30, 2013
1 parent 6e1b1a2 commit 0b46d6f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
18 changes: 18 additions & 0 deletions libavutil/bprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
av_bprint_grow(buf, n);
}

void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
{
unsigned room, real_n;

while (1) {
room = av_bprint_room(buf);
if (size < room)
break;
if (av_bprint_alloc(buf, size))
break;
}
if (room) {
real_n = FFMIN(size, room - 1);
memcpy(buf->str + buf->len, data, real_n);
}
av_bprint_grow(buf, size);
}

void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
{
unsigned room;
Expand Down
9 changes: 9 additions & 0 deletions libavutil/bprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg);
*/
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);

/**
* Append data to a print buffer.
*
* param buf bprint buffer to use
* param data pointer to data
* param size size of data
*/
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size);

struct tm;
/**
* Append a formatted date and time to a print buffer.
Expand Down
2 changes: 1 addition & 1 deletion libavutil/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
*/

#define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 42
#define LIBAVUTIL_VERSION_MINOR 43
#define LIBAVUTIL_VERSION_MICRO 100

#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
Expand Down

0 comments on commit 0b46d6f

Please sign in to comment.