ir: add bt_ctf_trace_get_clock_by_name()
[babeltrace.git] / formats / ctf / ir / trace.c
index 78c2f28e87b86c83056bd5cbf91efbed5835b621..3f9bdb86f8962c3d5f970776e1e84a6f4bc2ae48 100644 (file)
@@ -497,6 +497,36 @@ end:
        return stream_class;
 }
 
+struct bt_ctf_clock *bt_ctf_trace_get_clock_by_name(
+               struct bt_ctf_trace *trace, const char *name)
+{
+       size_t i;
+       struct bt_ctf_clock *clock = NULL;
+
+       if (!trace || !name) {
+               goto end;
+       }
+
+       for (i = 0; i < trace->clocks->len; ++i) {
+               struct bt_ctf_clock *cur_clk =
+                       g_ptr_array_index(trace->clocks, i);
+               const char *cur_clk_name = bt_ctf_clock_get_name(cur_clk);
+
+               if (!cur_clk_name) {
+                       goto end;
+               }
+
+               if (!strcmp(cur_clk_name, name)) {
+                       clock = cur_clk;
+                       bt_ctf_clock_get(clock);
+                       goto end;
+               }
+       }
+
+end:
+       return clock;
+}
+
 BT_HIDDEN
 const char *get_byte_order_string(int byte_order)
 {
This page took 0.024386 seconds and 4 git commands to generate.