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)
committerduna.oh <duna.oh@samsung.com>
Fri, 27 Jan 2023 05:45:20 +0000 (14:45 +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 381323a..f0abc4e
@@ -1175,6 +1175,22 @@ fallback_return_to_neutral_state(struct fallback_dispatch *dispatch,
 }
 
 static void
+fallback_dispatch_free_aux_data(struct fallback_dispatch *dispatch)
+{
+       int i;
+       struct mt_aux_data *aux_data;
+
+       for (i = 0; i < (int)dispatch->mt.slots_len; i++) {
+               list_for_each_safe(aux_data, &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)
 {
@@ -1308,6 +1324,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);
 }
@@ -1534,25 +1552,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;
-
-       dispatch = fallback_dispatch(evdev_dispatch);
-
-       for (i = 0; i < (int)dispatch->mt.slots_len; i++) {
-               list_for_each_safe(aux_data, &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 9bd4d62..32602ff 100644 (file)
@@ -3183,7 +3183,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);
 
@@ -3270,15 +3269,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 668e7f7..9053957 100644 (file)
@@ -357,7 +357,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 {
@@ -1078,7 +1077,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 */