From 6b0d2bb61bd33166b18d9504d69e25b430d2f21a Mon Sep 17 00:00:00 2001
From: Antonio Ospite <ao2@ao2.it>
Date: Wed, 28 Feb 2018 13:01:51 +0100
Subject: [PATCH] am7xxx-play: free AVCodecContext variables with
 avcodec_free_context()

Deallocate AVCodecContext variables with avcodec_free_context() instead
of av_free() this is for symmetry with the allocation functions.

Adjust and update the comment to the new code.
---
 examples/am7xxx-play.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c
index b523ca6..b43adc6 100644
--- a/examples/am7xxx-play.c
+++ b/examples/am7xxx-play.c
@@ -267,7 +267,7 @@ static int video_output_init(struct video_output_ctx *output_ctx,
 
 cleanup:
 	avcodec_close(output_codec_ctx);
-	av_free(output_codec_ctx);
+	avcodec_free_context(&output_codec_ctx);
 out:
 	return ret;
 }
@@ -474,11 +474,11 @@ cleanup_picture_raw:
 	av_frame_free(&picture_raw);
 
 cleanup_output:
-	/* av_free is needed as well,
-	 * see http://libav.org/doxygen/master/avcodec_8h.html#a5d7440cd7ea195bd0b14f21a00ef36dd
+	/* Freeing the codec context is needed as well,
+	 * see https://libav.org/documentation/doxygen/master/group__lavc__core.html#gaf4daa92361efb3523ef5afeb0b54077f
 	 */
 	avcodec_close(output_ctx.codec_ctx);
-	av_free(output_ctx.codec_ctx);
+	avcodec_free_context(&(output_ctx.codec_ctx));
 
 cleanup_input:
 	avcodec_close(input_ctx.codec_ctx);
-- 
2.1.4