[PATCH] Do not leak globals and listeners.

Laszlo Agocs laszlo.p.agocs at nokia.com
Tue Jun 14 02:41:54 PDT 2011


 From 3fa2ad7dec42f85795449f33b2a4c9461aa4924d Mon Sep 17 00:00:00 2001
From: Laszlo Agocs <laszlo.p.agocs at nokia.com>
Date: Tue, 14 Jun 2011 11:35:28 +0200
Subject: [PATCH] Do not leak globals and listeners.

---
  wayland/wayland-client.c |    8 ++++++++
  wayland/wayland-server.c |    4 ++++
  2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index b17e790..26acff7 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -428,8 +428,16 @@ wl_display_connect(const char *name)
  WL_EXPORT void
  wl_display_destroy(struct wl_display *display)
  {
+	struct wl_global *global, *gnext;
+	struct wl_global_listener *listener, *lnext;
  	wl_connection_destroy(display->connection);
  	wl_hash_table_destroy(display->objects);
+	wl_list_for_each_safe(global, gnext,
+			      &display->global_list, link)
+		free(global);
+	wl_list_for_each_safe(listener, lnext,
+			      &display->global_listener_list, link)
+		free(listener);
  	close(display->fd);
  	free(display);
  }
diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index e5006e1..384b8e6 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -623,6 +623,7 @@ WL_EXPORT void
  wl_display_destroy(struct wl_display *display)
  {
  	struct wl_socket *s, *next;
+	struct wl_global *global, *gnext;

  	wl_event_loop_destroy(display->loop);
  	wl_hash_table_destroy(display->objects);
@@ -635,6 +636,9 @@ wl_display_destroy(struct wl_display *display)
  		free(s);
  	}

+	wl_list_for_each_safe(global, gnext, &display->global_list, link)
+		free(global);
+
  	free(display);
  }

-- 
1.7.1



More information about the wayland-devel mailing list