From: John Koleszar Date: Sat, 14 Jul 2012 00:11:21 +0000 (-0700) Subject: examples: fix memory leak X-Git-Tag: v1.2.0~142^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d3c3be6ba744614bf7035eb87bd4c76a1fb92c4;p=libvpx examples: fix memory leak Free used resources before exiting. Change-Id: If6cde6541615fbf17bf56ed335b76e676eabba93 --- diff --git a/examples/encoder_tmpl.txt b/examples/encoder_tmpl.txt index 39aa22152..1afbd8b49 100644 --- a/examples/encoder_tmpl.txt +++ b/examples/encoder_tmpl.txt @@ -68,6 +68,7 @@ case VPX_CODEC_CX_FRAME_PKT: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY +vpx_img_free(&raw); if(vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY diff --git a/examples/twopass_encoder.txt b/examples/twopass_encoder.txt index 4683bc708..2f81a9018 100644 --- a/examples/twopass_encoder.txt +++ b/examples/twopass_encoder.txt @@ -71,5 +71,17 @@ Pass Progress Reporting It's sometimes helpful to see when each pass completes. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TWOPASS_LOOP_END printf("Pass %d complete.\n", pass+1); + if(vpx_codec_destroy(&codec)) + die_codec(&codec, "Failed to destroy codec"); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TWOPASS_LOOP_END + + +Clean-up +----------------------------- +Destruction of the encoder instance must be done on each pass. The +raw image should be destroyed at the end as usual. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY +vpx_img_free(&raw); +free(stats.buf); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY