diff mbox series

[FFmpeg-devel,08/10] avformat/segment: Remove redundant code for freeing in write_trailer

Message ID 20200907024952.11697-8-andreas.rheinhardt@gmail.com
State Accepted
Commit 5db09e8930e7914ab3169d26502cb989ec0adc90
Headers show
Series [FFmpeg-devel,01/10] avformat/segment: Don't overwrite AVCodecParameters after init | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 7, 2020, 2:49 a.m. UTC
This code mostly duplicates code in the deinit function; the only
exception is av_opt_free(): The options are freed generically lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/segment.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/segment.c b/libavformat/segment.c
index d895e6a678..0253b750b8 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -991,30 +991,21 @@  static int seg_write_trailer(struct AVFormatContext *s)
 {
     SegmentContext *seg = s->priv_data;
     AVFormatContext *oc = seg->avf;
-    int ret = 0;
+    int ret;
 
     if (!oc)
-        goto fail;
+        return 0;
 
     if (!seg->write_header_trailer) {
         if ((ret = segment_end(s, 0, 1)) < 0)
-            goto fail;
+            return ret;
         if ((ret = open_null_ctx(&oc->pb)) < 0)
-            goto fail;
+            return ret;
         seg->is_nullctx = 1;
         ret = av_write_trailer(oc);
-        close_null_ctxp(&oc->pb);
     } else {
         ret = segment_end(s, 1, 1);
     }
-fail:
-    if (seg->list)
-        ff_format_io_close(s, &seg->list_pb);
-
-    av_opt_free(seg);
-
-    avformat_free_context(oc);
-    seg->avf = NULL;
     return ret;
 }