projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove Babeltrace 1 files and reorganize the tree
[babeltrace.git]
/
include
/
babeltrace
/
object-internal.h
diff --git
a/include/babeltrace/object-internal.h
b/include/babeltrace/object-internal.h
index 0b0fd0f7075d523a13a83ae6ffa257c4b774dba4..e130a81e883d620cba525cffc28a4ffba2f90fcd 100644
(file)
--- a/
include/babeltrace/object-internal.h
+++ b/
include/babeltrace/object-internal.h
@@
-33,7
+33,7
@@
/**
* All objects publicly exposed by Babeltrace APIs must contain this structure
* as their first member. This allows the unification of all ref counting
/**
* All objects publicly exposed by Babeltrace APIs must contain this structure
* as their first member. This allows the unification of all ref counting
- * mechanism and may be used to provide more base functionality to all
+ * mechanism
s
and may be used to provide more base functionality to all
* objects.
*/
struct bt_object {
* objects.
*/
struct bt_object {
@@
-45,11
+45,14
@@
struct bt_object {
};
static inline
};
static inline
-long bt_object_get_ref_count(const void *);
-static inline
-void bt_object_set_parent(void *, void *);
+long bt_object_get_ref_count(const void *ptr)
+{
+ const struct bt_object *obj = ptr;
+
+ return obj->ref_count.count;
+}
-static
+static
inline
void bt_object_release(void *ptr)
{
struct bt_object *obj = ptr;
void bt_object_release(void *ptr)
{
struct bt_object *obj = ptr;
@@
-59,7
+62,7
@@
void bt_object_release(void *ptr)
}
}
}
}
-static
+static
inline
void generic_release(struct bt_object *obj)
{
if (obj->parent) {
void generic_release(struct bt_object *obj)
{
if (obj->parent) {
@@
-71,11
+74,17
@@
void generic_release(struct bt_object *obj)
}
static inline
}
static inline
-struct bt_object *bt_object_
get
_parent(void *ptr)
+struct bt_object *bt_object_
borrow
_parent(void *ptr)
{
struct bt_object *obj = ptr;
{
struct bt_object *obj = ptr;
- return ptr ? bt_get(obj->parent) : NULL;
+ return obj ? obj->parent : NULL;
+}
+
+static inline
+struct bt_object *bt_object_get_parent(void *ptr)
+{
+ return bt_get(bt_object_borrow_parent(ptr));
}
static inline
}
static inline
@@
-93,6
+102,7
@@
void bt_object_set_parent(void *child_ptr, void *parent)
* to the parent will be released once the object's reference count
* falls to zero.
*/
* to the parent will be released once the object's reference count
* falls to zero.
*/
+ BT_PUT(child->parent);
child->parent = bt_get(parent);
}
child->parent = bt_get(parent);
}
@@
-102,6
+112,7
@@
void bt_object_init(void *ptr, bt_object_release_func release)
struct bt_object *obj = ptr;
obj->release = release;
struct bt_object *obj = ptr;
obj->release = release;
+ obj->parent = NULL;
bt_ref_init(&obj->ref_count, generic_release);
}
bt_ref_init(&obj->ref_count, generic_release);
}
This page took
0.025972 seconds
and
4
git commands to generate.