diff mbox series

[FFmpeg-devel,3/4] fftools/ffmpeg_filter: Avoid DynBuf-API for writing strings

Message ID AM7PR03MB6660DDCE80277C3AE9EC43318F689@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit cf8925a0965a75f22cddb1cc42e11871ccf84c15
Headers show
Series [FFmpeg-devel,1/4] all: Remove unused-but-set variables
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Dec. 1, 2021, 5:03 p.m. UTC
It is not really natural, it requires internal allocations
of its own and its error handling is horrible (i.e. the implicit
(re)allocations here are unchecked).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 fftools/ffmpeg_filter.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 452b689d62..47bbb67ce0 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -201,17 +201,15 @@  static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
     AVFilterContext *ctx = inout->filter_ctx;
     AVFilterPad *pads = in ? ctx->input_pads  : ctx->output_pads;
     int       nb_pads = in ? ctx->nb_inputs   : ctx->nb_outputs;
-    AVIOContext *pb;
-    uint8_t *res = NULL;
+    char *res;
 
-    if (avio_open_dyn_buf(&pb) < 0)
-        exit_program(1);
-
-    avio_printf(pb, "%s", ctx->filter->name);
     if (nb_pads > 1)
-        avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));
-    avio_w8(pb, 0);
-    avio_close_dyn_buf(pb, &res);
+        res = av_strdup(ctx->filter->name);
+    else
+        res = av_asprintf("%s:%s", ctx->filter->name,
+                          avfilter_pad_get_name(pads, inout->pad_idx));
+    if (!res)
+        exit_program(1);
     return res;
 }