tests/src: fix memory leaks
authorPaul Brossier <piem@piem.org>
Tue, 10 Jul 2012 22:26:51 +0000 (15:26 -0700)
committerPaul Brossier <piem@piem.org>
Tue, 10 Jul 2012 22:26:51 +0000 (15:26 -0700)
tests/src/onset/test-peakpicker.c
tests/src/pitch/test-pitch.c
tests/src/pitch/test-pitchfcomb.c
tests/src/spectral/test-phasevoc-jack.c
tests/src/spectral/test-tss.c

index 1ce6bb4..0afce6f 100644 (file)
@@ -16,6 +16,7 @@ int main(){
         aubio_peakpicker_do(o, in, out);
 
         del_aubio_peakpicker(o);
+        del_fvec(out);
         del_fvec(in);
         return 0;
 }
index ac884c6..70d5e93 100644 (file)
@@ -19,6 +19,7 @@ main ()
   };
 
   del_aubio_pitch (o);
+  del_fvec (out);
   del_fvec (in);
   aubio_cleanup ();
 
index dda6099..bfe33ee 100644 (file)
@@ -18,6 +18,7 @@ int main(){
         };
 
         del_aubio_pitchfcomb(o);
+        del_fvec(out);
         del_fvec(in);
         aubio_cleanup();
 
index d42bdd3..d1b8f19 100644 (file)
@@ -10,7 +10,9 @@
 #include <stdio.h>
 #include <unistd.h>  /* sleep() */
 #include <aubio.h>
+#ifdef HAVE_JACK
 #include "jackio.h"
+#endif /* HAVE_JACK */
 
 uint_t testing  = 0;  /* change this to 1 to listen        */
 
index 0040168..c0600ec 100644 (file)
 #include <aubio.h>
 
 int main(){
-       int i;
-        uint_t win_s    = 1024; /* window size                       */
-        uint_t hop_s    = 256;  /* hop size                          */
-        /* allocate some memory */
-        fvec_t * in       = new_fvec (hop_s); /* input buffer       */
-        cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
-        cvec_t * cstead   = new_cvec (win_s); /* fft norm and phase */
-        cvec_t * ctrans   = new_cvec (win_s); /* fft norm and phase */
-        fvec_t * stead    = new_fvec (hop_s); /* output buffer      */
-        fvec_t * trans    = new_fvec (hop_s); /* output buffer      */
-        /* allocate fft and other memory space */
-        aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
-        aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
-        aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);
+  int i;
+  uint_t win_s    = 1024; /* window size                       */
+  uint_t hop_s    = 256;  /* hop size                          */
 
-       aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
-        /* fill input with some data */
-        printf("initialised\n");
-        /* execute stft */
-       for (i = 0; i < 10; i++) {
-               aubio_pvoc_do (pv,in,fftgrain);
-               aubio_tss_do  (tss,fftgrain,ctrans,cstead);
-               aubio_pvoc_rdo(pvt,cstead,stead);
-               aubio_pvoc_rdo(pvs,ctrans,trans);
-       }
-        del_aubio_pvoc(pv);
-        del_fvec(in);
-        del_cvec(fftgrain);
-        del_cvec(cstead);
-        del_cvec(ctrans);
-        del_fvec(stead);
-        del_fvec(trans);
-        aubio_cleanup();
-        printf("memory freed\n");
-        return 0;
+  /* allocate some memory */
+  fvec_t * in       = new_fvec (hop_s); /* input buffer       */
+  cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */
+  cvec_t * cstead   = new_cvec (win_s); /* fft norm and phase */
+  cvec_t * ctrans   = new_cvec (win_s); /* fft norm and phase */
+  fvec_t * stead    = new_fvec (hop_s); /* output buffer      */
+  fvec_t * trans    = new_fvec (hop_s); /* output buffer      */
+  /* allocate phase vocoders and transient steady-state separation */
+  aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
+  aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
+  aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);
+  aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
+
+  /* fill input with some data */
+  printf("initialised\n");
+
+  /* execute stft */
+  for (i = 0; i < 10; i++) {
+    aubio_pvoc_do (pv,in,fftgrain);
+    aubio_tss_do  (tss,fftgrain,ctrans,cstead);
+    aubio_pvoc_rdo(pvt,cstead,stead);
+    aubio_pvoc_rdo(pvs,ctrans,trans);
+  }
+
+  del_aubio_pvoc(pv);
+  del_aubio_pvoc(pvt);
+  del_aubio_pvoc(pvs);
+  del_aubio_tss(tss);
+
+  del_fvec(in);
+  del_cvec(fftgrain);
+  del_cvec(cstead);
+  del_cvec(ctrans);
+  del_fvec(stead);
+  del_fvec(trans);
+  aubio_cleanup();
+  printf("memory freed\n");
+  return 0;
 }