From: Philippe Proulx Date: Mon, 27 Jul 2015 12:49:09 +0000 (-0400) Subject: ir: add bt_ctf_field_get_type_id() X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=4ebcc69560461edad17ab62e3a3fe733e3fdc266;p=deliverable%2Fbabeltrace.git ir: add bt_ctf_field_get_type_id() Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/event-fields.c b/formats/ctf/ir/event-fields.c index a3de98f61..4538d8e03 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 2b682bb64..a1e1351aa 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. *