shithub: libvpx

Download patch

ref: 4d3c3be6ba744614bf7035eb87bd4c76a1fb92c4
parent: a6f4fc5a93be96700eb53d2b70b498a8c28edf97
author: John Koleszar <jkoleszar@google.com>
date: Fri Jul 13 13:11:21 EDT 2012

examples: fix memory leak

Free used resources before exiting.

Change-Id: If6cde6541615fbf17bf56ed335b76e676eabba93

--- a/examples/encoder_tmpl.txt
+++ b/examples/encoder_tmpl.txt
@@ -68,6 +68,7 @@
 
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
+vpx_img_free(&raw);
 if(vpx_codec_destroy(&codec))
     die_codec(&codec, "Failed to destroy codec");
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY
--- a/examples/twopass_encoder.txt
+++ b/examples/twopass_encoder.txt
@@ -71,5 +71,17 @@
 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