/* Only set an event ID if none was explicitly set before */
*event_id = bt_ctf_event_class_get_id(event_class);
- if (event_id < 0) {
+ if (*event_id < 0) {
if (bt_ctf_event_class_set_id(event_class,
stream_class->next_event_id++)) {
ret = -1;
/* Notifiy listeners of the trace's schema modification. */
if (trace) {
- struct bt_ctf_ir_element element = { .element = event_class,
- .type = BT_CTF_IR_TYPE_EVENT_CLASS };
+ struct bt_ctf_object obj = { .object = event_class,
+ .type = BT_CTF_OBJECT_TYPE_EVENT_CLASS };
- (void) bt_ctf_trace_element_modification(&element, trace);
+ (void) bt_ctf_trace_object_modification(&obj, trace);
}
end:
BT_PUT(trace);
goto end;
}
- assert(stream_class->packet_context_type);
bt_get(stream_class->packet_context_type);
ret = stream_class->packet_context_type;
end:
{
int ret = 0;
- if (!stream_class || !packet_context_type || stream_class->frozen) {
+ if (!stream_class || stream_class->frozen) {
ret = -1;
goto end;
}
- assert(stream_class->packet_context_type);
- if (stream_class->packet_context_type == packet_context_type) {
- goto end;
- }
- if (bt_ctf_field_type_get_type_id(packet_context_type) !=
- BT_CTF_TYPE_ID_STRUCT) {
- /* A packet context must be a structure */
+ if (packet_context_type &&
+ bt_ctf_field_type_get_type_id(packet_context_type) !=
+ BT_CTF_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
ret = -1;
goto end;
}
goto end;
}
- assert(stream_class->event_header_type);
bt_get(stream_class->event_header_type);
ret = stream_class->event_header_type;
end:
{
int ret = 0;
- if (!stream_class || !event_header_type || stream_class->frozen) {
+ if (!stream_class || stream_class->frozen) {
ret = -1;
goto end;
}
- assert(stream_class->event_header_type);
- if (stream_class->event_header_type == event_header_type) {
- goto end;
- }
- if (bt_ctf_field_type_get_type_id(event_header_type) !=
- BT_CTF_TYPE_ID_STRUCT) {
- /* An event header must be a structure */
+ if (event_header_type &&
+ bt_ctf_field_type_get_type_id(event_header_type) !=
+ BT_CTF_TYPE_ID_STRUCT) {
+ /* An event header must be a structure. */
ret = -1;
goto end;
}
bt_put(stream_class->event_header_type);
- bt_get(event_header_type);
- stream_class->event_header_type = event_header_type;
+ stream_class->event_header_type = bt_get(event_header_type);
end:
return ret;
}
goto end;
}
- assert(stream_class->event_context_type);
bt_get(stream_class->event_context_type);
ret = stream_class->event_context_type;
end:
{
int ret = 0;
- if (!stream_class || !event_context_type || stream_class->frozen) {
+ if (!stream_class || stream_class->frozen) {
ret = -1;
goto end;
}
- if (bt_ctf_field_type_get_type_id(event_context_type) !=
- BT_CTF_TYPE_ID_STRUCT) {
- /* A packet context must be a structure */
+ if (event_context_type &&
+ bt_ctf_field_type_get_type_id(event_context_type) !=
+ BT_CTF_TYPE_ID_STRUCT) {
+ /* A packet context must be a structure. */
ret = -1;
goto end;
}
bt_put(stream_class->event_context_type);
- bt_get(event_context_type);
- stream_class->event_context_type = event_context_type;
+ stream_class->event_context_type = bt_get(event_context_type);
end:
return ret;
}
}
static
-int visit_event_class(void *element, bt_ctf_ir_visitor visitor,void *data)
+int visit_event_class(void *object, bt_ctf_visitor visitor,void *data)
{
- struct bt_ctf_ir_element ir_element =
- { .element = element,
- .type = BT_CTF_IR_TYPE_EVENT_CLASS };
+ struct bt_ctf_object obj =
+ { .object = object,
+ .type = BT_CTF_OBJECT_TYPE_EVENT_CLASS };
- return visitor(&ir_element, data);
+ return visitor(&obj, data);
}
int bt_ctf_stream_class_visit(struct bt_ctf_stream_class *stream_class,
- bt_ctf_ir_visitor visitor, void *data)
+ bt_ctf_visitor visitor, void *data)
{
int ret;
- struct bt_ctf_ir_element element =
- { .element = stream_class,
- .type = BT_CTF_IR_TYPE_STREAM_CLASS };
+ struct bt_ctf_object obj =
+ { .object = stream_class,
+ .type = BT_CTF_OBJECT_TYPE_STREAM_CLASS };
if (!stream_class || !visitor) {
ret = -1;
goto end;
}
- ret = visitor_helper(&element, get_event_class_count,
+ ret = visitor_helper(&obj, get_event_class_count,
get_event_class,
visit_event_class, visitor, data);
end: