X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Fevent.c;h=d5c66c4d87de50bdd13302c07228413993734b03;hb=71362d5384a769c154185f03afe6ef1c099aa795;hp=db55b26b5e68c0798ae7121151821954d85c14e5;hpb=29664b2a3a15c7233d916887d2f58fc42e18521e;p=babeltrace.git diff --git a/formats/ctf/ir/event.c b/formats/ctf/ir/event.c index db55b26b..d5c66c4d 100644 --- a/formats/ctf/ir/event.c +++ b/formats/ctf/ir/event.c @@ -704,6 +704,19 @@ end: return ret; } +struct bt_ctf_field *bt_ctf_event_get_payload_field(struct bt_ctf_event *event) +{ + struct bt_ctf_field *payload = NULL; + + if (!event || !event->fields_payload) { + goto end; + } + + payload = event->fields_payload; + bt_ctf_field_get(payload); +end: + return payload; +} struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, const char *name) @@ -1230,3 +1243,71 @@ int bt_ctf_event_set_stream(struct bt_ctf_event *event, end: return ret; } + +struct bt_ctf_event *bt_ctf_event_copy(struct bt_ctf_event *event) +{ + struct bt_ctf_event *copy = NULL; + + if (!event) { + goto error; + } + + copy = g_new0(struct bt_ctf_event, 1); + if (!copy) { + goto error; + } + + bt_ctf_ref_init(©->ref_count); + copy->event_class = event->event_class; + bt_ctf_event_class_get(copy->event_class); + copy->stream = event->stream; + + if (event->event_header) { + copy->event_header = bt_ctf_field_copy(event->event_header); + + if (!copy->event_header) { + goto error; + } + } + + if (event->context_payload) { + copy->context_payload = bt_ctf_field_copy( + event->context_payload); + + if (!copy->context_payload) { + goto error; + } + } + + if (event->fields_payload) { + copy->fields_payload = bt_ctf_field_copy(event->fields_payload); + + if (!copy->fields_payload) { + goto error; + } + } + + return copy; + +error: + if (copy) { + if (copy->event_class) { + bt_ctf_event_class_put(copy->event_class); + } + + if (copy->event_header) { + bt_ctf_field_put(copy->event_header); + } + + if (copy->context_payload) { + bt_ctf_field_put(copy->context_payload); + } + + if (copy->fields_payload) { + bt_ctf_field_put(copy->fields_payload); + } + } + + g_free(copy); + return NULL; +}