[AD] New patch for ex_audio_simple

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Fix the leak memory where you press 'r' key.
From 67c902a849ed6b42bc3c9d03ad97e57be8fb418f Mon Sep 17 00:00:00 2001
From: Rm Beer <rmbeer2@xxxxxxxxx>
Date: Tue, 25 Apr 2017 17:32:21 -0300
Subject: [PATCH] Fix ex_audio_simple for avoid the leak memory

---
 examples/ex_audio_simple.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/examples/ex_audio_simple.c b/examples/ex_audio_simple.c
index 2f47690ef..b0b75114b 100644
--- a/examples/ex_audio_simple.c
+++ b/examples/ex_audio_simple.c
@@ -98,11 +98,18 @@ Restart:
           */
          if (event.keyboard.unichar == 'r') {
             al_uninstall_audio();
+            for (i = 0; i < argc && i < MAX_SAMPLE_DATA; i++) {
+               if(sample[i])al_destroy_sample(sample[i]);
+            }
             goto Restart;
          }
       }
    }
 
+   for (i = 0; i < argc && i < MAX_SAMPLE_DATA; i++) {
+      if(sample[i])al_destroy_sample(sample[i]);
+   }
+
    /* Sample data and other objects will be automatically freed. */
    al_uninstall_audio();
 
-- 
2.12.2



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/