pipewire: core: static assert member order requirement

The pw_proxy member of pw_core must be the first because the
pw_core object is freed via pw_proxy_destroy() -> pw_proxy_unref().
This commit is contained in:
Barnabás Pőcze 2023-06-26 15:19:43 +02:00
parent 4bec3b56d4
commit 0e823d8a0f

View file

@ -476,6 +476,12 @@ struct pw_mempool * pw_core_get_mempool(struct pw_core *core)
SPA_EXPORT
int pw_core_disconnect(struct pw_core *core)
{
/*
* the `proxy` member must be the first because the whole pw_core object is
* freed via the free() call in pw_proxy_destroy() -> pw_proxy_unref()
*/
SPA_STATIC_ASSERT(offsetof(struct pw_core, proxy) == 0, "`proxy` member must be first");
pw_log_debug("%p: disconnect", core);
if (!core->removed)
pw_proxy_remove(&core->proxy);