Commit 264bde1b authored by Pekka Pessi's avatar Pekka Pessi

su_alloc.c: allow reference counting on home objects initialized statically or with su_home_init().

Note that an assertion fails if su_home_deinit() or su_home_destroy() is
passed a home object that has reference count more than 1.

darcs-hash:20070202180709-65a35-8810986f9572370a333dbd0c3bbadd23e9914477.gz
parent 387a895a
This diff is collapsed.
......@@ -161,9 +161,35 @@ static int test_alloc(void)
su_home_check(h0->home);
su_home_zap(h0->home);
{
su_home_t h1[1];
void test_destructor(void *);
memset(h1, 0, sizeof h1);
TEST(su_home_init(h1), 0);
TEST(su_home_threadsafe(h1), 0);
TEST_1(su_home_ref(h1));
TEST_1(su_home_ref(h1));
TEST(su_home_destructor(h1, test_destructor), 0);
TEST_1(!su_home_unref(h1));
TEST_1(!su_home_unref(h1));
TEST_1(su_home_unref(h1));
TEST(h1->suh_size, 13);
}
END();
}
void test_destructor(void *a)
{
su_home_t *h = a;
h->suh_size = 13;
}
static int test_strdupcat(void)
{
su_home_t home[1] = { SU_HOME_INIT(home) };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment