wl_container_of

Retrieves a pointer to the containing struct of a given member item.

This macro allows conversion from a pointer to a item to its containing struct. This is useful if you have a contained item like a wl_list, wl_listener, or wl_signal, provided via a callback or other means and would like to retrieve the struct that contains it.

To demonstrate, the following example retrieves a pointer to example_container given only its destroy_listener member:

\code struct example_container { struct wl_listener destroy_listener; // other members... };

void example_container_destroy(struct wl_listener *listener, void *data) { struct example_container *ctr;

ctr = wl_container_of(listener, ctr, destroy_listener); // destroy ctr... } \endcode

\param ptr A valid pointer to the contained item.

\param sample A pointer to the type of content that the list item stores. Sample does not need be a valid pointer; a null or an uninitialised pointer will suffice.

\param member The named location of ptr within the sample type.

\return The container for the specified pointer.

template wl_container_of(alias member)
static
ParentOf!member*
wl_container_of
(
T
)
(
T* ptr
)

Members

Static functions

wl_container_of
ParentOf!member* wl_container_of(T* ptr)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta