示例#1
0
文件: ref.c 项目: eepp/babeltrace
void *bt_get(void *ptr)
{
	struct bt_object *obj = ptr;

	if (unlikely(!obj)) {
		goto end;
	}

	if (unlikely(!obj->ref_count.release)) {
		goto end;
	}

	if (unlikely(obj->parent && bt_object_get_ref_count(obj) == 0)) {
		BT_LOGV("Incrementing object's parent's reference count: "
			"addr=%p, parent-addr=%p", ptr, obj->parent);
		bt_get(obj->parent);
	}
	BT_LOGV("Incrementing object's reference count: %lu -> %lu: "
		"addr=%p, cur-count=%lu, new-count=%lu",
		obj->ref_count.count, obj->ref_count.count + 1,
		ptr,
		obj->ref_count.count, obj->ref_count.count + 1);
	bt_ref_get(&obj->ref_count);

end:
	return obj;
}
示例#2
0
文件: ref.c 项目: mjeanson/babeltrace
void *bt_get(void *ptr)
{
	struct bt_object *obj = ptr;

	if (!obj) {
		goto end;
	}

	if (obj->parent && bt_object_get_ref_count(obj) == 0) {
		bt_get(obj->parent);
	}
	bt_ref_get(&obj->ref_count);
end:
	return obj;
}