profile: free the buttons/resolutions on profile cleanup

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2016-03-09 13:25:44 +10:00
parent aceef4d0d0
commit 9f9383e6ff

View File

@@ -362,9 +362,24 @@ int ratbagd_profile_new(struct ratbagd_profile **out,
struct ratbagd_profile *ratbagd_profile_free(struct ratbagd_profile *profile)
{
unsigned int i;
if (!profile)
return NULL;
profile->resolution_vtable_slot = sd_bus_slot_unref(profile->resolution_vtable_slot);
profile->resolution_enum_slot = sd_bus_slot_unref(profile->resolution_enum_slot);
profile->button_vtable_slot = sd_bus_slot_unref(profile->button_vtable_slot);
profile->button_enum_slot = sd_bus_slot_unref(profile->button_enum_slot);
for (i = 0; i< profile->n_buttons; ++i)
ratbagd_button_free(profile->buttons[i]);
for (i = 0; i< profile->n_resolutions; ++i)
ratbagd_resolution_free(profile->resolutions[i]);
mfree(profile->buttons);
mfree(profile->resolutions);
profile->path = mfree(profile->path);
/* we cannot assume the profile is gone, so set NULL explicitly */