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)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 4 Dec 2023 10:24:41 +0000 (19:24 +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 d21928d..c083ca2
@@ -1181,6 +1181,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;
+
+       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)
@@ -1315,6 +1331,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);
 }
@@ -1541,25 +1559,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 b6e5ab48b63d0e7cc348936c0a9fd87073260748..9cdd2eb1254abce5b407f885b082336113ecb0b4 100644 (file)
@@ -3179,7 +3179,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);
 
@@ -3266,15 +3265,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 23ff12c79b35b8685dd32475a0860a4562468e74..519723a47d45a59feab20b9e73c773946c379744 100644 (file)
@@ -356,7 +356,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 {
@@ -1077,7 +1076,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 */