summaryrefslogtreecommitdiff
path: root/libavutil/log.c
diff options
context:
space:
mode:
authorAndreas Weis <github@ghulbus-inc.de>2016-04-27 08:15:17 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-04-27 19:23:05 +0200
commitfb9187129c3d07ac6d0f7deaa27f1248394d8f91 (patch)
treeff1ba082a3a820db6543150695468e93ab4d5b56 /libavutil/log.c
parent6f784c158bd56f2cc73354974ceebb04a40e0f52 (diff)
avutil/log: added av_log_format_line2 which returns buffer length
The new function behaves the same as av_log_format_line, but also forwards the return value from the underlying snprintf call. This will allow callers to accurately determine the size requirements for the line buffer. Signed-off-by: Andreas Weis <github@ghulbus-inc.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil/log.c')
-rw-r--r--libavutil/log.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavutil/log.c b/libavutil/log.c
index 45835195e1..0efba7ada4 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -284,10 +284,19 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl,
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
char *line, int line_size, int *print_prefix)
{
+ av_log_format_line2(ptr, level, fmt, vl, line, line_size, print_prefix);
+}
+
+int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
+ char *line, int line_size, int *print_prefix)
+{
AVBPrint part[4];
+ int ret;
+
format_line(ptr, level, fmt, vl, part, print_prefix, NULL);
- snprintf(line, line_size, "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
+ ret = snprintf(line, line_size, "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
av_bprint_finalize(part+3, NULL);
+ return ret;
}
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)