[PATCH 2/4] Convert wl_resource.link to a wl_slink

alexl at redhat.com alexl at redhat.com
Thu May 23 10:31:22 PDT 2013


From: Alexander Larsson <alexl at redhat.com>

This lets us free up an extra pointer in wl_resource for other use.
---
 src/wayland-server.c | 17 ++++++++++-------
 src/wayland-server.h |  3 ++-
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index a3d3887..f1a6aac 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -86,7 +86,7 @@ struct wl_display {
 	uint32_t id;
 	uint32_t serial;
 
-	struct wl_list registry_resource_list;
+	struct wl_slist registry_resource_list;
 	struct wl_list global_list;
 	struct wl_list socket_list;
 	struct wl_list client_list;
@@ -513,7 +513,10 @@ display_sync(struct wl_client *client,
 static void
 unbind_resource(struct wl_resource *resource)
 {
-	wl_list_remove(&resource->link);
+	struct wl_display *display = resource->data;
+
+	wl_slist_remove(&display->registry_resource_list,
+			&resource->link);
 	free(resource);
 }
 
@@ -530,8 +533,8 @@ display_get_registry(struct wl_client *client,
 				     &registry_interface, id, display);
 	registry_resource->destroy = unbind_resource;
 
-	wl_list_insert(&display->registry_resource_list,
-		       &registry_resource->link);
+	wl_slist_insert(&display->registry_resource_list,
+			&registry_resource->link);
 
 	wl_list_for_each(global, &display->global_list, link)
 		wl_resource_post_event(registry_resource,
@@ -590,7 +593,7 @@ wl_display_create(void)
 	wl_list_init(&display->global_list);
 	wl_list_init(&display->socket_list);
 	wl_list_init(&display->client_list);
-	wl_list_init(&display->registry_resource_list);
+	wl_slist_init(&display->registry_resource_list);
 
 	wl_signal_init(&display->destroy_signal);
 
@@ -649,7 +652,7 @@ wl_display_add_global(struct wl_display *display,
 	global->bind = bind;
 	wl_list_insert(display->global_list.prev, &global->link);
 
-	wl_list_for_each(resource, &display->registry_resource_list, link)
+	wl_slist_for_each(resource, &display->registry_resource_list, link)
 		wl_resource_post_event(resource,
 				       WL_REGISTRY_GLOBAL,
 				       global->name,
@@ -664,7 +667,7 @@ wl_display_remove_global(struct wl_display *display, struct wl_global *global)
 {
 	struct wl_resource *resource;
 
-	wl_list_for_each(resource, &display->registry_resource_list, link)
+	wl_slist_for_each(resource, &display->registry_resource_list, link)
 		wl_resource_post_event(resource, WL_REGISTRY_GLOBAL_REMOVE,
 				       global->name);
 	wl_list_remove(&global->link);
diff --git a/src/wayland-server.h b/src/wayland-server.h
index a9cf544..4867652 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -180,7 +180,8 @@ wl_signal_emit(struct wl_signal *signal, void *data)
 struct wl_resource {
 	struct wl_object object;
 	void (*destroy)(struct wl_resource *resource);
-	struct wl_list link;
+	struct wl_slist link;
+	void *reserved;
 	struct wl_signal destroy_signal;
 	struct wl_client *client;
 	void *data;
-- 
1.8.1.4



More information about the wayland-devel mailing list