Cleanup: Missing whitespace in comment
[babeltrace.git] / formats / ctf / ir / stream.c
index d9bd5ef87b0950ef0fb60b63a189196ab7d2b33c..b4eb294bf1bfe4ac0990110bf902e0cadb8db814 100644 (file)
@@ -67,7 +67,21 @@ struct bt_ctf_stream *bt_ctf_stream_create(
                goto error_destroy;
        }
 
-       /* Initialize events_discarded*/
+       /*
+        * A stream class may not have a stream event context defined
+        * in which case this stream will never have a stream_event_context
+        * member since, after a stream's creation, the parent stream class
+        * is "frozen" (immutable).
+        */
+       if (stream_class->event_context_type) {
+               stream->event_context = bt_ctf_field_create(
+                       stream_class->event_context_type);
+               if (!stream->packet_context) {
+                       goto error_destroy;
+               }
+       }
+
+       /* Initialize events_discarded */
        ret = set_structure_field_integer(stream->packet_context,
                "events_discarded", 0);
        if (ret) {
@@ -252,6 +266,7 @@ int bt_ctf_stream_append_event(struct bt_ctf_stream *stream,
 {
        int ret = 0;
        uint64_t timestamp;
+       struct bt_ctf_field *event_context_copy = NULL;
 
        if (!stream || !event) {
                ret = -1;
@@ -326,7 +341,11 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
        struct bt_ctf_field *integer = NULL;
        struct ctf_stream_pos packet_context_pos;
 
-       if (!stream) {
+       if (!stream || stream->pos.fd < 0) {
+               /*
+                * Stream does not have an associated fd. It is,
+                * therefore, not a stream being used to write events.
+                */
                ret = -1;
                goto end;
        }
This page took 0.026664 seconds and 4 git commands to generate.