- const char *clock_name =
- bt_ctf_clock_get_name(stream_class->clock);
- struct bt_ctf_clock *trace_clock;
-
- assert(clock_name);
- trace_clock = bt_ctf_trace_get_clock_by_name(trace, clock_name);
- bt_put(trace_clock);
- if (trace_clock) {
- if (trace_clock != stream_class->clock) {
- /*
- * Error: two different clocks in the
- * trace would share the same name.
- */
+ struct bt_ctf_clock_class *stream_clock_class =
+ stream_class->clock->clock_class;
+
+ if (trace->is_created_by_writer) {
+ /*
+ * Make sure this clock was also added to the
+ * trace (potentially through its CTF writer
+ * owner).
+ */
+ size_t i;
+
+ for (i = 0; i < trace->clocks->len; i++) {
+ if (trace->clocks->pdata[i] ==
+ stream_clock_class) {
+ /* Found! */
+ break;
+ }
+ }
+
+ if (i == trace->clocks->len) {
+ /* Not found */