Use the new AVIOContext destructor.
authorAnton Khirnov <anton@khirnov.net>
Fri, 13 Jan 2017 11:04:16 +0000 (12:04 +0100)
committerAnton Khirnov <anton@khirnov.net>
Sat, 11 Feb 2017 10:37:45 +0000 (11:37 +0100)
avprobe.c
libavformat/avidec.c
libavformat/flac_picture.c
libavformat/hdsenc.c
libavformat/mpjpegdec.c
libavformat/rdt.c
libavformat/segment.c
libavformat/smoothstreamingenc.c
libavformat/swfdec.c
libavformat/tests/movenc.c
libavformat/wtv.c

index a24e6440eb6138f744ae218268c08b95a8c41342..613e090be6e8bc5ada0ad565bfdda0ebb5ab56a3 100644 (file)
--- a/avprobe.c
+++ b/avprobe.c
@@ -1178,7 +1178,7 @@ int main(int argc, char **argv)
     ret = probe_file(input_filename);
     probe_footer();
     avio_flush(probe_out);
-    av_freep(&probe_out);
+    avio_context_free(&probe_out);
     av_freep(&buffer);
     uninit_opts();
     avformat_network_deinit();
index 0439c9c94cc95886e65b4aaf1838cbce275657e6..701cccb6b0ad1676be0bb62f6ede737c9cad24f5 100644 (file)
@@ -901,7 +901,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt)
         return 1;
 
 error:
-        av_freep(&pb);
+        avio_context_free(&pb);
     }
     return 0;
 }
@@ -1576,7 +1576,7 @@ static int avi_read_close(AVFormatContext *s)
         AVIStream *ast = st->priv_data;
         if (ast) {
             if (ast->sub_ctx) {
-                av_freep(&ast->sub_ctx->pb);
+                avio_context_free(&ast->sub_ctx->pb);
                 avformat_close_input(&ast->sub_ctx);
             }
             av_free(ast->sub_buffer);
index 1381a28b8064fc8b7ae2d78a08fb157dace9392a..fd0bb0291fd0f3c975bc0b8be7a60cc5c1c264f0 100644 (file)
@@ -139,14 +139,14 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
     if (desc)
         av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
 
-    av_freep(&pb);
+    avio_context_free(&pb);
 
     return 0;
 
 fail:
     av_buffer_unref(&data);
     av_freep(&desc);
-    av_freep(&pb);
+    avio_context_free(&pb);
 
     return ret;
 }
index e32c36503e5cd2c80a61fc1131adc2e3e090c0ee..a608e7eb0f793df555d91ff7f2158a333c992498 100644 (file)
@@ -143,8 +143,8 @@ static void hds_free(AVFormatContext *s)
             ff_format_io_close(s, &os->out);
         if (os->ctx && os->ctx_inited)
             av_write_trailer(os->ctx);
-        if (os->ctx && os->ctx->pb)
-            av_free(os->ctx->pb);
+        if (os->ctx)
+            avio_context_free(&os->ctx->pb);
         if (os->ctx)
             avformat_free_context(os->ctx);
         av_free(os->metadata);
index 886bdfcbef4432f887e60b264cf4fe597b7b5966..844aa87da8ff1968307e387ab1badfec26434a0a 100644 (file)
@@ -102,7 +102,7 @@ static int mpjpeg_read_probe(AVProbeData *p)
         }
     }
 
-    av_free(pb);
+    avio_context_free(&pb);
 
     return ret;
 }
index 825e4f1355209b64e744f57e03c0219db9f71cd2..0adfa2534f64bf4f6bb06c96976e10c42bf53dda 100644 (file)
@@ -324,7 +324,7 @@ get_cache:
                                   st, rdt->rmst[st->index], pkt);
         if (rdt->audio_pkt_cnt == 0 &&
             st->codecpar->codec_id == AV_CODEC_ID_AAC)
-            av_freep(&rdt->rmctx->pb);
+            avio_context_free(&rdt->rmctx->pb);
     }
     pkt->stream_index = st->index;
     pkt->pts = *timestamp;
index fd68a9f753d7d4baca47b22168495a44c3ec1b5a..7d23afc0131a40041273eb4005f651702cea00c3 100644 (file)
@@ -184,10 +184,10 @@ static int open_null_ctx(AVIOContext **ctx)
     return 0;
 }
 
-static void close_null_ctx(AVIOContext *pb)
+static void close_null_ctx(AVIOContext **pb)
 {
-    av_free(pb->buffer);
-    av_free(pb);
+    av_free((*pb)->buffer);
+    avio_context_free(pb);
 }
 
 static void seg_free_context(SegmentContext *seg)
@@ -259,7 +259,7 @@ static int seg_write_header(AVFormatContext *s)
     }
 
     if (!seg->write_header_trailer) {
-        close_null_ctx(oc->pb);
+        close_null_ctx(&oc->pb);
         if ((ret = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, NULL)) < 0)
             goto fail;
     }
@@ -353,7 +353,7 @@ static int seg_write_trailer(struct AVFormatContext *s)
         if ((ret = open_null_ctx(&oc->pb)) < 0)
             goto fail;
         ret = av_write_trailer(oc);
-        close_null_ctx(oc->pb);
+        close_null_ctx(&oc->pb);
     } else {
         ret = segment_end(oc, 1);
     }
index 065ecc2ee461837a20e21dc1439e67aafca9469e..997b9e636cc2b073181bbdcbcf5bd7a0a715e717 100644 (file)
@@ -187,8 +187,8 @@ static void ism_free(AVFormatContext *s)
         os->out = os->out2 = os->tail_out = NULL;
         if (os->ctx && os->ctx_inited)
             av_write_trailer(os->ctx);
-        if (os->ctx && os->ctx->pb)
-            av_free(os->ctx->pb);
+        if (os->ctx)
+            avio_context_free(&os->ctx->pb);
         if (os->ctx)
             avformat_free_context(os->ctx);
         av_free(os->private_str);
index 7bb67de8d8fe45293324a4369929b16e1ab8eddb..984fedffcf9740249690a3177c8ef84ff7b1df4a 100644 (file)
@@ -310,7 +310,9 @@ static av_cold int swf_read_close(AVFormatContext *avctx)
     inflateEnd(&s->zstream);
     av_freep(&s->zbuf_in);
     av_freep(&s->zbuf_out);
-    av_freep(&s->zpb);
+
+    avio_context_free(&s->zpb);
+
     return 0;
 }
 #endif
index 05432eb488d9393498d60ed0003e783b64257dac..583a8d9ca43367dc9f1161087b111f2ba063b199 100644 (file)
@@ -338,7 +338,7 @@ static void signal_init_ts(void)
 static void finish(void)
 {
     av_write_trailer(ctx);
-    av_free(ctx->pb);
+    avio_context_free(&ctx->pb);
     avformat_free_context(ctx);
     ctx = NULL;
 }
index 2cab4e5bd05e0782e15b67eabc80528bf7cef55a..794dd4bb71b689567e9738e92f9f71b0b75217f7 100644 (file)
@@ -313,7 +313,7 @@ static void wtvfile_close(AVIOContext *pb)
     av_free(wf->sectors);
     av_free(wf);
     av_free(pb->buffer);
-    av_free(pb);
+    avio_context_free(&pb);
 }
 
 /*