mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
server: add wl_global_set_user_data
When implementing a workaround for [1], one needs to accept a global to be bound even though it has become stale. Often, a global's user data is free'd when the global needs to be destroyed. Being able to set the global's user data (e.g. to NULL) can help preventing a use-after-free. (The alternative is to make the compositor responsible for keeping track of stale user data objects via e.g. refcounting.) [1]: https://gitlab.freedesktop.org/wayland/wayland/issues/10 Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
parent
766edf0243
commit
d5055ad913
2 changed files with 16 additions and 0 deletions
|
|
@ -279,6 +279,9 @@ wl_global_get_interface(const struct wl_global *global);
|
|||
void *
|
||||
wl_global_get_user_data(const struct wl_global *global);
|
||||
|
||||
void
|
||||
wl_global_set_user_data(struct wl_global *global, void *data);
|
||||
|
||||
struct wl_client *
|
||||
wl_client_create(struct wl_display *display, int fd);
|
||||
|
||||
|
|
|
|||
|
|
@ -1245,6 +1245,19 @@ wl_global_get_user_data(const struct wl_global *global)
|
|||
return global->data;
|
||||
}
|
||||
|
||||
/** Set the global's user data
|
||||
*
|
||||
* \param global The global object
|
||||
* \param data The user data pointer
|
||||
*
|
||||
* \since 1.17.90
|
||||
*/
|
||||
WL_EXPORT void
|
||||
wl_global_set_user_data(struct wl_global *global, void *data)
|
||||
{
|
||||
global->data = data;
|
||||
}
|
||||
|
||||
/** Get the current serial number
|
||||
*
|
||||
* \param display The display object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue