- struct bt_ctf_clock_class *clock_class =
- bt_ctf_trace_get_clock_class_by_index(trace, i);
-
- if (!clock_class) {
- fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__,
- __LINE__);
- goto error;
+ const struct bt_clock_class *clock_class =
+ bt_trace_get_clock_class_by_index(trace, i);
+ const struct bt_clock_class *existing_clock_class = NULL;
+
+ BT_ASSERT(clock_class);
+
+ existing_clock_class = bt_trace_get_clock_class_by_name(
+ writer_trace, bt_clock_class_get_name(clock_class));
+ bt_object_put_ref(existing_clock_class);
+ if (existing_clock_class) {
+ bt_object_put_ref(clock_class);
+ continue;