mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-25 19:08:47 +02: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
@@ -76,9 +76,7 @@ static bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Jo
|
||||
child = device->children[i];
|
||||
child->driver->CloseJoystick(child, joystick);
|
||||
}
|
||||
if (serial) {
|
||||
SDL_free(serial);
|
||||
}
|
||||
SDL_free(serial);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -102,9 +100,7 @@ static bool HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Jo
|
||||
}
|
||||
|
||||
// Update the joystick with the combined serial numbers
|
||||
if (joystick->serial) {
|
||||
SDL_free(joystick->serial);
|
||||
}
|
||||
SDL_free(joystick->serial);
|
||||
joystick->serial = serial;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -797,28 +797,18 @@ static bool GIP_AttachmentIsController(GIP_Attachment *attachment)
|
||||
|
||||
static void GIP_MetadataFree(GIP_Metadata *metadata)
|
||||
{
|
||||
if (metadata->device.audio_formats) {
|
||||
SDL_free(metadata->device.audio_formats);
|
||||
}
|
||||
SDL_free(metadata->device.audio_formats);
|
||||
if (metadata->device.preferred_types) {
|
||||
int i;
|
||||
for (i = 0; i < metadata->device.num_preferred_types; i++) {
|
||||
if (metadata->device.preferred_types[i]) {
|
||||
SDL_free(metadata->device.preferred_types[i]);
|
||||
}
|
||||
SDL_free(metadata->device.preferred_types[i]);
|
||||
}
|
||||
SDL_free(metadata->device.preferred_types);
|
||||
}
|
||||
if (metadata->device.supported_interfaces) {
|
||||
SDL_free(metadata->device.supported_interfaces);
|
||||
}
|
||||
if (metadata->device.hid_descriptor) {
|
||||
SDL_free(metadata->device.hid_descriptor);
|
||||
}
|
||||
SDL_free(metadata->device.supported_interfaces);
|
||||
SDL_free(metadata->device.hid_descriptor);
|
||||
|
||||
if (metadata->message_metadata) {
|
||||
SDL_free(metadata->message_metadata);
|
||||
}
|
||||
SDL_free(metadata->message_metadata);
|
||||
SDL_memset(metadata, 0, sizeof(*metadata));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user