From: Sebastian Harl Date: Wed, 9 Jul 2014 19:36:49 +0000 (+0200) Subject: object: Added SDB_OBJECT_STATIC. X-Git-Tag: sysdb-0.3.0~62 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=246943645fbba04c41221e485cb80be5a74ed0a3;p=sysdb.git object: Added SDB_OBJECT_STATIC. This is a helper to initialize static, named objects. Replaced SSTRING_OBJ (which was basically the same) used by unit tests. --- diff --git a/src/include/core/object.h b/src/include/core/object.h index a92fb53..b91e9b8 100644 --- a/src/include/core/object.h +++ b/src/include/core/object.h @@ -57,6 +57,10 @@ struct sdb_object { #define SDB_OBJECT_INIT { SDB_TYPE_INIT, 1, NULL } #define SDB_OBJECT_TYPED_INIT(t) { (t), 1, NULL } +#define SDB_OBJECT_STATIC(name) { \ + /* type */ { sizeof(sdb_object_t), NULL, NULL }, \ + /* ref-cnt */ 1, (name) } + typedef struct { sdb_object_t super; void *data; diff --git a/t/unit/libsysdb_test.h b/t/unit/libsysdb_test.h index 861623f..beefdfc 100644 --- a/t/unit/libsysdb_test.h +++ b/t/unit/libsysdb_test.h @@ -36,16 +36,6 @@ #include #include -/* - * private testing helpers - */ - -/* static string object: - * Any such object may is of type sdb_object_t but may never be destroyed. */ -#define SSTRING_OBJ(name) { \ - /* type = */ { sizeof(sdb_object_t), NULL, NULL }, \ - /* ref_cnt = */ 1, /* name = */ (name) } - /* * test-related data-types */ diff --git a/t/unit/utils/avltree_test.c b/t/unit/utils/avltree_test.c index f1ea1fc..0488693 100644 --- a/t/unit/utils/avltree_test.c +++ b/t/unit/utils/avltree_test.c @@ -49,21 +49,21 @@ teardown(void) /* 'a' thru 'o' */ static sdb_object_t test_data[] = { - SSTRING_OBJ("h"), - SSTRING_OBJ("j"), - SSTRING_OBJ("i"), - SSTRING_OBJ("f"), - SSTRING_OBJ("e"), - SSTRING_OBJ("g"), - SSTRING_OBJ("k"), - SSTRING_OBJ("l"), - SSTRING_OBJ("m"), - SSTRING_OBJ("n"), - SSTRING_OBJ("o"), - SSTRING_OBJ("d"), - SSTRING_OBJ("c"), - SSTRING_OBJ("b"), - SSTRING_OBJ("a"), + SDB_OBJECT_STATIC("h"), + SDB_OBJECT_STATIC("j"), + SDB_OBJECT_STATIC("i"), + SDB_OBJECT_STATIC("f"), + SDB_OBJECT_STATIC("e"), + SDB_OBJECT_STATIC("g"), + SDB_OBJECT_STATIC("k"), + SDB_OBJECT_STATIC("l"), + SDB_OBJECT_STATIC("m"), + SDB_OBJECT_STATIC("n"), + SDB_OBJECT_STATIC("o"), + SDB_OBJECT_STATIC("d"), + SDB_OBJECT_STATIC("c"), + SDB_OBJECT_STATIC("b"), + SDB_OBJECT_STATIC("a"), }; static void @@ -76,7 +76,7 @@ populate(void) START_TEST(test_null) { - sdb_object_t o1 = SSTRING_OBJ("obj"); + sdb_object_t o1 = SDB_OBJECT_STATIC("obj"); sdb_object_t *o2; sdb_avltree_iter_t *iter; int check; diff --git a/t/unit/utils/llist_test.c b/t/unit/utils/llist_test.c index 5ae771f..71a6c8c 100644 --- a/t/unit/utils/llist_test.c +++ b/t/unit/utils/llist_test.c @@ -35,13 +35,13 @@ */ static sdb_object_t golden_data[] = { - SSTRING_OBJ("abc"), - SSTRING_OBJ("bcd"), - SSTRING_OBJ("cde"), - SSTRING_OBJ("def"), - SSTRING_OBJ("efg"), - SSTRING_OBJ("fgh"), - SSTRING_OBJ("ghi") + SDB_OBJECT_STATIC("abc"), + SDB_OBJECT_STATIC("bcd"), + SDB_OBJECT_STATIC("cde"), + SDB_OBJECT_STATIC("def"), + SDB_OBJECT_STATIC("efg"), + SDB_OBJECT_STATIC("fgh"), + SDB_OBJECT_STATIC("ghi") }; static char *unused_names[] = {