ref: c0a1906a54c8d2e58f708408c72cbf0b6aa534c8
parent: d16fbba0af7bbc3300402f2717da681ff5d4a65e
author: Paul Brossier <piem@piem.org>
date: Sun Dec 16 21:01:06 EST 2018
[source] simplify and avoid unrequired checks
--- a/src/io/source.c
+++ b/src/io/source.c
@@ -138,6 +138,7 @@
}
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);
--- a/src/io/source_apple_audio.c
+++ b/src/io/source_apple_audio.c
@@ -94,7 +94,6 @@
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 @@
}
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) {
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -147,7 +147,6 @@
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 @@
}
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);
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -330,7 +330,7 @@
}
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) {
--- a/src/io/source_wavread.c
+++ b/src/io/source_wavread.c
@@ -91,7 +91,6 @@
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 @@
}
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);