ir: add length_field_path to sequence field type
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 May 2015 21:27:09 +0000 (17:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 May 2015 21:39:24 +0000 (17:39 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-types.c
include/babeltrace/ctf-ir/event-types-internal.h

index 9a8ce8965b4cbaa9e8548db367c0986c305bdcaf..9b6e7bbbfd8c0ac0b1d65ed3be343dc8a8d2ad2a 100644 (file)
@@ -2071,6 +2071,29 @@ int bt_ctf_field_type_variant_get_field_name_index(
 end:
        return ret;
 }
+
+BT_HIDDEN
+int bt_ctf_field_type_sequence_set_length_field_path(
+               struct bt_ctf_field_type *type,
+               struct bt_ctf_field_path *path)
+{
+       int ret = 0;
+       struct bt_ctf_field_type_sequence *sequence;
+
+       if (!type || bt_ctf_field_type_get_type_id(type) != CTF_TYPE_SEQUENCE) {
+               ret = -1;
+               goto end;
+       }
+
+       sequence = container_of(type, struct bt_ctf_field_type_sequence,
+               parent);
+       if (sequence->length_field_path) {
+               bt_ctf_field_path_destroy(sequence->length_field_path);
+       }
+       sequence->length_field_path = path;
+end:
+       return ret;
+}
 static
 void bt_ctf_field_type_integer_destroy(struct bt_ctf_ref *ref)
 {
@@ -2187,6 +2210,7 @@ void bt_ctf_field_type_sequence_destroy(struct bt_ctf_ref *ref)
                struct bt_ctf_field_type_sequence, parent);
        bt_ctf_field_type_put(sequence->element_type);
        g_string_free(sequence->length_field_name, TRUE);
+       bt_ctf_field_path_destroy(sequence->length_field_path);
        g_free(sequence);
 }
 
@@ -3039,12 +3063,25 @@ struct bt_ctf_field_type *bt_ctf_field_type_sequence_copy(
        copy_sequence = container_of(copy, struct bt_ctf_field_type_sequence,
                parent);
        copy_sequence->declaration = sequence->declaration;
+       if (sequence->length_field_path) {
+               copy_sequence->length_field_path = bt_ctf_field_path_copy(
+                       sequence->length_field_path);
+               if (!copy_sequence->length_field_path) {
+                       goto error;
+               }
+       }
 end:
        if (copy_element) {
                bt_ctf_field_type_put(copy_element);
        }
 
        return copy;
+error:
+       if (copy) {
+               bt_ctf_field_type_put(copy);
+               copy = NULL;
+       }
+       goto end;
 }
 
 static
index b420a5799fa0920d0d472db21b934774b6ba4d0f..ca0cf0280c0393525923770077bc22b5744aebee 100644 (file)
@@ -139,6 +139,7 @@ struct bt_ctf_field_type_sequence {
        struct bt_ctf_field_type parent;
        struct bt_ctf_field_type *element_type;
        GString *length_field_name;
+       struct bt_ctf_field_path *length_field_path;
        struct declaration_sequence declaration;
 };
 
@@ -202,4 +203,9 @@ int bt_ctf_field_type_structure_get_field_name_index(
 BT_HIDDEN
 int bt_ctf_field_type_variant_get_field_name_index(
                struct bt_ctf_field_type *variant, const char *name);
+
+BT_HIDDEN
+int bt_ctf_field_type_sequence_set_length_field_path(
+               struct bt_ctf_field_type *type,
+               struct bt_ctf_field_path *path);
 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.026829 seconds and 4 git commands to generate.