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>
Tue, 4 Feb 2025 09:32:08 +0000 (18:32 +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 83f95f0..d71ae3c
@@ -1189,6 +1189,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)
@@ -1329,6 +1345,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);
 }
@@ -1555,25 +1573,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 8f8116963a4a9f8fa3788a13b2363ad32a539091..e9dfed869b7f568b7f01a32d7c3f955d53843d82 100644 (file)
@@ -3187,7 +3187,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);
 
@@ -3226,15 +3225,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 3aeae5be430b2f020cd2f4fad02f7d5258b1b831..396d5b3c6717c2bc29aef003555ff4f3c623d8c2 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 {
@@ -1074,7 +1073,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 */