mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-25 11:42:10 +01:00
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:
parent
ae6dbb35cb
commit
e74b4351a3
@ -32,20 +32,18 @@
|
|||||||
static void
|
static void
|
||||||
test_private1 (void)
|
test_private1 (void)
|
||||||
{
|
{
|
||||||
GPrivate *private1;
|
static GPrivate private = G_PRIVATE_INIT (NULL);
|
||||||
gpointer value;
|
gpointer value;
|
||||||
|
|
||||||
private1 = g_private_new (NULL);
|
value = g_private_get (&private);
|
||||||
|
|
||||||
value = g_private_get (private1);
|
|
||||||
g_assert (value == NULL);
|
g_assert (value == NULL);
|
||||||
|
|
||||||
g_private_set (private1, GINT_TO_POINTER(1));
|
g_private_set (&private, GINT_TO_POINTER(1));
|
||||||
value = g_private_get (private1);
|
value = g_private_get (&private);
|
||||||
g_assert_cmpint (GPOINTER_TO_INT (value), ==, 1);
|
g_assert_cmpint (GPOINTER_TO_INT (value), ==, 1);
|
||||||
|
|
||||||
g_private_set (private1, GINT_TO_POINTER(2));
|
g_private_set (&private, GINT_TO_POINTER(2));
|
||||||
value = g_private_get (private1);
|
value = g_private_get (&private);
|
||||||
g_assert_cmpint (GPOINTER_TO_INT (value), ==, 2);
|
g_assert_cmpint (GPOINTER_TO_INT (value), ==, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user