diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-06-22 04:06:37 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-07-04 19:19:34 +0200 |
commit | 09a39042db1b34672ba92a29c2b2f8f18a588a40 (patch) | |
tree | b47151a66fc2dbcb539adc51e3b377c6e93b30a5 /libavformat/smacker.c | |
parent | 6e5dbd62681c2059bb7047f0b42d33fdf5a9d40d (diff) | |
download | ffmpeg-09a39042db1b34672ba92a29c2b2f8f18a588a40.tar.gz |
avformat/smacker: Don't allocate arrays separately
Allocating two arrays with the same number of elements together
simplifies freeing them.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/smacker.c')
-rw-r--r-- | libavformat/smacker.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 0138af3d14..2043563fdb 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -205,13 +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)); - smk->frm_flags = av_malloc(smk->frames); - if (!smk->frm_size || !smk->frm_flags) { - av_freep(&smk->frm_size); - av_freep(&smk->frm_flags); + smk->frm_size = av_malloc_array(smk->frames, sizeof(*smk->frm_size) + + sizeof(*smk->frm_flags)); + if (!smk->frm_size) return AVERROR(ENOMEM); - } + smk->frm_flags = (void*)(smk->frm_size + smk->frames); /* read frame info */ for (i = 0; i < smk->frames; i++) { @@ -225,7 +223,6 @@ static int smacker_read_header(AVFormatContext *s) ret = avio_read(pb, par->extradata + 16, par->extradata_size - 16); if (ret != par->extradata_size - 16) { av_freep(&smk->frm_size); - av_freep(&smk->frm_flags); return AVERROR(EIO); } @@ -362,7 +359,6 @@ static int smacker_read_close(AVFormatContext *s) SmackerContext *smk = s->priv_data; av_freep(&smk->frm_size); - av_freep(&smk->frm_flags); return 0; } |