evdev: free aux_data struct in fallback destroy function
authorJengHyun Kang <jhyuni.kang@samsung.com>
Fri, 12 Oct 2018 07:00:46 +0000 (16:00 +0900)
committerjeon <jhyuni.kang@samsung.com>
Tue, 5 Jan 2021 10:39:43 +0000 (19:39 +0900)
Change-Id: Ief8b7ed7bf1aea714e635ca2661450b519012015

src/evdev-fallback.c [changed mode: 0755->0644]
src/evdev.c
src/evdev.h

old mode 100755 (executable)
new mode 100644 (file)
index ce35493..4f66b4e
@@ -1230,6 +1230,22 @@ fallback_return_to_neutral_state(struct fallback_dispatch *dispatch,
        memset(dispatch->hw_key_mask, 0, sizeof(dispatch->last_hw_key_mask));
 }
 
+static void
+fallback_dispatch_free_aux_data(struct fallback_dispatch *dispatch)
+{
+       int i;
+       struct mt_aux_data *aux_data, *aux_data_tmp;
+
+       for (i = 0; i < (int)dispatch->mt.slots_len; i++) {
+               list_for_each_safe(aux_data, aux_data_tmp, &dispatch->mt.aux_data_list[i], link) {
+                       list_remove(&aux_data->link);
+                       free(aux_data);
+               }
+               list_remove(&dispatch->mt.aux_data_list[i]);
+       }
+       free(dispatch->mt.aux_data_list);
+}
+
 static void
 fallback_interface_suspend(struct evdev_dispatch *evdev_dispatch,
                           struct evdev_device *device)
@@ -1363,6 +1379,8 @@ fallback_interface_destroy(struct evdev_dispatch *evdev_dispatch)
        libinput_timer_destroy(&dispatch->debounce.timer);
        libinput_timer_destroy(&dispatch->debounce.timer_short);
 
+       fallback_dispatch_free_aux_data(dispatch);
+
        free(dispatch->mt.slots);
        free(dispatch);
 }
@@ -1590,25 +1608,6 @@ failed:
        }
 }
 
-static void
-fallback_device_interface_free_aux_data(struct evdev_dispatch *evdev_dispatch)
-{
-       int i;
-       struct fallback_dispatch *dispatch;
-       struct mt_aux_data *aux_data, *aux_data_tmp;
-
-       dispatch = fallback_dispatch(evdev_dispatch);
-
-       for (i = 0; i < (int)dispatch->mt.slots_len; i++) {
-               list_for_each_safe(aux_data, aux_data_tmp, &dispatch->mt.aux_data_list[i], link) {
-                       list_remove(&aux_data->link);
-                       free(aux_data);
-               }
-               list_remove(&dispatch->mt.aux_data_list[i]);
-       }
-       free(dispatch->mt.aux_data_list);
-}
-
 struct evdev_dispatch_device_interface fallback_device_interface = {
        .set_aux_data = fallback_device_interface_set_aux_data
 };
index 258cc2495d766978d8c75f8eb0a5a97ba5483b14..760998353fb9ca3f4d5a740806011cc544fe64e5 100644 (file)
@@ -2928,7 +2928,6 @@ evdev_device_destroy(struct evdev_device *device)
        struct evdev_dispatch *dispatch;
 
        dispatch = device->dispatch;
-       evdev_device_free_aux_data(device);
        if (dispatch)
                dispatch->interface->destroy(dispatch);
 
@@ -3013,15 +3012,3 @@ evdev_device_set_aux_data(struct evdev_device *device, uint32_t code)
                dispatch->device_interface->set_aux_data(dispatch, code);
        }
 }
-
-void
-evdev_device_free_aux_data(struct evdev_device *device)
-{
-       struct evdev_dispatch *dispatch = device->dispatch;
-       if (!dispatch) return;
-       if (!dispatch->device_interface) return;
-
-       if (dispatch->device_interface->free_aux_data) {
-               dispatch->device_interface->free_aux_data(dispatch, code);
-       }
-}
index dc596a5bc9c50196b33b2ff129caa91618dd6d12..e19e5a61314f48405f7ed45e6535641ca3534c77 100644 (file)
@@ -355,7 +355,6 @@ struct evdev_dispatch_interface {
 
 struct evdev_dispatch_device_interface {
        void (*set_aux_data) (struct evdev_dispatch *dispatch, uint32_t code);
-       void (*free_aux_data) (struct evdev_dispatch *dispatch);
 };
 
 enum evdev_dispatch_type {
@@ -1054,7 +1053,4 @@ evdev_device_has_aux_data(struct evdev_device *device, uint32_t code);
 
 void
 evdev_device_set_aux_data(struct evdev_device *device, uint32_t code);
-
-void
-evdev_device_free_aux_data(struct evdev_device *device);
 #endif /* EVDEV_H */