Don't do NULL-checks before SDL_free()

Replaces the pattern

  if (ptr) {
    SDL_free(ptr);
  }

with

  SDL_free(ptr);
This commit is contained in:
Eddy Jansson
2025-10-19 11:07:48 +02:00
committed by Sam Lantinga
parent 2f810e0a5f
commit aaee09d6ed
40 changed files with 76 additions and 229 deletions

View File

@@ -223,9 +223,7 @@ static void OPENSLES_DestroyPCMRecorder(SDL_AudioDevice *device)
audiodata->playsem = NULL;
}
if (audiodata->mixbuff) {
SDL_free(audiodata->mixbuff);
}
SDL_free(audiodata->mixbuff);
}
// !!! FIXME: make this non-blocking!
@@ -419,9 +417,7 @@ static void OPENSLES_DestroyPCMPlayer(SDL_AudioDevice *device)
audiodata->playsem = NULL;
}
if (audiodata->mixbuff) {
SDL_free(audiodata->mixbuff);
}
SDL_free(audiodata->mixbuff);
}
static bool OPENSLES_CreatePCMPlayer(SDL_AudioDevice *device)

View File

@@ -635,16 +635,12 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons
if (subject == PW_ID_CORE && key && value) {
if (!SDL_strcmp(key, "default.audio.sink")) {
if (pipewire_default_sink_id) {
SDL_free(pipewire_default_sink_id);
}
SDL_free(pipewire_default_sink_id);
pipewire_default_sink_id = get_name_from_json(value);
node->persist = true;
change_default_device(pipewire_default_sink_id);
} else if (!SDL_strcmp(key, "default.audio.source")) {
if (pipewire_default_source_id) {
SDL_free(pipewire_default_source_id);
}
SDL_free(pipewire_default_source_id);
pipewire_default_source_id = get_name_from_json(value);
node->persist = true;
change_default_device(pipewire_default_source_id);