[PATCH wayland 2/3] wayland-server: Add a wl_resource_for_each macro

Rob Bradford robert.bradford at intel.com
Mon Jul 22 09:30:51 PDT 2013


From: Rob Bradford <rob at linux.intel.com>

This macro allows you to correctly iterate through a list of resources
handling the opaque nature of this type.
---
 src/wayland-server.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/wayland-server.h b/src/wayland-server.h
index 5109530..6dbd68d 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -299,6 +299,11 @@ struct wl_listener *
 wl_resource_get_destroy_listener(struct wl_resource *resource,
 				 wl_notify_func_t notify);
 
+#define wl_resource_for_each(resource, list)					\
+	for (resource = 0, resource = wl_resource_from_link((list)->next);	\
+	     wl_resource_get_link(resource) != (list);				\
+	     resource = wl_resource_from_link(wl_resource_get_link(resource)->next))
+
 struct wl_shm_buffer;
 
 struct wl_shm_buffer *
-- 
1.8.3.1



More information about the wayland-devel mailing list