[glib] threadtests: Fix leaks in tests



commit 5339950e2519933912fe5e3374caf721ad790220
Author: Stef Walter <stefw gnome org>
Date:   Thu Nov 7 22:57:27 2013 +0100

    threadtests: Fix leaks in tests
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711779

 gobject/tests/threadtests.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gobject/tests/threadtests.c b/gobject/tests/threadtests.c
index 37b6b70..e075c57 100644
--- a/gobject/tests/threadtests.c
+++ b/gobject/tests/threadtests.c
@@ -117,18 +117,15 @@ tester_init_thread (gpointer data)
 static void
 test_threaded_class_init (void)
 {
-  GThread *thread;
+  GThread *t1, *t2, *t3;
 
   /* pause newly created threads */
   g_mutex_lock (&sync_mutex);
 
   /* create threads */
-  thread = g_thread_create (tester_init_thread, (gpointer) my_tester0_get_type(), TRUE, NULL);
-  g_thread_unref (thread);
-  thread = g_thread_create (tester_init_thread, (gpointer) my_tester1_get_type(), TRUE, NULL);
-  g_thread_unref (thread);
-  thread = g_thread_create (tester_init_thread, (gpointer) my_tester2_get_type(), TRUE, NULL);
-  g_thread_unref (thread);
+  t1 = g_thread_create (tester_init_thread, (gpointer) my_tester0_get_type(), TRUE, NULL);
+  t2 = g_thread_create (tester_init_thread, (gpointer) my_tester1_get_type(), TRUE, NULL);
+  t3 = g_thread_create (tester_init_thread, (gpointer) my_tester2_get_type(), TRUE, NULL);
 
   /* execute threads */
   g_mutex_unlock (&sync_mutex);
@@ -142,6 +139,10 @@ test_threaded_class_init (void)
     g_print ("Total initializers: %u\n", g_atomic_int_get (&mtsafe_call_counter));
   /* ensure non-corrupted counter updates */
   g_assert_cmpint (g_atomic_int_get (&mtsafe_call_counter), ==, unsafe_call_counter);
+
+  g_thread_join (t1);
+  g_thread_join (t2);
+  g_thread_join (t3);
 }
 #endif
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]