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

@@ -1349,9 +1349,7 @@ static void D3D12_INTERNAL_ReleaseBufferContainer(
}
// Containers are just client handles, so we can free immediately
if (container->debugName) {
SDL_free(container->debugName);
}
SDL_free(container->debugName);
SDL_free(container->buffers);
SDL_free(container);
@@ -1426,9 +1424,7 @@ static void D3D12_INTERNAL_ReleaseTextureContainer(
SDL_DestroyProperties(container->header.info.props);
// Containers are just client handles, so we can destroy immediately
if (container->debugName) {
SDL_free(container->debugName);
}
SDL_free(container->debugName);
SDL_free(container->textures);
SDL_free(container);
@@ -2072,9 +2068,7 @@ static void D3D12_SetBufferName(
D3D12BufferContainer *container = (D3D12BufferContainer *)buffer;
if (renderer->debug_mode && text != NULL) {
if (container->debugName != NULL) {
SDL_free(container->debugName);
}
SDL_free(container->debugName);
container->debugName = SDL_strdup(text);
@@ -2096,9 +2090,7 @@ static void D3D12_SetTextureName(
D3D12TextureContainer *container = (D3D12TextureContainer *)texture;
if (renderer->debug_mode && text != NULL) {
if (container->debugName != NULL) {
SDL_free(container->debugName);
}
SDL_free(container->debugName);
container->debugName = SDL_strdup(text);

View File

@@ -4958,9 +4958,7 @@ static void VULKAN_DestroyDevice(
j);
}
if (renderer->memoryAllocator->subAllocators[i].allocations != NULL) {
SDL_free(renderer->memoryAllocator->subAllocators[i].allocations);
}
SDL_free(renderer->memoryAllocator->subAllocators[i].allocations);
SDL_free(renderer->memoryAllocator->subAllocators[i].sortedFreeRegions);
}
@@ -6987,9 +6985,7 @@ static void VULKAN_ReleaseTexture(
SDL_DestroyProperties(vulkanTextureContainer->header.info.props);
// Containers are just client handles, so we can destroy immediately
if (vulkanTextureContainer->debugName != NULL) {
SDL_free(vulkanTextureContainer->debugName);
}
SDL_free(vulkanTextureContainer->debugName);
SDL_free(vulkanTextureContainer->textures);
SDL_free(vulkanTextureContainer);