[PATCH weston] Clients: Fix memleak issues in various clients of weston

vivek vivek.ellur at samsung.com
Thu May 15 06:28:16 PDT 2014


In many clients of weston, Display was not being destroyed so added it.
Also destroy windows, widgets which were not being destroyed.

Signed-off-by: vivek <vivek.ellur at samsung.com>
---
 clients/cliptest.c    |   13 ++++++++++---
 clients/dnd.c         |   11 +++++++++++
 clients/editor.c      |    3 +++
 clients/flower.c      |    4 ++++
 clients/fullscreen.c  |    4 ++++
 clients/gears.c       |   14 +++++++++++++-
 clients/image.c       |    2 ++
 clients/scaler.c      |    3 +++
 clients/smoke.c       |    4 ++++
 clients/stacking.c    |    3 +++
 clients/transformed.c |    3 +++
 11 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/clients/cliptest.c b/clients/cliptest.c
index 3cee343..a1928f4 100644
--- a/clients/cliptest.c
+++ b/clients/cliptest.c
@@ -879,6 +879,14 @@ benchmark(void)
 	return 0;
 }
 
+static void
+cliptest_destroy(struct cliptest *cliptest)
+{
+	widget_destroy(cliptest->widget);
+	window_destroy(cliptest->window);
+	free(cliptest);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -897,9 +905,8 @@ main(int argc, char *argv[])
 	cliptest = cliptest_create(d);
 	display_run(d);
 
-	widget_destroy(cliptest->widget);
-	window_destroy(cliptest->window);
-	free(cliptest);
+	cliptest_destroy(cliptest);
+	display_destroy(d);
 
 	return 0;
 }
diff --git a/clients/dnd.c b/clients/dnd.c
index a463d6f..620cfff 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -639,6 +639,14 @@ dnd_create(struct display *display)
 	return dnd;
 }
 
+static void
+dnd_destroy(struct dnd *dnd)
+{
+	widget_destroy(dnd->widget);
+	window_destroy(dnd->window);
+	free(dnd);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -660,5 +668,8 @@ main(int argc, char *argv[])
 
 	display_run(d);
 
+	dnd_destroy(dnd);
+	display_destroy(d);
+
 	return 0;
 }
diff --git a/clients/editor.c b/clients/editor.c
index f3f6141..08d1203 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -1382,6 +1382,9 @@ main(int argc, char *argv[])
 
 	text_entry_destroy(editor.entry);
 	text_entry_destroy(editor.editor);
+	widget_destroy(editor.widget);
+	window_destroy(editor.window);
+	display_destroy(editor.display);
 
 	return 0;
 }
diff --git a/clients/flower.c b/clients/flower.c
index 8769445..624525c 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -195,5 +195,9 @@ int main(int argc, char *argv[])
 
 	display_run(d);
 
+	widget_destroy(flower.widget);
+	window_destroy(flower.window);
+	display_destroy(d);
+
 	return 0;
 }
diff --git a/clients/fullscreen.c b/clients/fullscreen.c
index 28efb15..5c5dd2b 100644
--- a/clients/fullscreen.c
+++ b/clients/fullscreen.c
@@ -562,5 +562,9 @@ int main(int argc, char *argv[])
 
 	display_run(d);
 
+	widget_destroy(fullscreen.widget);
+	window_destroy(fullscreen.window);
+	display_destroy(d);
+
 	return 0;
 }
diff --git a/clients/gears.c b/clients/gears.c
index 93a86b4..95f0bb2 100644
--- a/clients/gears.c
+++ b/clients/gears.c
@@ -469,17 +469,29 @@ gears_create(struct display *display)
 	return gears;
 }
 
+static void
+gears_destroy(struct gears *gears)
+{
+	widget_destroy(gears->widget);
+	window_destroy(gears->window);
+	free(gears);
+}
+
 int main(int argc, char *argv[])
 {
 	struct display *d;
+	struct gears *gears;
 
 	d = display_create(&argc, argv);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
 	}
-	gears_create(d);
+	gears = gears_create(d);
 	display_run(d);
 
+	gears_destroy(gears);
+	display_destroy(d);
+
 	return 0;
 }
diff --git a/clients/image.c b/clients/image.c
index 054979d..112b93d 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -424,5 +424,7 @@ main(int argc, char *argv[])
 	if (image_counter > 0)
 		display_run(d);
 
+	display_destroy(d);
+
 	return 0;
 }
diff --git a/clients/scaler.c b/clients/scaler.c
index f94e714..3939022 100644
--- a/clients/scaler.c
+++ b/clients/scaler.c
@@ -321,6 +321,9 @@ main(int argc, char *argv[])
 
 	display_run(d);
 
+	widget_destroy(box.widget);
 	window_destroy(box.window);
+	display_destroy(d);
+
 	return 0;
 }
diff --git a/clients/smoke.c b/clients/smoke.c
index 5d976af..65b6e03 100644
--- a/clients/smoke.c
+++ b/clients/smoke.c
@@ -329,5 +329,9 @@ int main(int argc, char *argv[])
 
 	display_run(d);
 
+	widget_destroy(smoke.widget);
+	window_destroy(smoke.window);
+	display_destroy(d);
+
 	return 0;
 }
diff --git a/clients/stacking.c b/clients/stacking.c
index f51a476..5aaf469 100644
--- a/clients/stacking.c
+++ b/clients/stacking.c
@@ -304,5 +304,8 @@ main(int argc, char *argv[])
 
 	display_run(stacking.display);
 
+	window_destroy(stacking.root_window);
+	display_destroy(stacking.display);
+
 	return 0;
 }
diff --git a/clients/transformed.c b/clients/transformed.c
index 4b1cb05..880a0a9 100644
--- a/clients/transformed.c
+++ b/clients/transformed.c
@@ -290,6 +290,9 @@ int main(int argc, char *argv[])
 			       transformed.width, transformed.height);
 
 	display_run(d);
+	widget_destroy(transformed.widget);
+	window_destroy(transformed.window);
+	display_destroy(d);
 
 	return 0;
 }
-- 
1.7.9.5



More information about the wayland-devel mailing list