shithub: opus

Download patch

ref: 9aebd7e03d95a8999ad939c9e8a6bf420ffd6d56
parent: 34d821ceae87bd8baf8eedbd8037ef3dc05455a5
author: Mark Harris <[email protected]>
date: Tue Jun 13 17:22:51 EDT 2017

Free all allocated memory in unit tests

--- a/celt/tests/test_unit_dft.c
+++ b/celt/tests/test_unit_dft.c
@@ -86,9 +86,8 @@
 void test1d(int nfft,int isinverse,int arch)
 {
     size_t buflen = sizeof(kiss_fft_cpx)*nfft;
-
-    kiss_fft_cpx  * in = (kiss_fft_cpx*)malloc(buflen);
-    kiss_fft_cpx  * out= (kiss_fft_cpx*)malloc(buflen);
+    kiss_fft_cpx *in;
+    kiss_fft_cpx *out;
     int k;
 #ifdef CUSTOM_MODES
     kiss_fft_state *cfg = opus_fft_alloc(nfft,0,0,arch);
@@ -103,6 +102,9 @@
     else return;
     cfg = mode->mdct.kfft[id];
 #endif
+
+    in = (kiss_fft_cpx*)malloc(buflen);
+    out = (kiss_fft_cpx*)malloc(buflen);
 
     for (k=0;k<nfft;++k) {
         in[k].r = (rand() % 32767) - 16384;
--- a/celt/tests/test_unit_mdct.c
+++ b/celt/tests/test_unit_mdct.c
@@ -106,11 +106,10 @@
 void test1d(int nfft,int isinverse,int arch)
 {
     size_t buflen = sizeof(kiss_fft_scalar)*nfft;
-
-    kiss_fft_scalar  * in = (kiss_fft_scalar*)malloc(buflen);
-    kiss_fft_scalar  * in_copy = (kiss_fft_scalar*)malloc(buflen);
-    kiss_fft_scalar  * out= (kiss_fft_scalar*)malloc(buflen);
-    opus_val16  * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2);
+    kiss_fft_scalar *in;
+    kiss_fft_scalar *in_copy;
+    kiss_fft_scalar *out;
+    opus_val16 *window;
     int k;
 
 #ifdef CUSTOM_MODES
@@ -130,6 +129,12 @@
     else return;
     cfg = &mode->mdct;
 #endif
+
+    in = (kiss_fft_scalar*)malloc(buflen);
+    in_copy = (kiss_fft_scalar*)malloc(buflen);
+    out = (kiss_fft_scalar*)malloc(buflen);
+    window = (opus_val16*)malloc(sizeof(opus_val16)*nfft/2);
+
     for (k=0;k<nfft;++k) {
         in[k] = (rand() % 32768) - 16384;
     }