From c0a1906a54c8d2e58f708408c72cbf0b6aa534c8 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 17 Dec 2018 02:01:06 +0100 Subject: [PATCH] [source] simplify and avoid unrequired checks --- src/io/source.c | 1 + src/io/source_apple_audio.c | 3 +-- src/io/source_avcodec.c | 3 +-- src/io/source_sndfile.c | 2 +- src/io/source_wavread.c | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/io/source.c b/src/io/source.c index 6af6c3fd..5a2e4938 100644 --- a/src/io/source.c +++ b/src/io/source.c @@ -138,6 +138,7 @@ uint_t aubio_source_close(aubio_source_t * s) { } void del_aubio_source(aubio_source_t * s) { + AUBIO_ASSERT(s); if (s->s_del && s->source) s->s_del((void *)s->source); AUBIO_FREE(s); diff --git a/src/io/source_apple_audio.c b/src/io/source_apple_audio.c index d8b33af6..1cd21580 100644 --- a/src/io/source_apple_audio.c +++ b/src/io/source_apple_audio.c @@ -94,7 +94,6 @@ uint_t aubio_source_apple_audio_open (aubio_source_apple_audio_t *s, const char_ OSStatus err = noErr; UInt32 propSize; - if (s->path) AUBIO_FREE(s->path); s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); @@ -293,11 +292,11 @@ uint_t aubio_source_apple_audio_close (aubio_source_apple_audio_t *s) } void del_aubio_source_apple_audio(aubio_source_apple_audio_t * s){ + AUBIO_ASSERT(s); aubio_source_apple_audio_close (s); if (s->path) AUBIO_FREE(s->path); freeAudioBufferList(&s->bufferList); AUBIO_FREE(s); - return; } uint_t aubio_source_apple_audio_seek (aubio_source_apple_audio_t * s, uint_t pos) { diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c index 247a3452..4df2f9d0 100644 --- a/src/io/source_avcodec.c +++ b/src/io/source_avcodec.c @@ -147,7 +147,6 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, s->hop_size = hop_size; s->channels = 1; - if (s->path) AUBIO_FREE(s->path); s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); @@ -639,7 +638,7 @@ uint_t aubio_source_avcodec_close(aubio_source_avcodec_t * s) { } void del_aubio_source_avcodec(aubio_source_avcodec_t * s){ - if (!s) return; + AUBIO_ASSERT(s); aubio_source_avcodec_close(s); if (s->output != NULL) { av_free(s->output); diff --git a/src/io/source_sndfile.c b/src/io/source_sndfile.c index 7fc68c02..23cd73cb 100644 --- a/src/io/source_sndfile.c +++ b/src/io/source_sndfile.c @@ -330,7 +330,7 @@ uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) { } void del_aubio_source_sndfile(aubio_source_sndfile_t * s){ - if (!s) return; + AUBIO_ASSERT(s); aubio_source_sndfile_close(s); #ifdef HAVE_SAMPLERATE if (s->resamplers != NULL) { diff --git a/src/io/source_wavread.c b/src/io/source_wavread.c index 90638af8..deec9604 100644 --- a/src/io/source_wavread.c +++ b/src/io/source_wavread.c @@ -91,7 +91,6 @@ aubio_source_wavread_t * new_aubio_source_wavread(const char_t * path, uint_t sa goto beach; } - if (s->path) AUBIO_FREE(s->path); s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1); strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); @@ -471,7 +470,7 @@ uint_t aubio_source_wavread_close (aubio_source_wavread_t * s) { } void del_aubio_source_wavread(aubio_source_wavread_t * s) { - if (!s) return; + AUBIO_ASSERT(s); aubio_source_wavread_close(s); if (s->short_output) AUBIO_FREE(s->short_output); if (s->output) del_fmat(s->output); -- 2.11.0