mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-06 07:06:10 +00:00
xrt: Introduce xrt_comp_fd_destroy to avoid some error prone casting
This commit is contained in:
parent
b60219445a
commit
077087bb15
|
@ -31,7 +31,7 @@ client_egl_compositor_destroy(struct xrt_compositor *xc)
|
||||||
{
|
{
|
||||||
struct client_gl_compositor *c = client_gl_compositor(xc);
|
struct client_gl_compositor *c = client_gl_compositor(xc);
|
||||||
// Pipe down call into fd compositor.
|
// Pipe down call into fd compositor.
|
||||||
xrt_comp_destroy((struct xrt_compositor **)c->xcfd);
|
xrt_comp_fd_destroy(&c->xcfd);
|
||||||
free(c);
|
free(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ client_gl_xlib_compositor_destroy(struct xrt_compositor *xc)
|
||||||
{
|
{
|
||||||
struct client_gl_xlib_compositor *c = client_gl_xlib_compositor(xc);
|
struct client_gl_xlib_compositor *c = client_gl_xlib_compositor(xc);
|
||||||
// Pipe down call into fd compositor.
|
// Pipe down call into fd compositor.
|
||||||
xrt_comp_destroy((struct xrt_compositor **)c->base.xcfd);
|
xrt_comp_fd_destroy(&c->base.xcfd);
|
||||||
free(c);
|
free(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ client_vk_compositor_destroy(struct xrt_compositor *xc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pipe down call into fd compositor.
|
// Pipe down call into fd compositor.
|
||||||
xrt_comp_destroy((struct xrt_compositor **)&c->xcfd);
|
xrt_comp_fd_destroy(&c->xcfd);
|
||||||
free(c);
|
free(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -777,6 +777,27 @@ xrt_comp_fd_create_swapchain(struct xrt_compositor_fd *xcfd,
|
||||||
return (struct xrt_swapchain_fd *)xsc;
|
return (struct xrt_swapchain_fd *)xsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @copydoc xrt_compositor::destroy
|
||||||
|
*
|
||||||
|
* Helper for calling through the function pointer: does a null check and sets
|
||||||
|
* xcfd_ptr to null if freed.
|
||||||
|
*
|
||||||
|
* @public @memberof xrt_compositor_fd
|
||||||
|
*/
|
||||||
|
static inline void
|
||||||
|
xrt_comp_fd_destroy(struct xrt_compositor_fd **xcfd_ptr)
|
||||||
|
{
|
||||||
|
struct xrt_compositor_fd *xcfd = *xcfd_ptr;
|
||||||
|
if (xcfd == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcfd->base.destroy(&xcfd->base);
|
||||||
|
*xcfd_ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue