From: Jérémie Galarneau Date: Tue, 15 Nov 2016 21:47:18 +0000 (-0500) Subject: Add trace name attribute X-Git-Tag: v2.0.0-pre1~711 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=e96045d4f186a5f3a7ed1f5585cf4cbfe890f579 Add trace name attribute Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/trace.c b/formats/ctf/ir/trace.c index 55967275..4cf2462b 100644 --- a/formats/ctf/ir/trace.c +++ b/formats/ctf/ir/trace.c @@ -124,6 +124,38 @@ error: return trace; } +const char *bt_ctf_trace_get_name(struct bt_ctf_trace *trace) +{ + const char *name = NULL; + + if (!trace || !trace->name) { + goto end; + } + + name = trace->name->str; +end: + return name; +} + +int bt_ctf_trace_set_name(struct bt_ctf_trace *trace, const char *name) +{ + int ret = 0; + + if (!trace || !name || trace->frozen) { + ret = -1; + goto end; + } + + trace->name = trace->name ? g_string_assign(trace->name, name) : + g_string_new(name); + if (!trace->name) { + ret = -1; + goto end; + } +end: + return ret; +} + void bt_ctf_trace_destroy(struct bt_object *obj) { struct bt_ctf_trace *trace; @@ -133,6 +165,10 @@ void bt_ctf_trace_destroy(struct bt_object *obj) bt_ctf_attributes_destroy(trace->environment); } + if (trace->name) { + g_string_free(trace->name, TRUE); + } + if (trace->clocks) { g_ptr_array_free(trace->clocks, TRUE); } diff --git a/include/babeltrace/ctf-ir/trace-internal.h b/include/babeltrace/ctf-ir/trace-internal.h index db3d84f7..a782d04c 100644 --- a/include/babeltrace/ctf-ir/trace-internal.h +++ b/include/babeltrace/ctf-ir/trace-internal.h @@ -49,6 +49,7 @@ enum field_type_alias { struct bt_ctf_trace { struct bt_object base; + GString *name; int frozen; uuid_t uuid; int byte_order; /* A value defined in Babeltrace's "endian.h" */ diff --git a/include/babeltrace/ctf-ir/trace.h b/include/babeltrace/ctf-ir/trace.h index fae7832b..e935dd1f 100644 --- a/include/babeltrace/ctf-ir/trace.h +++ b/include/babeltrace/ctf-ir/trace.h @@ -71,6 +71,10 @@ typedef void (*bt_ctf_listener_cb)( */ extern struct bt_ctf_trace *bt_ctf_trace_create(void); +extern const char *bt_ctf_trace_get_name(struct bt_ctf_trace *trace); + +extern int bt_ctf_trace_set_name(struct bt_ctf_trace *trace, const char *name); + /* * bt_ctf_trace_set_environment_field: sets an environment field to the * trace.