diff mbox series

[FFmpeg-devel,8/9] avformat/smacker: Use st->priv_data to store array

Message ID 20200624134705.14833-8-andreas.rheinhardt@gmail.com
State Accepted
Commit e40ad1c0d4299d0450dd6b53e01e704fc98b18d8
Headers show
Series [FFmpeg-devel,1/9] avformat/smacker: Don't increase packet counter prematurely
Related show

Checks

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

Commit Message

Andreas Rheinhardt June 24, 2020, 1:47 p.m. UTC
It simplifies freeing and allows to completely remove smacker_read_close.

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

Patch

diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index 201372aee6..2e4a499a13 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -205,10 +205,11 @@  static int smacker_read_header(AVFormatContext *s)
     avio_rl32(pb); /* padding */
 
     /* setup data */
-    smk->frm_size  = av_malloc_array(smk->frames, sizeof(*smk->frm_size) +
+    st->priv_data  = av_malloc_array(smk->frames, sizeof(*smk->frm_size) +
                                                   sizeof(*smk->frm_flags));
-    if (!smk->frm_size)
+    if (!st->priv_data)
         return AVERROR(ENOMEM);
+    smk->frm_size  = st->priv_data;
     smk->frm_flags = (void*)(smk->frm_size + smk->frames);
 
     /* read frame info */
@@ -219,7 +220,6 @@  static int smacker_read_header(AVFormatContext *s)
         /* load trees to extradata, they will be unpacked by decoder */
         (ret = ffio_read_size(pb, par->extradata + 16,
                               par->extradata_size - 16)) < 0) {
-        av_freep(&smk->frm_size);
         return ret;
     }
 
@@ -351,15 +351,6 @@  next_frame:
     return ret;
 }
 
-static int smacker_read_close(AVFormatContext *s)
-{
-    SmackerContext *smk = s->priv_data;
-
-    av_freep(&smk->frm_size);
-
-    return 0;
-}
-
 AVInputFormat ff_smacker_demuxer = {
     .name           = "smk",
     .long_name      = NULL_IF_CONFIG_SMALL("Smacker"),
@@ -367,5 +358,4 @@  AVInputFormat ff_smacker_demuxer = {
     .read_probe     = smacker_probe,
     .read_header    = smacker_read_header,
     .read_packet    = smacker_read_packet,
-    .read_close     = smacker_read_close,
 };