Allow NULL (unset) packet, stream and event headers, contexts
[babeltrace.git] / formats / ctf / ir / trace.c
index ee50df6dc8e9d8714b8397781283274c184e29b0..dfb815514f55a145fa2c10ea2a3c7f3c090a4079 100644 (file)
@@ -1073,21 +1073,21 @@ int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace,
 {
        int ret = 0;
 
-       if (!trace || !packet_header_type || trace->frozen) {
+       if (!trace || trace->frozen) {
                ret = -1;
                goto end;
        }
 
-       /* packet_header_type must be a structure */
-       if (bt_ctf_field_type_get_type_id(packet_header_type) !=
-               BT_CTF_TYPE_ID_STRUCT) {
+       /* packet_header_type must be a structure. */
+       if (packet_header_type &&
+                       bt_ctf_field_type_get_type_id(packet_header_type) !=
+                               BT_CTF_TYPE_ID_STRUCT) {
                ret = -1;
                goto end;
        }
 
-       bt_get(packet_header_type);
        bt_put(trace->packet_header_type);
-       trace->packet_header_type = packet_header_type;
+       trace->packet_header_type = bt_get(packet_header_type);
 end:
        return ret;
 }
This page took 0.023837 seconds and 4 git commands to generate.