ir: stream: add bt_ctf_stream_is_writer()
[babeltrace.git] / formats / ctf / ir / stream.c
index 2f852373044d042fe3a3b40616102c9ce885a59a..5e9e133794232aeba637540998dd6afd7c84c4bd 100644 (file)
@@ -636,7 +636,7 @@ int bt_ctf_stream_set_packet_context(struct bt_ctf_stream *stream,
        int ret = 0;
        struct bt_ctf_field_type *field_type;
 
-       if (!stream || !field || stream->pos.fd < 0) {
+       if (!stream || stream->pos.fd < 0) {
                ret = -1;
                goto end;
        }
@@ -649,9 +649,8 @@ int bt_ctf_stream_set_packet_context(struct bt_ctf_stream *stream,
        }
 
        bt_put(field_type);
-       bt_get(field);
        bt_put(stream->packet_context);
-       stream->packet_context = field;
+       stream->packet_context = bt_get(field);
 end:
        return ret;
 }
@@ -680,7 +679,7 @@ int bt_ctf_stream_set_packet_header(struct bt_ctf_stream *stream,
        struct bt_ctf_trace *trace = NULL;
        struct bt_ctf_field_type *field_type = NULL;
 
-       if (!stream || !field || stream->pos.fd < 0) {
+       if (!stream || stream->pos.fd < 0) {
                ret = -1;
                goto end;
        }
@@ -692,9 +691,8 @@ int bt_ctf_stream_set_packet_header(struct bt_ctf_stream *stream,
                goto end;
        }
 
-       bt_get(field);
        bt_put(stream->packet_header);
-       stream->packet_header = field;
+       stream->packet_header = bt_get(field);
 end:
        BT_PUT(trace);
        bt_put(field_type);
@@ -1002,3 +1000,17 @@ const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream)
 end:
        return name;
 }
+
+int bt_ctf_stream_is_writer(struct bt_ctf_stream *stream)
+{
+       int ret = -1;
+
+       if (!stream) {
+               goto end;
+       }
+
+       ret = (stream->pos.fd >= 0);
+
+end:
+       return ret;
+}
This page took 0.024022 seconds and 4 git commands to generate.