Add bt_clock_class_priority_map_copy()
[babeltrace.git] / lib / graph / clock-class-priority-map.c
index 136ed276de4a11c1ff8532948634a34fa3715d80..2d4fac11937037dc6bda3e233b711f8d87b36d4b 100644 (file)
@@ -265,3 +265,37 @@ end:
 
        return ret;
 }
+
+struct bt_clock_class_priority_map *bt_clock_class_priority_map_copy(
+               struct bt_clock_class_priority_map *orig_cc_prio_map)
+{
+       struct bt_clock_class_priority_map *cc_prio_map;
+       size_t i;
+
+       cc_prio_map = bt_clock_class_priority_map_create();
+       if (!cc_prio_map) {
+               goto error;
+       }
+
+       for (i = 0; i < orig_cc_prio_map->entries->len; i++) {
+               struct bt_ctf_clock_class *clock_class =
+                       g_ptr_array_index(orig_cc_prio_map->entries, i);
+               uint64_t *prio = g_hash_table_lookup(orig_cc_prio_map->prios,
+                       clock_class);
+               int ret = bt_clock_class_priority_map_add_clock_class(
+                       cc_prio_map, clock_class, *prio);
+
+               if (ret) {
+                       goto error;
+               }
+       }
+
+       cc_prio_map->highest_prio_cc = orig_cc_prio_map->highest_prio_cc;
+       goto end;
+
+error:
+       BT_PUT(cc_prio_map);
+
+end:
+       return cc_prio_map;
+}
This page took 0.035159 seconds and 4 git commands to generate.