mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 17:08:07 +02:00
path: add helper function to destroy a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
36284defd0
commit
451cbce44f
1 changed files with 13 additions and 12 deletions
|
|
@ -232,6 +232,14 @@ path_input_enable(struct libinput *libinput)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
path_device_destroy(struct path_device *dev)
|
||||||
|
{
|
||||||
|
list_remove(&dev->link);
|
||||||
|
udev_device_unref(dev->udev_device);
|
||||||
|
free(dev);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
path_input_destroy(struct libinput *input)
|
path_input_destroy(struct libinput *input)
|
||||||
{
|
{
|
||||||
|
|
@ -240,10 +248,8 @@ path_input_destroy(struct libinput *input)
|
||||||
|
|
||||||
udev_unref(path_input->udev);
|
udev_unref(path_input->udev);
|
||||||
|
|
||||||
list_for_each_safe(dev, tmp, &path_input->path_list, link) {
|
list_for_each_safe(dev, tmp, &path_input->path_list, link)
|
||||||
udev_device_unref(dev->udev_device);
|
path_device_destroy(dev);
|
||||||
free(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -263,11 +269,8 @@ path_create_device(struct libinput *libinput,
|
||||||
|
|
||||||
device = path_device_enable(input, udev_device, seat_name);
|
device = path_device_enable(input, udev_device, seat_name);
|
||||||
|
|
||||||
if (!device) {
|
if (!device)
|
||||||
udev_device_unref(dev->udev_device);
|
path_device_destroy(dev);
|
||||||
list_remove(&dev->link);
|
|
||||||
free(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
@ -416,9 +419,7 @@ libinput_path_remove_device(struct libinput_device *device)
|
||||||
|
|
||||||
list_for_each(dev, &input->path_list, link) {
|
list_for_each(dev, &input->path_list, link) {
|
||||||
if (dev->udev_device == evdev->udev_device) {
|
if (dev->udev_device == evdev->udev_device) {
|
||||||
list_remove(&dev->link);
|
path_device_destroy(dev);
|
||||||
udev_device_unref(dev->udev_device);
|
|
||||||
free(dev);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue