ref: e4e0861cffbc8d3a53dcd18f9ae85797690d67c7
parent: c4a8bc138e49de8b43fcd2221ef84dfa5073208f
author: Paul Brossier <piem@piem.org>
date: Sat Nov 24 13:53:12 EST 2018
[onset] safer deletion method
--- a/src/onset/onset.c
+++ b/src/onset/onset.c
@@ -256,11 +256,14 @@
o->pv = new_aubio_pvoc(buf_size, o->hop_size);
o->pp = new_aubio_peakpicker();
o->od = new_aubio_specdesc(onset_mode,buf_size);
- if (o->od == NULL) goto beach_specdesc;
o->fftgrain = new_cvec(buf_size);
o->desc = new_fvec(1);
o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate);
+ if (!o->pv || !o->pp || !o->od || !o->fftgrain
+ || !o->desc || !o->spectral_whitening)
+ goto beach;
+
/* initialize internal variables */
aubio_onset_set_default_parameters (o, onset_mode);
@@ -267,11 +270,8 @@
aubio_onset_reset(o);
return o;
-beach_specdesc:
- del_aubio_peakpicker(o->pp);
- del_aubio_pvoc(o->pv);
beach:
- AUBIO_FREE(o);
+ del_aubio_onset(o);
return NULL;
}
@@ -339,11 +339,17 @@
void del_aubio_onset (aubio_onset_t *o)
{
- del_aubio_spectral_whitening(o->spectral_whitening);
- del_aubio_specdesc(o->od);
- del_aubio_peakpicker(o->pp);
- del_aubio_pvoc(o->pv);
- del_fvec(o->desc);
- del_cvec(o->fftgrain);
+ if (o->spectral_whitening)
+ del_aubio_spectral_whitening(o->spectral_whitening);
+ if (o->od)
+ del_aubio_specdesc(o->od);
+ if (o->pp)
+ del_aubio_peakpicker(o->pp);
+ if (o->pv)
+ del_aubio_pvoc(o->pv);
+ if (o->desc)
+ del_fvec(o->desc);
+ if (o->fftgrain)
+ del_cvec(o->fftgrain);
AUBIO_FREE(o);
}