Document libbabeltrace2's C API
[babeltrace.git] / src / lib / trace-ir / clock-snapshot.c
index 899d0083dba106ff0fa6c993ed6d21b5f63dde27..9d20c9c1a0ff69e7b4e378702155224bc8d509e7 100644 (file)
@@ -27,7 +27,7 @@
 #include "common/uuid.h"
 #include "clock-class.h"
 #include "clock-snapshot.h"
-#include <babeltrace2/trace-ir/clock-snapshot-const.h>
+#include <babeltrace2/trace-ir/clock-snapshot.h>
 #include "compat/compiler.h"
 #include <babeltrace2/types.h>
 #include "compat/string.h"
@@ -63,7 +63,7 @@ struct bt_clock_snapshot *bt_clock_snapshot_new(
 
        bt_object_init_unique(&ret->base);
        ret->clock_class = clock_class;
-       bt_object_get_no_null_check(clock_class);
+       bt_object_get_ref_no_null_check(clock_class);
        bt_clock_class_freeze(clock_class);
        BT_LIB_LOGD("Created clock snapshot object: %!+k", ret);
 
@@ -77,26 +77,18 @@ struct bt_clock_snapshot *bt_clock_snapshot_create(
 {
        struct bt_clock_snapshot *clock_snapshot = NULL;
 
-       BT_ASSERT(clock_class);
+       BT_ASSERT_DBG(clock_class);
        clock_snapshot = bt_object_pool_create_object(&clock_class->cs_pool);
        if (!clock_snapshot) {
                BT_LIB_LOGE_APPEND_CAUSE(
                        "Cannot allocate one clock snapshot from clock class's clock snapshot pool: "
                        "%![cc-]+K", clock_class);
-               goto error;
+               goto end;
        }
 
        if (G_LIKELY(!clock_snapshot->clock_class)) {
                clock_snapshot->clock_class = clock_class;
-               bt_object_get_no_null_check(clock_class);
-       }
-
-       goto end;
-
-error:
-       if (clock_snapshot) {
-               bt_clock_snapshot_recycle(clock_snapshot);
-               clock_snapshot = NULL;
+               bt_object_get_ref_no_null_check(clock_class);
        }
 
 end:
@@ -108,7 +100,7 @@ void bt_clock_snapshot_recycle(struct bt_clock_snapshot *clock_snapshot)
 {
        struct bt_clock_class *clock_class;
 
-       BT_ASSERT(clock_snapshot);
+       BT_ASSERT_DBG(clock_snapshot);
        BT_LIB_LOGD("Recycling clock snapshot: %!+k", clock_snapshot);
 
        /*
@@ -135,7 +127,7 @@ void bt_clock_snapshot_recycle(struct bt_clock_snapshot *clock_snapshot)
         */
        bt_clock_snapshot_reset(clock_snapshot);
        clock_class = clock_snapshot->clock_class;
-       BT_ASSERT(clock_class);
+       BT_ASSERT_DBG(clock_class);
        clock_snapshot->clock_class = NULL;
        bt_object_pool_recycle_object(&clock_class->cs_pool, clock_snapshot);
        bt_object_put_ref(clock_class);
@@ -157,6 +149,7 @@ bt_clock_snapshot_get_ns_from_origin(
 {
        int ret = BT_FUNC_STATUS_OK;
 
+       BT_ASSERT_PRE_DEV_NO_ERROR();
        BT_ASSERT_PRE_DEV_NON_NULL(clock_snapshot, "Clock snapshot");
        BT_ASSERT_PRE_DEV_NON_NULL(ret_value_ns, "Value (ns) (output)");
        BT_ASSERT_PRE_DEV(clock_snapshot->is_set,
This page took 0.025968 seconds and 4 git commands to generate.