Cleanup: line over 80 chars
[babeltrace.git] / formats / ctf / ir / event.c
index ee019ff65f0e2b89531bfab18866eceb57c00855..e63f0de295fd779042940ec0a2f12fae59277b3d 100644 (file)
@@ -35,6 +35,7 @@
 #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
@@ -48,7 +49,7 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name)
 {
        struct bt_ctf_event_class *event_class = NULL;
 
-       if (validate_identifier(name)) {
+       if (bt_ctf_validate_identifier(name)) {
                goto end;
        }
 
@@ -136,7 +137,7 @@ int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class,
 {
        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;
@@ -288,7 +289,15 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class)
        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(
@@ -307,12 +316,13 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class)
        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);
@@ -372,7 +382,7 @@ int bt_ctf_event_set_payload(struct bt_ctf_event *event,
 {
        int ret = 0;
 
-       if (!event || !value || validate_identifier(name)) {
+       if (!event || !value || bt_ctf_validate_identifier(name)) {
                ret = -1;
                goto end;
        }
@@ -704,6 +714,20 @@ 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)
 {
This page took 0.037473 seconds and 4 git commands to generate.