Define a set of cleanup helpers

These are all data structs that are used in libinput and the tests,
let's declare them in a shared header so we can use them everywhere.

For udev and libevdev let's use an ifdef check for a known #define
so we don't have to add those deps everywhere.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184>
This commit is contained in:
Peter Hutterer 2025-04-02 15:24:59 +10:00
parent ae423bc3fe
commit bbbe757a26

View file

@ -43,6 +43,7 @@
#include "util-range.h"
#include "util-prop-parsers.h"
#include "util-time.h"
#include "util-mem.h"
#define VENDOR_ID_APPLE 0x5ac
#define VENDOR_ID_CHICONY 0x4f2
@ -71,4 +72,21 @@
#define LIBINPUT_EXPORT __attribute__ ((visibility("default")))
#define LIBINPUT_UNUSED __attribute__ ((unused))
/* Commonly-used cleanup */
#ifdef udev_list_entry_foreach
DEFINE_UNREF_CLEANUP_FUNC(udev);
DEFINE_UNREF_CLEANUP_FUNC(udev_device);
DEFINE_UNREF_CLEANUP_FUNC(udev_enumerate);
DEFINE_UNREF_CLEANUP_FUNC(udev_monitor);
#endif
#ifdef LIBEVDEV_ATTRIBUTE_PRINTF
DEFINE_FREE_CLEANUP_FUNC(libevdev);
#endif
DEFINE_UNREF_CLEANUP_FUNC(libinput);
DEFINE_UNREF_CLEANUP_FUNC(libinput_device);
DEFINE_UNREF_CLEANUP_FUNC(libinput_tablet_tool);
DEFINE_UNREF_CLEANUP_FUNC(libinput_seat);
DEFINE_DESTROY_CLEANUP_FUNC(libinput_event);
DEFINE_DESTROY_CLEANUP_FUNC(libinput_config_accel);
#endif /* LIBINPUT_UTIL_H */