diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2012-06-01 02:54:46 -0400 |
---|---|---|
committer | Martin Pitt <martinpitt@gnome.org> | 2012-06-01 15:46:37 +0200 |
commit | bb83f34bebdd3581a01f521f8e6fda5a724ae0de (patch) | |
tree | 75f5cb68b3d6fda8953896f7366c453c0308ffd4 /tests/scanner/regress.c | |
parent | 932bf2a700368e46b30b58ec9b6beb3ff09a081c (diff) | |
download | gobject-introspection-bb83f34bebdd3581a01f521f8e6fda5a724ae0de.tar.gz |
tests: Add a refcounting boxed
https://bugzilla.gnome.org/show_bug.cgi?id=677249
Diffstat (limited to 'tests/scanner/regress.c')
-rw-r--r-- | tests/scanner/regress.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index ca8d6ef8..13b18887 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1825,6 +1825,38 @@ G_DEFINE_BOXED_TYPE(RegressTestBoxedB, regress_test_boxed_b_copy, regress_test_boxed_b_free); +RegressTestBoxedC * +regress_test_boxed_c_new (void) +{ + RegressTestBoxedC *boxed; + + boxed = g_slice_new (RegressTestBoxedC); + boxed->refcount = 1; + boxed->another_thing = 42; /* what else */ + + return boxed; +} + +static RegressTestBoxedC * +regress_test_boxed_c_ref (RegressTestBoxedC *boxed) +{ + g_atomic_int_inc (&boxed->refcount); + return boxed; +} + +static void +regress_test_boxed_c_unref (RegressTestBoxedC *boxed) +{ + if (g_atomic_int_dec_and_test (&boxed->refcount)) { + g_slice_free (RegressTestBoxedC, boxed); + } +} + +G_DEFINE_BOXED_TYPE(RegressTestBoxedC, + regress_test_boxed_c, + regress_test_boxed_c_ref, + regress_test_boxed_c_unref); + G_DEFINE_TYPE(RegressTestObj, regress_test_obj, G_TYPE_OBJECT); enum |