From: Paul Brossier Date: Mon, 16 Jul 2012 18:19:29 +0000 (-0600) Subject: tests/src/io/test-source_sndfile.c: avoid memory leak X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ab7d1002918618b57d1741e4bcdbea6c73a27c38;p=aubio.git tests/src/io/test-source_sndfile.c: avoid memory leak --- diff --git a/tests/src/io/test-source_sndfile.c b/tests/src/io/test-source_sndfile.c index 9dc78254..fa8179e5 100644 --- a/tests/src/io/test-source_sndfile.c +++ b/tests/src/io/test-source_sndfile.c @@ -2,17 +2,18 @@ #include #include "config.h" -char_t *path = "/home/piem/archives/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav"; +char_t *path = "/home/piem/archives/samples/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav"; int main(){ + int err = 0; #ifdef HAVE_SNDFILE - uint_t samplerate = 32000; + uint_t samplerate = 192000; uint_t hop_size = 512; uint_t read = hop_size; fvec_t *vec = new_fvec(hop_size); aubio_source_sndfile_t * s = new_aubio_source_sndfile(path, samplerate, hop_size); - if (!s) return -1; + if (!s) { err = 1; goto beach; } while ( read == hop_size ) { aubio_source_sndfile_do(s, vec, &read); @@ -20,10 +21,13 @@ int main(){ fprintf(stdout, "%d [%f, %f, ..., %f]\n", read, vec->data[0], vec->data[1], vec->data[read - 1]); } +beach: del_aubio_source_sndfile(s); + del_fvec(vec); #else fprintf(stderr, "ERR: aubio was not compiled with aubio_source_sndfile\n"); + err = 2; #endif /* HAVE_SNDFILE */ - return 0; + return err; }