<div dir="ltr"><div>---<br><br></div>Here's the full patch with those changes applied. This uses \comment{} as well, so it's dependent on that patch.<br><div><br> src/wayland-util.h | 35 +++++++++++++++++++++++++++++++++++<br>
1 file changed, 35 insertions(+)<br>
<br>diff --git a/src/wayland-util.h b/src/wayland-util.h<br>index aa74512..68d91e2 100644<br>
--- a/src/wayland-util.h<br>+++ b/src/wayland-util.h<br>@@ -116,6 +116,41 @@ int wl_list_length(const struct wl_list *list);<br> int wl_list_empty(const struct wl_list *list);<br> void wl_list_insert_list(struct wl_list *list, struct wl_list *other);<br>
<br>+/**<br>+ * Retrieves a pointer to the containing struct of a given member item.<br>+ *<br>+ * This macro allows conversion from a pointer to a item to its containing<br>+ * struct. This is useful if you have a contained item like a wl_list,<br>
+ * wl_listener, or wl_signal, provided via a callback or other means and would<br>+ * like to retrieve the struct that contains it.<br>+ *<br>+ * To demonstrate, the following example retrieves a pointer to<br>+ * `example_container` given only its `destroy_listener` member:<br>
+ *<br>+ * ~~~<br>+ * struct example_container {<br>+ * struct wl_listener destroy_listener;<br>+ * \comment{other members...}<br>+ * };<br>+ *<br>+ * void example_container_destroy(struct wl_listener *listener, void *data)<br>
+ * {<br>+ * struct example_container *ctr = NULL;<br>+ *<br>+ * ctr = wl_container_of(listener, ctr, destroy_listener);<br>+ * \comment{destroy ctr...}<br>+ * }<br>+ * ~~~<br>+ *<br>+ * \param ptr A valid pointer to the contained item.<br>
+ *<br>+ * \param sample A pointer to the type of content that the list item stores.<br>+ * Sample does not need be a valid pointer; a null pointer will suffice.<br>+ *<br>+ * \param member The named location of ptr within the sample type.<br>
+ *<br>+ * \return The container for the specified pointer.<br>+ */<br> #ifdef __GNUC__<br> #define wl_container_of(ptr, sample, member) \<br> (__typeof__(sample))((char *)(ptr) - \<br>
</div></div>