From 935e7ed6b558638e2ede402febdb7c82930cc1b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 30 Nov 2015 09:01:16 -0500 Subject: [PATCH] Add internal bt_object reference count accessor MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This accessor is added to facilitate the testing and validation of the bt_object reference counting and aggregation mechanism. Signed-off-by: Jérémie Galarneau --- include/babeltrace/object-internal.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/babeltrace/object-internal.h b/include/babeltrace/object-internal.h index 0b0fd0f7..747950f7 100644 --- a/include/babeltrace/object-internal.h +++ b/include/babeltrace/object-internal.h @@ -102,7 +102,16 @@ void bt_object_init(void *ptr, bt_object_release_func release) struct bt_object *obj = ptr; obj->release = release; + obj->parent = NULL; bt_ref_init(&obj->ref_count, generic_release); } +static inline +long bt_object_get_ref_count(const void *ptr) +{ + const struct bt_object *obj = ptr; + + return obj->ref_count.count; +} + #endif /* BABELTRACE_OBJECT_INTERNAL_H */ -- 2.34.1