tap-driver.sh: flush stdout after each test result
[babeltrace.git] / plugins / ctf / common / metadata / ctf-meta.h
index 4957a94b11aa45bd3dc7ffd68c64aac3dc366757..3e7896316d94966088af4476aea9fa17aa687333 100644 (file)
  * all copies or substantial portions of the Software.
  */
 
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/common-internal.h>
-#include <babeltrace/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/common-internal.h>
+#include <babeltrace2/assert-internal.h>
 #include <glib.h>
 #include <stdint.h>
 #include <string.h>
 
-enum ctf_field_class_id {
-       CTF_FIELD_CLASS_ID_INT,
-       CTF_FIELD_CLASS_ID_ENUM,
-       CTF_FIELD_CLASS_ID_FLOAT,
-       CTF_FIELD_CLASS_ID_STRING,
-       CTF_FIELD_CLASS_ID_STRUCT,
-       CTF_FIELD_CLASS_ID_ARRAY,
-       CTF_FIELD_CLASS_ID_SEQUENCE,
-       CTF_FIELD_CLASS_ID_VARIANT,
+enum ctf_field_class_type {
+       CTF_FIELD_CLASS_TYPE_INT,
+       CTF_FIELD_CLASS_TYPE_ENUM,
+       CTF_FIELD_CLASS_TYPE_FLOAT,
+       CTF_FIELD_CLASS_TYPE_STRING,
+       CTF_FIELD_CLASS_TYPE_STRUCT,
+       CTF_FIELD_CLASS_TYPE_ARRAY,
+       CTF_FIELD_CLASS_TYPE_SEQUENCE,
+       CTF_FIELD_CLASS_TYPE_VARIANT,
 };
 
 enum ctf_field_class_meaning {
@@ -59,14 +59,38 @@ enum ctf_encoding {
        CTF_ENCODING_UTF8,
 };
 
+enum ctf_scope {
+       CTF_SCOPE_PACKET_HEADER,
+       CTF_SCOPE_PACKET_CONTEXT,
+       CTF_SCOPE_EVENT_HEADER,
+       CTF_SCOPE_EVENT_COMMON_CONTEXT,
+       CTF_SCOPE_EVENT_SPECIFIC_CONTEXT,
+       CTF_SCOPE_EVENT_PAYLOAD,
+};
+
+struct ctf_clock_class {
+       GString *name;
+       GString *description;
+       uint64_t frequency;
+       uint64_t precision;
+       int64_t offset_seconds;
+       uint64_t offset_cycles;
+       uint8_t uuid[16];
+       bool has_uuid;
+       bool is_absolute;
+
+       /* Weak, set during translation */
+       bt_clock_class *ir_cc;
+};
+
 struct ctf_field_class {
-       enum ctf_field_class_id id;
+       enum ctf_field_class_type type;
        unsigned int alignment;
        bool is_compound;
        bool in_ir;
 
        /* Weak, set during translation. NULL if `in_ir` is false below. */
-       struct bt_field_class *ir_fc;
+       bt_field_class *ir_fc;
 };
 
 struct ctf_field_class_bit_array {
@@ -79,12 +103,12 @@ struct ctf_field_class_int {
        struct ctf_field_class_bit_array base;
        enum ctf_field_class_meaning meaning;
        bool is_signed;
-       enum bt_field_class_integer_preferred_display_base disp_base;
+       bt_field_class_integer_preferred_display_base disp_base;
        enum ctf_encoding encoding;
        int64_t storing_index;
 
-       /* Owned by this */
-       struct bt_clock_class *mapped_clock_class;
+       /* Weak */
+       struct ctf_clock_class *mapped_clock_class;
 };
 
 struct ctf_range {
@@ -135,7 +159,7 @@ struct ctf_field_class_struct {
 };
 
 struct ctf_field_path {
-       enum bt_scope root;
+       enum ctf_scope root;
 
        /* Array of `int64_t` */
        GArray *path;
@@ -188,7 +212,7 @@ struct ctf_event_class {
        GString *name;
        uint64_t id;
        GString *emf_uri;
-       enum bt_event_class_log_level log_level;
+       bt_event_class_log_level log_level;
        bool is_translated;
 
        /* Owned by this */
@@ -198,12 +222,18 @@ struct ctf_event_class {
        struct ctf_field_class *payload_fc;
 
        /* Weak, set during translation */
-       struct bt_event_class *ir_ec;
+       bt_event_class *ir_ec;
 };
 
 struct ctf_stream_class {
        uint64_t id;
        bool is_translated;
+       bool packets_have_ts_begin;
+       bool packets_have_ts_end;
+       bool has_discarded_events;
+       bool has_discarded_packets;
+       bool discarded_events_have_default_cs;
+       bool discarded_packets_have_default_cs;
 
        /* Owned by this */
        struct ctf_field_class *packet_context_fc;
@@ -223,11 +253,11 @@ struct ctf_stream_class {
         */
        GHashTable *event_classes_by_id;
 
-       /* Owned by this */
-       struct bt_clock_class *default_clock_class;
+       /* Weak */
+       struct ctf_clock_class *default_clock_class;
 
        /* Weak, set during translation */
-       struct bt_stream_class *ir_sc;
+       bt_stream_class *ir_sc;
 };
 
 enum ctf_trace_class_env_entry_type {
@@ -246,7 +276,6 @@ struct ctf_trace_class_env_entry {
 };
 
 struct ctf_trace_class {
-       GString *name;
        unsigned int major;
        unsigned int minor;
        uint8_t uuid[16];
@@ -258,7 +287,7 @@ struct ctf_trace_class {
 
        uint64_t stored_value_count;
 
-       /* Array of `struct bt_clock_class *` (owned by this) */
+       /* Array of `struct ctf_clock_class *` (owned by this) */
        GPtrArray *clock_classes;
 
        /* Array of `struct ctf_stream_class *` */
@@ -270,34 +299,34 @@ struct ctf_trace_class {
        bool is_translated;
 
        /* Weak, set during translation */
-       struct bt_trace *ir_tc;
+       bt_trace_class *ir_tc;
 };
 
 static inline
 void ctf_field_class_destroy(struct ctf_field_class *fc);
 
 static inline
-void _ctf_field_class_init(struct ctf_field_class *fc, enum ctf_field_class_id id,
-               unsigned int alignment)
+void _ctf_field_class_init(struct ctf_field_class *fc,
+               enum ctf_field_class_type type, unsigned int alignment)
 {
        BT_ASSERT(fc);
-       fc->id = id;
+       fc->type = type;
        fc->alignment = alignment;
        fc->in_ir = false;
 }
 
 static inline
 void _ctf_field_class_bit_array_init(struct ctf_field_class_bit_array *fc,
-               enum ctf_field_class_id id)
+               enum ctf_field_class_type type)
 {
-       _ctf_field_class_init((void *) fc, id, 1);
+       _ctf_field_class_init((void *) fc, type, 1);
 }
 
 static inline
 void _ctf_field_class_int_init(struct ctf_field_class_int *fc,
-               enum ctf_field_class_id id)
+               enum ctf_field_class_type type)
 {
-       _ctf_field_class_bit_array_init((void *) fc, id);
+       _ctf_field_class_bit_array_init((void *) fc, type);
        fc->meaning = CTF_FIELD_CLASS_MEANING_NONE;
        fc->storing_index = -1;
 }
@@ -366,7 +395,7 @@ struct ctf_field_class_int *ctf_field_class_int_create(void)
        struct ctf_field_class_int *fc = g_new0(struct ctf_field_class_int, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_int_init(fc, CTF_FIELD_CLASS_ID_INT);
+       _ctf_field_class_int_init(fc, CTF_FIELD_CLASS_TYPE_INT);
        return fc;
 }
 
@@ -377,7 +406,7 @@ struct ctf_field_class_float *ctf_field_class_float_create(void)
                g_new0(struct ctf_field_class_float, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_bit_array_init((void *) fc, CTF_FIELD_CLASS_ID_FLOAT);
+       _ctf_field_class_bit_array_init((void *) fc, CTF_FIELD_CLASS_TYPE_FLOAT);
        return fc;
 }
 
@@ -388,7 +417,7 @@ struct ctf_field_class_string *ctf_field_class_string_create(void)
                g_new0(struct ctf_field_class_string, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_ID_STRING, 8);
+       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_STRING, 8);
        return fc;
 }
 
@@ -398,7 +427,7 @@ struct ctf_field_class_enum *ctf_field_class_enum_create(void)
        struct ctf_field_class_enum *fc = g_new0(struct ctf_field_class_enum, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_int_init((void *) fc, CTF_FIELD_CLASS_ID_ENUM);
+       _ctf_field_class_int_init((void *) fc, CTF_FIELD_CLASS_TYPE_ENUM);
        fc->mappings = g_array_new(FALSE, TRUE,
                sizeof(struct ctf_field_class_enum_mapping));
        BT_ASSERT(fc->mappings);
@@ -412,7 +441,7 @@ struct ctf_field_class_struct *ctf_field_class_struct_create(void)
                g_new0(struct ctf_field_class_struct, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_ID_STRUCT, 1);
+       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_STRUCT, 1);
        fc->members = g_array_new(FALSE, TRUE,
                sizeof(struct ctf_named_field_class));
        BT_ASSERT(fc->members);
@@ -427,7 +456,7 @@ struct ctf_field_class_variant *ctf_field_class_variant_create(void)
                g_new0(struct ctf_field_class_variant, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_ID_VARIANT, 1);
+       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_VARIANT, 1);
        fc->options = g_array_new(FALSE, TRUE,
                sizeof(struct ctf_named_field_class));
        BT_ASSERT(fc->options);
@@ -448,7 +477,7 @@ struct ctf_field_class_array *ctf_field_class_array_create(void)
                g_new0(struct ctf_field_class_array, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_ID_ARRAY, 1);
+       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_ARRAY, 1);
        fc->base.base.is_compound = true;
        return fc;
 }
@@ -460,7 +489,7 @@ struct ctf_field_class_sequence *ctf_field_class_sequence_create(void)
                g_new0(struct ctf_field_class_sequence, 1);
 
        BT_ASSERT(fc);
-       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_ID_SEQUENCE, 1);
+       _ctf_field_class_init((void *) fc, CTF_FIELD_CLASS_TYPE_SEQUENCE, 1);
        fc->length_ref = g_string_new(NULL);
        BT_ASSERT(fc->length_ref);
        ctf_field_path_init(&fc->length_path);
@@ -472,7 +501,6 @@ static inline
 void _ctf_field_class_int_destroy(struct ctf_field_class_int *fc)
 {
        BT_ASSERT(fc);
-       bt_put(fc->mapped_clock_class);
        g_free(fc);
 }
 
@@ -480,7 +508,6 @@ static inline
 void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc)
 {
        BT_ASSERT(fc);
-       bt_put(fc->base.mapped_clock_class);
 
        if (fc->mappings) {
                uint64_t i;
@@ -602,29 +629,29 @@ void ctf_field_class_destroy(struct ctf_field_class *fc)
                return;
        }
 
-       switch (fc->id) {
-       case CTF_FIELD_CLASS_ID_INT:
+       switch (fc->type) {
+       case CTF_FIELD_CLASS_TYPE_INT:
                _ctf_field_class_int_destroy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_ENUM:
+       case CTF_FIELD_CLASS_TYPE_ENUM:
                _ctf_field_class_enum_destroy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_FLOAT:
+       case CTF_FIELD_CLASS_TYPE_FLOAT:
                _ctf_field_class_float_destroy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_STRING:
+       case CTF_FIELD_CLASS_TYPE_STRING:
                _ctf_field_class_string_destroy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_STRUCT:
+       case CTF_FIELD_CLASS_TYPE_STRUCT:
                _ctf_field_class_struct_destroy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_ARRAY:
+       case CTF_FIELD_CLASS_TYPE_ARRAY:
                _ctf_field_class_array_destroy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_SEQUENCE:
+       case CTF_FIELD_CLASS_TYPE_SEQUENCE:
                _ctf_field_class_sequence_destroy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_VARIANT:
+       case CTF_FIELD_CLASS_TYPE_VARIANT:
                _ctf_field_class_variant_destroy((void *) fc);
                break;
        default:
@@ -730,8 +757,8 @@ ctf_field_class_struct_borrow_member_int_field_class_by_name(
                goto end;
        }
 
-       if (int_fc->base.base.id != CTF_FIELD_CLASS_ID_INT &&
-                       int_fc->base.base.id != CTF_FIELD_CLASS_ID_ENUM) {
+       if (int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_INT &&
+                       int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_ENUM) {
                int_fc = NULL;
                goto end;
        }
@@ -865,8 +892,8 @@ struct ctf_field_class *ctf_field_class_compound_borrow_field_class_by_index(
 {
        struct ctf_field_class *fc = NULL;
 
-       switch (comp_fc->id) {
-       case CTF_FIELD_CLASS_ID_STRUCT:
+       switch (comp_fc->type) {
+       case CTF_FIELD_CLASS_TYPE_STRUCT:
        {
                struct ctf_named_field_class *named_fc =
                        ctf_field_class_struct_borrow_member_by_index(
@@ -876,7 +903,7 @@ struct ctf_field_class *ctf_field_class_compound_borrow_field_class_by_index(
                fc = named_fc->fc;
                break;
        }
-       case CTF_FIELD_CLASS_ID_VARIANT:
+       case CTF_FIELD_CLASS_TYPE_VARIANT:
        {
                struct ctf_named_field_class *named_fc =
                        ctf_field_class_variant_borrow_option_by_index(
@@ -886,8 +913,8 @@ struct ctf_field_class *ctf_field_class_compound_borrow_field_class_by_index(
                fc = named_fc->fc;
                break;
        }
-       case CTF_FIELD_CLASS_ID_ARRAY:
-       case CTF_FIELD_CLASS_ID_SEQUENCE:
+       case CTF_FIELD_CLASS_TYPE_ARRAY:
+       case CTF_FIELD_CLASS_TYPE_SEQUENCE:
        {
                struct ctf_field_class_array_base *array_fc = (void *) comp_fc;
 
@@ -906,23 +933,23 @@ uint64_t ctf_field_class_compound_get_field_class_count(struct ctf_field_class *
 {
        uint64_t field_count;
 
-       switch (fc->id) {
-       case CTF_FIELD_CLASS_ID_STRUCT:
+       switch (fc->type) {
+       case CTF_FIELD_CLASS_TYPE_STRUCT:
        {
                struct ctf_field_class_struct *struct_fc = (void *) fc;
 
                field_count = struct_fc->members->len;
                break;
        }
-       case CTF_FIELD_CLASS_ID_VARIANT:
+       case CTF_FIELD_CLASS_TYPE_VARIANT:
        {
                struct ctf_field_class_variant *var_fc = (void *) fc;
 
                field_count = var_fc->options->len;
                break;
        }
-       case CTF_FIELD_CLASS_ID_ARRAY:
-       case CTF_FIELD_CLASS_ID_SEQUENCE:
+       case CTF_FIELD_CLASS_TYPE_ARRAY:
+       case CTF_FIELD_CLASS_TYPE_SEQUENCE:
                /*
                 * Array and sequence types always contain a single
                 * member (the element type).
@@ -943,8 +970,8 @@ int64_t ctf_field_class_compound_get_field_class_index_from_name(
        int64_t ret_index = -1;
        uint64_t i;
 
-       switch (fc->id) {
-       case CTF_FIELD_CLASS_ID_STRUCT:
+       switch (fc->type) {
+       case CTF_FIELD_CLASS_TYPE_STRUCT:
        {
                struct ctf_field_class_struct *struct_fc = (void *) fc;
 
@@ -961,7 +988,7 @@ int64_t ctf_field_class_compound_get_field_class_index_from_name(
 
                break;
        }
-       case CTF_FIELD_CLASS_ID_VARIANT:
+       case CTF_FIELD_CLASS_TYPE_VARIANT:
        {
                struct ctf_field_class_variant *var_fc = (void *) fc;
 
@@ -1009,6 +1036,27 @@ void ctf_field_path_clear(struct ctf_field_path *fp)
        g_array_set_size(fp->path, 0);
 }
 
+static inline
+const char *ctf_scope_string(enum ctf_scope scope)
+{
+       switch (scope) {
+       case CTF_SCOPE_PACKET_HEADER:
+               return "CTF_SCOPE_PACKET_HEADER";
+       case CTF_SCOPE_PACKET_CONTEXT:
+               return "CTF_SCOPE_PACKET_CONTEXT";
+       case CTF_SCOPE_EVENT_HEADER:
+               return "CTF_SCOPE_EVENT_HEADER";
+       case CTF_SCOPE_EVENT_COMMON_CONTEXT:
+               return "CTF_SCOPE_EVENT_COMMON_CONTEXT";
+       case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
+               return "CTF_SCOPE_EVENT_SPECIFIC_CONTEXT";
+       case CTF_SCOPE_EVENT_PAYLOAD:
+               return "CTF_SCOPE_EVENT_PAYLOAD";
+       default:
+               abort();
+       }
+}
+
 static inline
 GString *ctf_field_path_string(struct ctf_field_path *path)
 {
@@ -1021,8 +1069,7 @@ GString *ctf_field_path_string(struct ctf_field_path *path)
                goto end;
        }
 
-       g_string_append_printf(str, "[%s", bt_common_scope_string(
-               path->root));
+       g_string_append_printf(str, "[%s", ctf_scope_string(path->root));
 
        for (i = 0; i < path->path->len; i++) {
                g_string_append_printf(str, ", %" PRId64,
@@ -1046,22 +1093,22 @@ struct ctf_field_class *ctf_field_path_borrow_field_class(
        struct ctf_field_class *fc;
 
        switch (field_path->root) {
-       case BT_SCOPE_PACKET_HEADER:
+       case CTF_SCOPE_PACKET_HEADER:
                fc = tc->packet_header_fc;
                break;
-       case BT_SCOPE_PACKET_CONTEXT:
+       case CTF_SCOPE_PACKET_CONTEXT:
                fc = sc->packet_context_fc;
                break;
-       case BT_SCOPE_EVENT_HEADER:
+       case CTF_SCOPE_EVENT_HEADER:
                fc = sc->event_header_fc;
                break;
-       case BT_SCOPE_EVENT_COMMON_CONTEXT:
+       case CTF_SCOPE_EVENT_COMMON_CONTEXT:
                fc = sc->event_common_context_fc;
                break;
-       case BT_SCOPE_EVENT_SPECIFIC_CONTEXT:
+       case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
                fc = ec->spec_context_fc;
                break;
-       case BT_SCOPE_EVENT_PAYLOAD:
+       case CTF_SCOPE_EVENT_PAYLOAD:
                fc = ec->payload_fc;
                break;
        default:
@@ -1108,7 +1155,7 @@ void ctf_field_class_int_copy_content(
        dst_fc->is_signed = src_fc->is_signed;
        dst_fc->disp_base = src_fc->disp_base;
        dst_fc->encoding = src_fc->encoding;
-       dst_fc->mapped_clock_class = bt_get(src_fc->mapped_clock_class);
+       dst_fc->mapped_clock_class = src_fc->mapped_clock_class;
        dst_fc->storing_index = src_fc->storing_index;
 }
 
@@ -1293,36 +1340,36 @@ struct ctf_field_class *ctf_field_class_copy(struct ctf_field_class *fc)
         */
        BT_ASSERT(!fc->ir_fc);
 
-       switch (fc->id) {
-       case CTF_FIELD_CLASS_ID_INT:
+       switch (fc->type) {
+       case CTF_FIELD_CLASS_TYPE_INT:
                copy_fc = (void *) _ctf_field_class_int_copy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_ENUM:
+       case CTF_FIELD_CLASS_TYPE_ENUM:
                copy_fc = (void *) _ctf_field_class_enum_copy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_FLOAT:
+       case CTF_FIELD_CLASS_TYPE_FLOAT:
                copy_fc = (void *) _ctf_field_class_float_copy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_STRING:
+       case CTF_FIELD_CLASS_TYPE_STRING:
                copy_fc = (void *) _ctf_field_class_string_copy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_STRUCT:
+       case CTF_FIELD_CLASS_TYPE_STRUCT:
                copy_fc = (void *) _ctf_field_class_struct_copy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_ARRAY:
+       case CTF_FIELD_CLASS_TYPE_ARRAY:
                copy_fc = (void *) _ctf_field_class_array_copy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_SEQUENCE:
+       case CTF_FIELD_CLASS_TYPE_SEQUENCE:
                copy_fc = (void *) _ctf_field_class_sequence_copy((void *) fc);
                break;
-       case CTF_FIELD_CLASS_ID_VARIANT:
+       case CTF_FIELD_CLASS_TYPE_VARIANT:
                copy_fc = (void *) _ctf_field_class_variant_copy((void *) fc);
                break;
        default:
                abort();
        }
 
-       copy_fc->id = fc->id;
+       copy_fc->type = fc->type;
        copy_fc->alignment = fc->alignment;
        copy_fc->in_ir = fc->in_ir;
 
@@ -1397,7 +1444,6 @@ void ctf_stream_class_destroy(struct ctf_stream_class *sc)
        ctf_field_class_destroy(sc->packet_context_fc);
        ctf_field_class_destroy(sc->event_header_fc);
        ctf_field_class_destroy(sc->event_common_context_fc);
-       bt_put(sc->default_clock_class);
        g_free(sc);
 }
 
@@ -1412,11 +1458,11 @@ void ctf_stream_class_append_event_class(struct ctf_stream_class *sc,
 
 static inline
 struct ctf_event_class *ctf_stream_class_borrow_event_class_by_id(
-               struct ctf_stream_class *sc, uint64_t id)
+               struct ctf_stream_class *sc, uint64_t type)
 {
        BT_ASSERT(sc);
        return g_hash_table_lookup(sc->event_classes_by_id,
-               GUINT_TO_POINTER((guint) id));
+               GUINT_TO_POINTER((guint) type));
 }
 
 static inline
@@ -1443,17 +1489,47 @@ void _ctf_trace_class_env_entry_fini(struct ctf_trace_class_env_entry *entry)
        }
 }
 
+static inline
+struct ctf_clock_class *ctf_clock_class_create(void)
+{
+       struct ctf_clock_class *cc = g_new0(struct ctf_clock_class, 1);
+
+       BT_ASSERT(cc);
+       cc->name = g_string_new(NULL);
+       BT_ASSERT(cc->name);
+       cc->description = g_string_new(NULL);
+       BT_ASSERT(cc->description);
+       return cc;
+}
+
+static inline
+void ctf_clock_class_destroy(struct ctf_clock_class *cc)
+{
+       if (!cc) {
+               return;
+       }
+
+       if (cc->name) {
+               g_string_free(cc->name, TRUE);
+       }
+
+       if (cc->description) {
+               g_string_free(cc->description, TRUE);
+       }
+
+       bt_clock_class_put_ref(cc->ir_cc);
+       g_free(cc);
+}
+
 static inline
 struct ctf_trace_class *ctf_trace_class_create(void)
 {
        struct ctf_trace_class *tc = g_new0(struct ctf_trace_class, 1);
 
        BT_ASSERT(tc);
-       tc->name = g_string_new(NULL);
        tc->default_byte_order = -1;
-       BT_ASSERT(tc->name);
        tc->clock_classes = g_ptr_array_new_with_free_func(
-               (GDestroyNotify) bt_put);
+               (GDestroyNotify) ctf_clock_class_destroy);
        BT_ASSERT(tc->clock_classes);
        tc->stream_classes = g_ptr_array_new_with_free_func(
                (GDestroyNotify) ctf_stream_class_destroy);
@@ -1470,10 +1546,6 @@ void ctf_trace_class_destroy(struct ctf_trace_class *tc)
                return;
        }
 
-       if (tc->name) {
-               g_string_free(tc->name, TRUE);
-       }
-
        ctf_field_class_destroy(tc->packet_header_fc);
 
        if (tc->clock_classes) {
@@ -1548,21 +1620,20 @@ end:
 }
 
 static inline
-struct bt_clock_class *ctf_trace_class_borrow_clock_class_by_name(
+struct ctf_clock_class *ctf_trace_class_borrow_clock_class_by_name(
                struct ctf_trace_class *tc, const char *name)
 {
        uint64_t i;
-       struct bt_clock_class *ret_cc = NULL;
+       struct ctf_clock_class *ret_cc = NULL;
 
        BT_ASSERT(tc);
        BT_ASSERT(name);
 
        for (i = 0; i < tc->clock_classes->len; i++) {
-               struct bt_clock_class *cc = tc->clock_classes->pdata[i];
-               const char *cc_name = bt_clock_class_get_name(cc);
+               struct ctf_clock_class *cc = tc->clock_classes->pdata[i];
 
-               BT_ASSERT(cc_name);
-               if (strcmp(cc_name, name) == 0) {
+               BT_ASSERT(cc->name);
+               if (strcmp(cc->name->str, name) == 0) {
                        ret_cc = cc;
                        goto end;
                }
This page took 0.040878 seconds and 4 git commands to generate.