changeset 36306:97638800c6f3

Fix and simplify alloc/free of AVIO buffer.
author reimar
date Mon, 05 Aug 2013 06:46:41 +0000
parents d8a13d907c61
children a3a1ad19b8b4
files libmpdemux/demux_lavf.c
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c	Sun Aug 04 20:19:58 2013 +0000
+++ b/libmpdemux/demux_lavf.c	Mon Aug 05 06:46:41 2013 +0000
@@ -70,7 +70,6 @@
     AVInputFormat *avif;
     AVFormatContext *avfc;
     AVIOContext *pb;
-    uint8_t *buffer;
     int audio_streams;
     int video_streams;
     int sub_streams;
@@ -553,8 +552,8 @@
         av_strlcat(mp_filename, "foobar.dummy", sizeof(mp_filename));
 
     if (!(priv->avif->flags & AVFMT_NOFILE)) {
-        priv->buffer = av_mallocz(BIO_BUFFER_SIZE);
-        priv->pb = avio_alloc_context(priv->buffer, BIO_BUFFER_SIZE, 0,
+        uint8_t *buffer = av_mallocz(BIO_BUFFER_SIZE);
+        priv->pb = avio_alloc_context(buffer, BIO_BUFFER_SIZE, 0,
                                       demuxer, mp_read, NULL, mp_seek);
         priv->pb->read_seek = mp_read_seek;
         if (!demuxer->stream->end_pos || (demuxer->stream->flags & MP_STREAM_SEEK) != MP_STREAM_SEEK)
@@ -873,7 +872,7 @@
          av_freep(&priv->avfc->key);
          avformat_close_input(&priv->avfc);
         }
-        av_freep(&priv->buffer);
+        av_freep(&priv->pb->buffer);
         av_freep(&priv->pb);
         free(priv); demuxer->priv= NULL;
     }