From 4ebcc69560461edad17ab62e3a3fe733e3fdc266 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 27 Jul 2015 08:49:09 -0400 Subject: [PATCH] ir: add bt_ctf_field_get_type_id() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/event-fields.c | 13 +++++++++++++ include/babeltrace/ctf-ir/event-fields.h | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/formats/ctf/ir/event-fields.c b/formats/ctf/ir/event-fields.c index a3de98f6..4538d8e0 100644 --- a/formats/ctf/ir/event-fields.c +++ b/formats/ctf/ir/event-fields.c @@ -282,6 +282,19 @@ end: return ret; } +enum ctf_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field) +{ + enum ctf_type_id ret = CTF_TYPE_UNKNOWN; + + if (!field) { + goto end; + } + + ret = bt_ctf_field_type_get_type_id(field->type); +end: + return ret; +} + struct bt_ctf_field *bt_ctf_field_sequence_get_length( struct bt_ctf_field *field) { diff --git a/include/babeltrace/ctf-ir/event-fields.h b/include/babeltrace/ctf-ir/event-fields.h index 2b682bb6..a1e1351a 100644 --- a/include/babeltrace/ctf-ir/event-fields.h +++ b/include/babeltrace/ctf-ir/event-fields.h @@ -352,6 +352,20 @@ extern int bt_ctf_field_string_append_len( extern struct bt_ctf_field_type *bt_ctf_field_get_type( struct bt_ctf_field *field); +/* + * bt_ctf_field_get_type_id: get a field's ctf_type_id. + * + * This is a helper function which avoids a call to + * bt_ctf_field_get_type(), followed by a call to + * bt_ctf_field_type_get_type_id(), followed by a call to + * bt_ctf_put(). + * + * @param field Field instance. + * + * Returns the field's ctf_type_id, CTF_TYPE_UNKNOWN on error. + */ +extern enum ctf_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field); + /* * bt_ctf_field_copy: get a field's deep copy. * -- 2.34.1