Christoph Mallon: Remove pointless if (x) before SDL_free(x)

This commit is contained in:
Sam Lantinga 2013-08-29 08:29:21 -07:00
parent edc88be724
commit 08dfaaa2e6
63 changed files with 157 additions and 349 deletions

View file

@ -300,9 +300,7 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
static void
SDL_StreamDeinit(SDL_AudioStreamer * stream)
{
if (stream->buffer != NULL) {
SDL_free(stream->buffer);
}
SDL_free(stream->buffer);
}
#if defined(ANDROID)
@ -632,9 +630,7 @@ free_device_list(char ***devices, int *devCount)
}
}
if (*devices != NULL) {
SDL_free(*devices);
}
SDL_free(*devices);
*devices = NULL;
*devCount = 0;
@ -761,9 +757,7 @@ close_audio_device(SDL_AudioDevice * device)
if (device->mixer_lock != NULL) {
SDL_DestroyMutex(device->mixer_lock);
}
if (device->fake_stream != NULL) {
SDL_FreeAudioMem(device->fake_stream);
}
SDL_FreeAudioMem(device->fake_stream);
if (device->convert.needed) {
SDL_FreeAudioMem(device->convert.buf);
}

View file

@ -449,10 +449,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
/* Read the audio data format chunk */
chunk.data = NULL;
do {
if (chunk.data != NULL) {
SDL_free(chunk.data);
chunk.data = NULL;
}
SDL_free(chunk.data);
chunk.data = NULL;
lenread = ReadChunk(src, &chunk);
if (lenread < 0) {
was_error = 1;
@ -549,10 +547,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
/* Read the audio data chunk */
*audio_buf = NULL;
do {
if (*audio_buf != NULL) {
SDL_free(*audio_buf);
*audio_buf = NULL;
}
SDL_free(*audio_buf);
*audio_buf = NULL;
lenread = ReadChunk(src, &chunk);
if (lenread < 0) {
was_error = 1;
@ -583,9 +579,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
*audio_len &= ~(samplesize - 1);
done:
if (format != NULL) {
SDL_free(format);
}
SDL_free(format);
if (src) {
if (freesrc) {
SDL_RWclose(src);
@ -606,9 +600,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
void
SDL_FreeWAV(Uint8 * audio_buf)
{
if (audio_buf != NULL) {
SDL_free(audio_buf);
}
SDL_free(audio_buf);
}
static int

View file

@ -340,10 +340,8 @@ static void
ALSA_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->pcm_handle) {
ALSA_snd_pcm_drain(this->hidden->pcm_handle);
ALSA_snd_pcm_close(this->hidden->pcm_handle);

View file

@ -204,10 +204,8 @@ static void
ARTS_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->stream) {
SDL_NAME(arts_close_stream) (this->hidden->stream);
this->hidden->stream = 0;

View file

@ -214,10 +214,8 @@ static void
BSDAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;

View file

@ -88,10 +88,8 @@ static void
DISKAUD_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->output != NULL) {
SDL_RWclose(this->hidden->output);
this->hidden->output = NULL;

View file

@ -61,10 +61,8 @@ static void
DSP_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;

View file

@ -176,10 +176,8 @@ static void
ESD_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
SDL_NAME(esd_close) (this->hidden->audio_fd);
this->hidden->audio_fd = -1;

View file

@ -169,10 +169,8 @@ static void
SDL_FS_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->stream) {
this->hidden->stream->Release(this->hidden->stream);
this->hidden->stream = NULL;

View file

@ -191,10 +191,8 @@ static void
NAS_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->aud) {
NAS_AuCloseServer(this->hidden->aud);
this->hidden->aud = 0;

View file

@ -231,10 +231,8 @@ static void
PAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;

View file

@ -300,10 +300,8 @@ static void
PULSEAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->stream) {
PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
PULSEAUDIO_pa_stream_unref(this->hidden->stream);

View file

@ -328,10 +328,8 @@ QSA_CloseDevice(_THIS)
this->hidden->audio_handle = NULL;
}
if (this->hidden->pcm_buf != NULL) {
SDL_FreeAudioMem(this->hidden->pcm_buf);
this->hidden->pcm_buf = NULL;
}
SDL_FreeAudioMem(this->hidden->pcm_buf);
this->hidden->pcm_buf = NULL;
SDL_free(this->hidden);
this->hidden = NULL;

View file

@ -181,10 +181,8 @@ static void
SNDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if ( this->hidden->dev != NULL ) {
SNDIO_sio_close(this->hidden->dev);
this->hidden->dev = NULL;

View file

@ -184,14 +184,10 @@ static void
SUNAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
if (this->hidden->mixbuf != NULL) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
if (this->hidden->ulaw_buf != NULL) {
SDL_free(this->hidden->ulaw_buf);
this->hidden->ulaw_buf = NULL;
}
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
SDL_free(this->hidden->ulaw_buf);
this->hidden->ulaw_buf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;

View file

@ -176,11 +176,9 @@ WINMM_CloseDevice(_THIS)
}
}
if (this->hidden->mixbuf != NULL) {
/* Free raw mixing buffer */
SDL_free(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
}
/* Free raw mixing buffer */
SDL_free(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
if (this->hidden->hin) {
waveInClose(this->hidden->hin);

View file

@ -205,9 +205,7 @@ XAUDIO2_CloseDevice(_THIS)
if (ixa2 != NULL) {
IXAudio2_Release(ixa2);
}
if (this->hidden->mixbuf != NULL) {
SDL_free(this->hidden->mixbuf);
}
SDL_free(this->hidden->mixbuf);
if (this->hidden->semaphore != NULL) {
CloseHandle(this->hidden->semaphore);
}