private: Fix memory leak in tests

Don't use g_private_new(), it's deprecated, and leaks by definition.

https://bugzilla.gnome.org/show_bug.cgi?id=711751
This commit is contained in:
Stef Walter 2013-10-31 14:41:34 +01:00
parent ae6dbb35cb
commit e74b4351a3

View File

@ -32,20 +32,18 @@
static void
test_private1 (void)
{
GPrivate *private1;
static GPrivate private = G_PRIVATE_INIT (NULL);
gpointer value;
private1 = g_private_new (NULL);
value = g_private_get (private1);
value = g_private_get (&private);
g_assert (value == NULL);
g_private_set (private1, GINT_TO_POINTER(1));
value = g_private_get (private1);
g_private_set (&private, GINT_TO_POINTER(1));
value = g_private_get (&private);
g_assert_cmpint (GPOINTER_TO_INT (value), ==, 1);
g_private_set (private1, GINT_TO_POINTER(2));
value = g_private_get (private1);
g_private_set (&private, GINT_TO_POINTER(2));
value = g_private_get (&private);
g_assert_cmpint (GPOINTER_TO_INT (value), ==, 2);
}