#include <babeltrace/ctf-ir/stream-class.h>
#include <babeltrace/ctf-ir/stream-class-internal.h>
#include <babeltrace/ctf-ir/trace-internal.h>
+#include <babeltrace/ctf-ir/utils.h>
#include <babeltrace/compiler.h>
static
{
struct bt_ctf_event_class *event_class = NULL;
- if (validate_identifier(name)) {
+ if (bt_ctf_validate_identifier(name)) {
goto end;
}
{
int ret = 0;
- if (!event_class || !type || validate_identifier(name) ||
+ if (!event_class || !type || bt_ctf_validate_identifier(name) ||
event_class->frozen) {
ret = -1;
goto end;
bt_ctf_event_class_freeze(event_class);
event->event_class = event_class;
- assert(event_class->stream_class);
+ /*
+ * The event class does not keep ownership of the stream class to
+ * which it as been added. Therefore, it can't assume it has been
+ * set. However, we disallow the creation of an event if its
+ * associated stream class has been reclaimed.
+ */
+ if (!event_class->stream_class) {
+ goto error_destroy;
+ }
assert(event_class->stream_class->event_header_type);
event->event_header = bt_ctf_field_create(
if (!event->fields_payload) {
goto error_destroy;
}
-end:
+
/*
* Freeze the stream class since the event header must not be changed
* anymore.
*/
bt_ctf_stream_class_freeze(event_class->stream_class);
+end:
return event;
error_destroy:
bt_ctf_event_destroy(&event->ref_count);
{
int ret = 0;
- if (!event || !value || validate_identifier(name)) {
+ if (!event || !value || bt_ctf_validate_identifier(name)) {
ret = -1;
goto end;
}
return ret;
}
+void bt_ctf_event_class_set_native_byte_order(
+ struct bt_ctf_event_class *event_class,
+ int byte_order)
+{
+ if (!event_class) {
+ return;
+ }
+
+ bt_ctf_field_type_set_native_byte_order(event_class->context,
+ byte_order);
+ bt_ctf_field_type_set_native_byte_order(event_class->fields,
+ byte_order);
+}
+
BT_HIDDEN
int bt_ctf_event_validate(struct bt_ctf_event *event)
{