From aa4e271c0a4467105f3909779875746ca3eeeedf Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 11 May 2015 17:27:09 -0400 Subject: [PATCH] ir: add length_field_path to sequence field type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/event-types.c | 37 +++++++++++++++++++ .../babeltrace/ctf-ir/event-types-internal.h | 6 +++ 2 files changed, 43 insertions(+) diff --git a/formats/ctf/ir/event-types.c b/formats/ctf/ir/event-types.c index 9a8ce896..9b6e7bbb 100644 --- a/formats/ctf/ir/event-types.c +++ b/formats/ctf/ir/event-types.c @@ -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 diff --git a/include/babeltrace/ctf-ir/event-types-internal.h b/include/babeltrace/ctf-ir/event-types-internal.h index b420a579..ca0cf028 100644 --- a/include/babeltrace/ctf-ir/event-types-internal.h +++ b/include/babeltrace/ctf-ir/event-types-internal.h @@ -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 */ -- 2.34.1