Remove g_mutex_new()/g_cond_new() in testcases

These were the last users of the dynamic allocation API.

Keep the uses in glib/tests/mutex.c since this is actually meant to test
the API (which has to continue working, even if it is deprecated).

https://bugzilla.gnome.org/show_bug.cgi?id=660739
This commit is contained in:
Ryan Lortie
2011-10-04 19:04:41 -04:00
parent 9793708931
commit 6f343ca548
10 changed files with 97 additions and 115 deletions

View File

@@ -5,7 +5,7 @@
/* GMutex */
static GMutex* test_g_mutex_mutex = NULL;
static GMutex test_g_mutex_mutex;
static guint test_g_mutex_int = 0;
static gboolean test_g_mutex_thread_ready;
G_LOCK_DEFINE_STATIC (test_g_mutex);
@@ -14,12 +14,12 @@ static gpointer
test_g_mutex_thread (gpointer data)
{
g_assert (GPOINTER_TO_INT (data) == 42);
g_assert (g_mutex_trylock (test_g_mutex_mutex) == FALSE);
g_assert (g_mutex_trylock (&test_g_mutex_mutex) == FALSE);
g_assert (G_TRYLOCK (test_g_mutex) == FALSE);
test_g_mutex_thread_ready = TRUE;
g_mutex_lock (test_g_mutex_mutex);
g_mutex_lock (&test_g_mutex_mutex);
g_assert (test_g_mutex_int == 42);
g_mutex_unlock (test_g_mutex_mutex);
g_mutex_unlock (&test_g_mutex_mutex);
return GINT_TO_POINTER (41);
}
@@ -28,9 +28,8 @@ static void
test_g_mutex (void)
{
GThread *thread;
test_g_mutex_mutex = g_mutex_new ();
g_assert (g_mutex_trylock (test_g_mutex_mutex));
g_assert (g_mutex_trylock (&test_g_mutex_mutex));
g_assert (G_TRYLOCK (test_g_mutex));
test_g_mutex_thread_ready = FALSE;
thread = g_thread_create (test_g_mutex_thread, GINT_TO_POINTER (42),
@@ -41,9 +40,8 @@ test_g_mutex (void)
g_usleep (G_USEC_PER_SEC / 5);
test_g_mutex_int = 42;
G_UNLOCK (test_g_mutex);
g_mutex_unlock (test_g_mutex_mutex);
g_mutex_unlock (&test_g_mutex_mutex);
g_assert (GPOINTER_TO_INT (g_thread_join (thread)) == 41);
g_mutex_free (test_g_mutex_mutex);
}
/* GStaticRecMutex */