mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-04 14:49:40 +00:00
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:
committed by
Sam Lantinga
parent
2f810e0a5f
commit
aaee09d6ed
@@ -2642,9 +2642,7 @@ void SetGamepadButtonLabel(GamepadButton *ctx, const char *label)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->label) {
|
||||
SDL_free(ctx->label);
|
||||
}
|
||||
SDL_free(ctx->label);
|
||||
|
||||
ctx->label = SDL_strdup(label);
|
||||
ctx->label_width = (float)(FONT_CHARACTER_SIZE * SDL_strlen(label));
|
||||
|
||||
@@ -1237,12 +1237,8 @@ static void DelController(SDL_JoystickID id)
|
||||
CyclePS5TriggerEffect(&controllers[i]);
|
||||
}
|
||||
SDL_assert(controllers[i].gamepad == NULL);
|
||||
if (controllers[i].axis_state) {
|
||||
SDL_free(controllers[i].axis_state);
|
||||
}
|
||||
if (controllers[i].imu_state) {
|
||||
SDL_free(controllers[i].imu_state);
|
||||
}
|
||||
SDL_free(controllers[i].axis_state);
|
||||
SDL_free(controllers[i].imu_state);
|
||||
if (controllers[i].joystick) {
|
||||
SDL_CloseJoystick(controllers[i].joystick);
|
||||
}
|
||||
|
||||
@@ -938,12 +938,8 @@ void DestroyVulkanVideoContext(VulkanVideoContext *context)
|
||||
if (context->device) {
|
||||
context->vkDeviceWaitIdle(context->device);
|
||||
}
|
||||
if (context->instanceExtensions) {
|
||||
SDL_free(context->instanceExtensions);
|
||||
}
|
||||
if (context->deviceExtensions) {
|
||||
SDL_free(context->deviceExtensions);
|
||||
}
|
||||
SDL_free(context->instanceExtensions);
|
||||
SDL_free(context->deviceExtensions);
|
||||
if (context->waitSemaphores) {
|
||||
for (uint32_t i = 0; i < context->waitSemaphoreCount; ++i) {
|
||||
context->vkDestroySemaphore(context->device, context->waitSemaphores[i], NULL);
|
||||
|
||||
@@ -123,8 +123,6 @@ SDL_Texture *LoadTexture(SDL_Renderer *renderer, const char *file, bool transpar
|
||||
}
|
||||
}
|
||||
SDL_DestroySurface(temp);
|
||||
if (path) {
|
||||
SDL_free(path);
|
||||
}
|
||||
SDL_free(path);
|
||||
return texture;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user