list_insert(&libinput->seat_list, &seat->link);
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_seat *
libinput_seat_ref(struct libinput_seat *seat)
{
seat->refcount++;
+ return seat;
}
static void
seat->destroy(seat);
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_seat *
libinput_seat_unref(struct libinput_seat *seat)
{
assert(seat->refcount > 0);
seat->refcount--;
- if (seat->refcount == 0)
+ if (seat->refcount == 0) {
libinput_seat_destroy(seat);
+ return NULL;
+ } else {
+ return seat;
+ }
}
LIBINPUT_EXPORT void
device->refcount = 1;
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_device *
libinput_device_ref(struct libinput_device *device)
{
device->refcount++;
+ return device;
}
static void
evdev_device_destroy((struct evdev_device *) device);
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_device *
libinput_device_unref(struct libinput_device *device)
{
assert(device->refcount > 0);
device->refcount--;
- if (device->refcount == 0)
+ if (device->refcount == 0) {
libinput_device_destroy(device);
+ return NULL;
+ } else {
+ return device;
+ }
}
LIBINPUT_EXPORT int
* the seat correctly to avoid dangling pointers.
*
* @param seat A previously obtained seat
+ * @return The passed seat
*/
-void
+struct libinput_seat *
libinput_seat_ref(struct libinput_seat *seat);
/**
* the seat correctly to avoid dangling pointers.
*
* @param seat A previously obtained seat
+ * @return NULL if seat was destroyed, otherwise the passed seat
*/
-void
+struct libinput_seat *
libinput_seat_unref(struct libinput_seat *seat);
/**
* the device correctly to avoid dangling pointers.
*
* @param device A previously obtained device
+ * @return The passed device
*/
-void
+struct libinput_device *
libinput_device_ref(struct libinput_device *device);
/**
* the device correctly to avoid dangling pointers.
*
* @param device A previously obtained device
+ * @return NULL if device was destroyed, otherwise the passed device
*/
-void
+struct libinput_device *
libinput_device_unref(struct libinput_device *device);
/**