lib: replace trace is_static with destruction listeners
[babeltrace.git] / plugins / lttng-utils / copy.c
index 5467d3843365534dc4b6aeeb5ffdb8b329c9474b..918e6e17bb8050b4ab66ee1e40b789acda0e1ad6 100644 (file)
 #include "debug-info.h"
 
 static
-struct bt_stream *insert_new_stream(
+const bt_stream *insert_new_stream(
                struct debug_info_iterator *debug_it,
-               struct bt_stream *stream,
+               const bt_stream *stream,
                struct debug_info_trace *di_trace);
 
 static
-void unref_stream(struct bt_stream *stream)
+void unref_stream(const bt_stream *stream)
 {
-       bt_object_put_ref(stream);
+       bt_stream_put_ref(stream);
 }
 
 static
-void unref_packet(struct bt_packet *packet)
+void unref_packet(const bt_packet *packet)
 {
-       bt_object_put_ref(packet);
+       bt_packet_put_ref(packet);
 }
 
 static
-void unref_stream_class(struct bt_stream_class *stream_class)
+void unref_stream_class(const bt_stream_class *stream_class)
 {
-       bt_object_put_ref(stream_class);
+       bt_stream_class_put_ref(stream_class);
 }
 
 static
@@ -73,11 +73,11 @@ void destroy_stream_state_key(gpointer key)
 }
 
 static
-struct bt_field *get_payload_field(FILE *err,
-               struct bt_event *event, const char *field_name)
+const bt_field *get_payload_field(FILE *err,
+               const bt_event *event, const char *field_name)
 {
-       struct bt_field *field = NULL, *payload = NULL;
-       struct bt_field_class *payload_class = NULL;
+       const bt_field *field = NULL, *payload = NULL;
+       const bt_field_class *payload_class = NULL;
 
        payload = bt_event_get_payload(event, NULL);
        BT_ASSERT(payload);
@@ -94,17 +94,17 @@ struct bt_field *get_payload_field(FILE *err,
        field = bt_field_structure_get_field_by_name(payload, field_name);
 
 end:
-       bt_object_put_ref(payload_class);
+       bt_field_class_put_ref(payload_class);
        bt_object_put_ref(payload);
        return field;
 }
 
 static
-struct bt_field *get_stream_event_context_field(FILE *err,
-               struct bt_event *event, const char *field_name)
+const bt_field *get_stream_event_context_field(FILE *err,
+               const bt_event *event, const char *field_name)
 {
-       struct bt_field *field = NULL, *sec = NULL;
-       struct bt_field_class *sec_class = NULL;
+       const bt_field *field = NULL, *sec = NULL;
+       const bt_field_class *sec_class = NULL;
 
        sec = bt_event_get_stream_event_context(event);
        if (!sec) {
@@ -123,19 +123,19 @@ struct bt_field *get_stream_event_context_field(FILE *err,
        field = bt_field_structure_get_field_by_name(sec, field_name);
 
 end:
-       bt_object_put_ref(sec_class);
+       bt_field_class_put_ref(sec_class);
        bt_object_put_ref(sec);
        return field;
 }
 
 BT_HIDDEN
 int get_stream_event_context_unsigned_int_field_value(FILE *err,
-               struct bt_event *event, const char *field_name,
+               const bt_event *event, const char *field_name,
                uint64_t *value)
 {
        int ret;
-       struct bt_field *field = NULL;
-       struct bt_field_class *field_class = NULL;
+       const bt_field *field = NULL;
+       const bt_field_class *field_class = NULL;
 
        field = get_stream_event_context_field(err, event, field_name);
        if (!field) {
@@ -168,17 +168,17 @@ int get_stream_event_context_unsigned_int_field_value(FILE *err,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        bt_object_put_ref(field);
        return ret;
 }
 
 BT_HIDDEN
-int get_stream_event_context_int_field_value(FILE *err, struct bt_event *event,
+int get_stream_event_context_int_field_value(FILE *err, const bt_event *event,
                const char *field_name, int64_t *value)
 {
-       struct bt_field *field = NULL;
-       struct bt_field_class *field_class = NULL;
+       const bt_field *field = NULL;
+       const bt_field_class *field_class = NULL;
        int ret;
 
        field = get_stream_event_context_field(err, event, field_name);
@@ -206,18 +206,18 @@ int get_stream_event_context_int_field_value(FILE *err, struct bt_event *event,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        bt_object_put_ref(field);
        return ret;
 }
 
 BT_HIDDEN
 int get_payload_unsigned_int_field_value(FILE *err,
-               struct bt_event *event, const char *field_name,
+               const bt_event *event, const char *field_name,
                uint64_t *value)
 {
-       struct bt_field *field = NULL;
-       struct bt_field_class *field_class = NULL;
+       const bt_field *field = NULL;
+       const bt_field_class *field_class = NULL;
        int ret;
 
        field = get_payload_field(err, event, field_name);
@@ -252,17 +252,17 @@ int get_payload_unsigned_int_field_value(FILE *err,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        bt_object_put_ref(field);
        return ret;
 }
 
 BT_HIDDEN
-int get_payload_int_field_value(FILE *err, struct bt_event *event,
+int get_payload_int_field_value(FILE *err, const bt_event *event,
                const char *field_name, int64_t *value)
 {
-       struct bt_field *field = NULL;
-       struct bt_field_class *field_class = NULL;
+       const bt_field *field = NULL;
+       const bt_field_class *field_class = NULL;
        int ret;
 
        field = get_payload_field(err, event, field_name);
@@ -296,18 +296,18 @@ int get_payload_int_field_value(FILE *err, struct bt_event *event,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        bt_object_put_ref(field);
        return ret;
 }
 
 BT_HIDDEN
 int get_payload_string_field_value(FILE *err,
-               struct bt_event *event, const char *field_name,
+               const bt_event *event, const char *field_name,
                const char **value)
 {
-       struct bt_field *field = NULL;
-       struct bt_field_class *field_class = NULL;
+       const bt_field *field = NULL;
+       const bt_field_class *field_class = NULL;
        int ret;
 
        /*
@@ -340,19 +340,19 @@ int get_payload_string_field_value(FILE *err,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        bt_object_put_ref(field);
        return ret;
 }
 
 BT_HIDDEN
 int get_payload_build_id_field_value(FILE *err,
-               struct bt_event *event, const char *field_name,
+               const bt_event *event, const char *field_name,
                uint8_t **build_id, uint64_t *build_id_len)
 {
-       struct bt_field *field = NULL, *seq_len = NULL;
-       struct bt_field_class *field_class = NULL;
-       struct bt_field *seq_field = NULL;
+       const bt_field *field = NULL, *seq_len = NULL;
+       const bt_field_class *field_class = NULL;
+       const bt_field *seq_field = NULL;
        uint64_t i;
        int ret;
 
@@ -371,7 +371,7 @@ int get_payload_build_id_field_value(FILE *err,
                BT_LOGE("Wrong type, expected sequence: field-name=\"%s\"", field_name);
                goto error;
        }
-       BT_OBJECT_PUT_REF_AND_RESET(field_class);
+       BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class);
 
        seq_len = bt_field_sequence_get_length(field);
        BT_ASSERT(seq_len);
@@ -417,14 +417,14 @@ error:
        g_free(*build_id);
        ret = -1;
 end:
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        bt_object_put_ref(field);
        return ret;
 }
 
 static
 struct debug_info *lookup_trace_debug_info(struct debug_info_iterator *debug_it,
-               struct bt_trace *writer_trace,
+               const bt_trace *writer_trace,
                struct debug_info_trace *di_trace)
 {
        return (struct debug_info *) g_hash_table_lookup(
@@ -434,13 +434,13 @@ struct debug_info *lookup_trace_debug_info(struct debug_info_iterator *debug_it,
 
 static
 struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it,
-               struct bt_trace *writer_trace,
+               const bt_trace *writer_trace,
                struct debug_info_trace *di_trace)
 {
        struct debug_info *debug_info = NULL;
-       struct bt_value *field = NULL;
+       bt_value *field = NULL;
        const char *str_value;
-       enum bt_value_status ret;
+       bt_value_status ret;
 
        field = bt_trace_get_environment_field_value_by_name(writer_trace,
                        "domain");
@@ -454,7 +454,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it,
        if (strcmp(str_value, "ust") != 0) {
                goto end;
        }
-       BT_OBJECT_PUT_REF_AND_RESET(field);
+       BT_VALUE_PUT_REF_AND_RESET(field);
 
        /* No tracer_name, no debug info */
        field = bt_trace_get_environment_field_value_by_name(writer_trace,
@@ -469,7 +469,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it,
        if (strcmp(str_value, "lttng-ust") != 0) {
                goto end;
        }
-       BT_OBJECT_PUT_REF_AND_RESET(field);
+       BT_VALUE_PUT_REF_AND_RESET(field);
 
        debug_info = debug_info_create(debug_it->debug_info_component);
        if (!debug_info) {
@@ -481,13 +481,13 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it,
                        debug_info);
 
 end:
-       bt_object_put_ref(field);
+       bt_value_put_ref(field);
        return debug_info;
 }
 
 static
 struct debug_info *get_trace_debug_info(struct debug_info_iterator *debug_it,
-               struct bt_trace *writer_trace,
+               const bt_trace *writer_trace,
                struct debug_info_trace *di_trace)
 {
        struct debug_info *debug_info;
@@ -505,7 +505,7 @@ end:
 
 static
 struct debug_info_trace *lookup_trace(struct debug_info_iterator *debug_it,
-               struct bt_trace *trace)
+               const bt_trace *trace)
 {
        return (struct debug_info_trace *) g_hash_table_lookup(
                        debug_it->trace_map,
@@ -515,7 +515,7 @@ struct debug_info_trace *lookup_trace(struct debug_info_iterator *debug_it,
 static
 enum debug_info_stream_state *insert_new_stream_state(
                struct debug_info_iterator *debug_it,
-               struct debug_info_trace *di_trace, struct bt_stream *stream)
+               struct debug_info_trace *di_trace, const bt_stream *stream)
 {
        enum debug_info_stream_state *v = NULL;
 
@@ -586,13 +586,13 @@ void debug_info_close_trace(struct debug_info_iterator *debug_it,
 
 static
 int sync_event_classes(struct debug_info_iterator *debug_it,
-               struct bt_stream *stream,
-               struct bt_stream *writer_stream)
+               const bt_stream *stream,
+               const bt_stream *writer_stream)
 {
        int int_ret;
-       struct bt_stream_class *stream_class = NULL,
+       const bt_stream_class *stream_class = NULL,
                                   *writer_stream_class = NULL;
-       enum bt_component_status ret;
+       bt_component_status ret;
 
        stream_class = bt_stream_get_class(stream);
        BT_ASSERT(stream_class);
@@ -613,18 +613,18 @@ int sync_event_classes(struct debug_info_iterator *debug_it,
 error:
        int_ret = -1;
 end:
-       bt_object_put_ref(stream_class);
-       bt_object_put_ref(writer_stream_class);
+       bt_stream_class_put_ref(stream_class);
+       bt_stream_class_put_ref(writer_stream_class);
        return int_ret;
 }
 
 static
-void trace_is_static_listener(struct bt_trace *trace, void *data)
+void trace_is_static_listener(const bt_trace *trace, void *data)
 {
        struct debug_info_trace *di_trace = data;
        int trace_completed = 1, ret, nr_stream, i;
-       struct bt_stream *stream = NULL, *writer_stream = NULL;
-       struct bt_trace *writer_trace = di_trace->writer_trace;
+       const bt_stream *stream = NULL, *writer_stream = NULL;
+       const bt_trace *writer_trace = di_trace->writer_trace;
 
        /*
         * When the trace becomes static, make sure that we have all
@@ -644,8 +644,8 @@ void trace_is_static_listener(struct bt_trace *trace, void *data)
                        BT_LOGE_STR("Failed to synchronize the event classes.");
                        goto error;
                }
-               BT_OBJECT_PUT_REF_AND_RESET(stream);
-               BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
+               BT_STREAM_PUT_REF_AND_RESET(stream);
+               BT_STREAM_PUT_REF_AND_RESET(writer_stream);
        }
 
        bt_trace_set_is_static(di_trace->writer_trace);
@@ -660,18 +660,18 @@ void trace_is_static_listener(struct bt_trace *trace, void *data)
        }
 
 error:
-       bt_object_put_ref(writer_stream);
-       bt_object_put_ref(stream);
+       bt_stream_put_ref(writer_stream);
+       bt_stream_put_ref(stream);
 }
 
 static
 struct debug_info_trace *insert_new_trace(struct debug_info_iterator *debug_it,
-               struct bt_stream *stream) {
-       struct bt_trace *writer_trace = NULL;
+               const bt_stream *stream) {
+       const bt_trace *writer_trace = NULL;
        struct debug_info_trace *di_trace = NULL;
-       struct bt_trace *trace = NULL;
-       struct bt_stream_class *stream_class = NULL;
-       struct bt_stream *writer_stream = NULL;
+       const bt_trace *trace = NULL;
+       const bt_stream_class *stream_class = NULL;
+       const bt_stream *writer_stream = NULL;
        int ret, nr_stream, i;
 
        writer_trace = bt_trace_create();
@@ -726,14 +726,14 @@ struct debug_info_trace *insert_new_trace(struct debug_info_iterator *debug_it,
                        BT_LOGE_STR("Failed to insert new stream.");
                        goto error;
                }
-               bt_object_get_ref(writer_stream);
+               bt_stream_get_ref(writer_stream);
                ret = sync_event_classes(debug_it, stream, writer_stream);
                if (ret) {
                        BT_LOGE_STR("Failed to synchronize event classes.");
                        goto error;
                }
-               BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
-               BT_OBJECT_PUT_REF_AND_RESET(stream);
+               BT_STREAM_PUT_REF_AND_RESET(writer_stream);
+               BT_STREAM_PUT_REF_AND_RESET(stream);
        }
 
        /* Check if the trace is already static or register a listener. */
@@ -752,34 +752,34 @@ struct debug_info_trace *insert_new_trace(struct debug_info_iterator *debug_it,
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_trace);
+       BT_TRACE_PUT_REF_AND_RESET(writer_trace);
        g_free(di_trace);
        di_trace = NULL;
 end:
-       bt_object_put_ref(stream);
-       bt_object_put_ref(writer_stream);
-       bt_object_put_ref(stream_class);
-       bt_object_put_ref(trace);
+       bt_stream_put_ref(stream);
+       bt_stream_put_ref(writer_stream);
+       bt_stream_class_put_ref(stream_class);
+       bt_trace_put_ref(trace);
        return di_trace;
 }
 
 static
-struct bt_packet *lookup_packet(struct debug_info_iterator *debug_it,
-               struct bt_packet *packet,
+const bt_packet *lookup_packet(struct debug_info_iterator *debug_it,
+               const bt_packet *packet,
                struct debug_info_trace *di_trace)
 {
-       return (struct bt_packet *) g_hash_table_lookup(
+       return (const bt_packet *) g_hash_table_lookup(
                        di_trace->packet_map,
                        (gpointer) packet);
 }
 
 static
-struct bt_packet *insert_new_packet(struct debug_info_iterator *debug_it,
-               struct bt_packet *packet,
-               struct bt_stream *writer_stream,
+const bt_packet *insert_new_packet(struct debug_info_iterator *debug_it,
+               const bt_packet *packet,
+               const bt_stream *writer_stream,
                struct debug_info_trace *di_trace)
 {
-       struct bt_packet *writer_packet;
+       const bt_packet *writer_packet;
        int ret;
 
        writer_packet = bt_packet_create(writer_stream);
@@ -799,17 +799,17 @@ struct bt_packet *insert_new_packet(struct debug_info_iterator *debug_it,
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_packet);
+       BT_PACKET_PUT_REF_AND_RESET(writer_packet);
 end:
        return writer_packet;
 }
 
 static
 int add_debug_info_fields(FILE *err,
-               struct bt_field_class *writer_event_context_class,
+               const bt_field_class *writer_event_context_class,
                struct debug_info_component *component)
 {
-       struct bt_field_class *ip_field = NULL, *debug_field_class = NULL,
+       const bt_field_class *ip_field = NULL, *debug_field_class = NULL,
                                 *bin_field_class = NULL, *func_field_class = NULL,
                                 *src_field_class = NULL;
        int ret = 0;
@@ -820,7 +820,7 @@ int add_debug_info_fields(FILE *err,
        if (!ip_field) {
                goto end;
        }
-       BT_OBJECT_PUT_REF_AND_RESET(ip_field);
+       BT_FIELD_CLASS_PUT_REF_AND_RESET(ip_field);
 
        debug_field_class = bt_field_class_structure_get_field_class_by_name(
                        writer_event_context_class,
@@ -886,27 +886,27 @@ int add_debug_info_fields(FILE *err,
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(debug_field_class);
+       BT_FIELD_CLASS_PUT_REF_AND_RESET(debug_field_class);
        ret = -1;
 end:
-       bt_object_put_ref(src_field_class);
-       bt_object_put_ref(func_field_class);
-       bt_object_put_ref(bin_field_class);
-       bt_object_put_ref(debug_field_class);
+       bt_field_class_put_ref(src_field_class);
+       bt_field_class_put_ref(func_field_class);
+       bt_field_class_put_ref(bin_field_class);
+       bt_field_class_put_ref(debug_field_class);
        return ret;
 }
 
 static
 int create_debug_info_event_context_class(FILE *err,
-               struct bt_field_class *event_context_class,
-               struct bt_field_class *writer_event_context_class,
+               const bt_field_class *event_context_class,
+               const bt_field_class *writer_event_context_class,
                struct debug_info_component *component)
 {
        int ret, nr_fields, i;
 
        nr_fields = bt_field_class_structure_get_field_count(event_context_class);
        for (i = 0; i < nr_fields; i++) {
-               struct bt_field_class *field_class = NULL;
+               const bt_field_class *field_class = NULL;
                const char *field_name;
 
                if (bt_field_class_structure_get_field_by_index(event_context_class,
@@ -918,7 +918,7 @@ int create_debug_info_event_context_class(FILE *err,
 
                ret = bt_field_class_structure_add_field(writer_event_context_class,
                                field_class, field_name);
-               BT_OBJECT_PUT_REF_AND_RESET(field_class);
+               BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class);
                if (ret) {
                        BT_LOGE("Failed to add a field to the event-context: field-name=\"%s\"",
                                        field_name);
@@ -937,14 +937,14 @@ end:
 }
 
 static
-struct bt_stream_class *copy_stream_class_debug_info(FILE *err,
-               struct bt_stream_class *stream_class,
-               struct bt_trace *writer_trace,
+const bt_stream_class *copy_stream_class_debug_info(FILE *err,
+               const bt_stream_class *stream_class,
+               const bt_trace *writer_trace,
                struct debug_info_component *component)
 {
-       struct bt_field_class *cls = NULL;
-       struct bt_stream_class *writer_stream_class = NULL;
-       struct bt_field_class *writer_event_context_class = NULL;
+       const bt_field_class *cls = NULL;
+       const bt_stream_class *writer_stream_class = NULL;
+       const bt_field_class *writer_event_context_class = NULL;
        int ret_int;
        const char *name = bt_stream_class_get_name(stream_class);
 
@@ -997,15 +997,15 @@ struct bt_stream_class *copy_stream_class_debug_info(FILE *err,
                        BT_LOGE_STR("Failed to set event_context type.");
                        goto error;
                }
-               BT_OBJECT_PUT_REF_AND_RESET(writer_event_context_class);
+               BT_FIELD_CLASS_PUT_REF_AND_RESET(writer_event_context_class);
        }
 
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class);
+       BT_STREAM_CLASS_PUT_REF_AND_RESET(writer_stream_class);
 end:
-       bt_object_put_ref(writer_event_context_class);
+       bt_field_class_put_ref(writer_event_context_class);
        bt_object_put_ref(type);
        return writer_stream_class;
 }
@@ -1016,31 +1016,31 @@ end:
  * to update the integers mapping to a clock.
  */
 static
-int add_clock_classes(FILE *err, struct bt_trace *writer_trace,
-               struct bt_stream_class *writer_stream_class,
-               struct bt_trace *trace)
+int add_clock_classes(FILE *err, const bt_trace *writer_trace,
+               const bt_stream_class *writer_stream_class,
+               const bt_trace *trace)
 {
        int ret, clock_class_count, i;
 
        clock_class_count = bt_trace_get_clock_class_count(trace);
 
        for (i = 0; i < clock_class_count; i++) {
-               struct bt_clock_class *clock_class =
+               const bt_clock_class *clock_class =
                        bt_trace_get_clock_class_by_index(trace, i);
-               struct bt_clock_class *existing_clock_class = NULL;
+               const bt_clock_class *existing_clock_class = NULL;
 
                BT_ASSERT(clock_class);
 
                existing_clock_class = bt_trace_get_clock_class_by_name(
                        writer_trace, bt_clock_class_get_name(clock_class));
-               bt_object_put_ref(existing_clock_class);
+               bt_clock_class_put_ref(existing_clock_class);
                if (existing_clock_class) {
-                       bt_object_put_ref(clock_class);
+                       bt_clock_class_put_ref(clock_class);
                        continue;
                }
 
                ret = bt_trace_add_clock_class(writer_trace, clock_class);
-               BT_OBJECT_PUT_REF_AND_RESET(clock_class);
+               BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class);
                if (ret != 0) {
                        BT_LOGE_STR("Failed to add clock_class.");
                        goto error;
@@ -1058,14 +1058,14 @@ end:
 }
 
 static
-struct bt_stream_class *insert_new_stream_class(
+const bt_stream_class *insert_new_stream_class(
                struct debug_info_iterator *debug_it,
-               struct bt_stream_class *stream_class)
+               const bt_stream_class *stream_class)
 {
-       struct bt_stream_class *writer_stream_class = NULL;
-       struct bt_trace *trace, *writer_trace = NULL;
+       const bt_stream_class *writer_stream_class = NULL;
+       const bt_trace *trace, *writer_trace = NULL;
        struct debug_info_trace *di_trace;
-       enum bt_component_status ret;
+       bt_component_status ret;
        int int_ret;
 
        trace = bt_stream_class_get_trace(stream_class);
@@ -1078,7 +1078,7 @@ struct bt_stream_class *insert_new_stream_class(
                goto error;
        }
        writer_trace = di_trace->writer_trace;
-       bt_object_get_ref(writer_trace);
+       bt_trace_get_ref(writer_trace);
 
        writer_stream_class = copy_stream_class_debug_info(debug_it->err, stream_class,
                        writer_trace, debug_it->debug_info_component);
@@ -1106,22 +1106,22 @@ struct bt_stream_class *insert_new_stream_class(
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class);
+       BT_STREAM_CLASS_PUT_REF_AND_RESET(writer_stream_class);
 end:
-       bt_object_put_ref(trace);
-       bt_object_put_ref(writer_trace);
+       bt_trace_put_ref(trace);
+       bt_trace_put_ref(writer_trace);
        return writer_stream_class;
 }
 
 static
-struct bt_stream *insert_new_stream(
+const bt_stream *insert_new_stream(
                struct debug_info_iterator *debug_it,
-               struct bt_stream *stream,
+               const bt_stream *stream,
                struct debug_info_trace *di_trace)
 {
-       struct bt_stream *writer_stream = NULL;
-       struct bt_stream_class *stream_class = NULL;
-       struct bt_stream_class *writer_stream_class = NULL;
+       const bt_stream *writer_stream = NULL;
+       const bt_stream_class *stream_class = NULL;
+       const bt_stream_class *writer_stream_class = NULL;
        int64_t id;
 
        stream_class = bt_stream_get_class(stream);
@@ -1139,7 +1139,7 @@ struct bt_stream *insert_new_stream(
                        goto error;
                }
        }
-       bt_object_get_ref(writer_stream_class);
+       bt_stream_class_get_ref(writer_stream_class);
 
        id = bt_stream_get_id(stream);
        if (id < 0) {
@@ -1162,26 +1162,26 @@ struct bt_stream *insert_new_stream(
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
+       BT_STREAM_PUT_REF_AND_RESET(writer_stream);
 end:
-       bt_object_put_ref(stream_class);
-       bt_object_put_ref(writer_stream_class);
+       bt_stream_class_put_ref(stream_class);
+       bt_stream_class_put_ref(writer_stream_class);
        return writer_stream;
 }
 
 static
-struct bt_stream *lookup_stream(struct debug_info_iterator *debug_it,
-               struct bt_stream *stream,
+const bt_stream *lookup_stream(struct debug_info_iterator *debug_it,
+               const bt_stream *stream,
                struct debug_info_trace *di_trace)
 {
-       return (struct bt_stream *) g_hash_table_lookup(
+       return (const bt_stream *) g_hash_table_lookup(
                        di_trace->stream_map, (gpointer) stream);
 }
 
 static
-struct bt_event_class *get_event_class(struct debug_info_iterator *debug_it,
-               struct bt_stream_class *writer_stream_class,
-               struct bt_event_class *event_class)
+const bt_event_class *get_event_class(struct debug_info_iterator *debug_it,
+               const bt_stream_class *writer_stream_class,
+               const bt_event_class *event_class)
 {
        return bt_stream_class_get_event_class_by_id(writer_stream_class,
                        bt_event_class_get_id(event_class));
@@ -1190,10 +1190,10 @@ struct bt_event_class *get_event_class(struct debug_info_iterator *debug_it,
 static
 struct debug_info_trace *lookup_di_trace_from_stream(
                struct debug_info_iterator *debug_it,
-               struct bt_stream *stream)
+               const bt_stream *stream)
 {
-       struct bt_stream_class *stream_class = NULL;
-       struct bt_trace *trace = NULL;
+       const bt_stream_class *stream_class = NULL;
+       const bt_trace *trace = NULL;
        struct debug_info_trace *di_trace = NULL;
 
        stream_class = bt_stream_get_class(stream);
@@ -1205,18 +1205,18 @@ struct debug_info_trace *lookup_di_trace_from_stream(
        di_trace = (struct debug_info_trace *) g_hash_table_lookup(
                        debug_it->trace_map, (gpointer) trace);
 
-       BT_OBJECT_PUT_REF_AND_RESET(stream_class);
-       BT_OBJECT_PUT_REF_AND_RESET(trace);
+       BT_STREAM_CLASS_PUT_REF_AND_RESET(stream_class);
+       BT_TRACE_PUT_REF_AND_RESET(trace);
        return di_trace;
 }
 
 static
-struct bt_stream *get_writer_stream(
+const bt_stream *get_writer_stream(
                struct debug_info_iterator *debug_it,
-               struct bt_packet *packet, struct bt_stream *stream)
+               const bt_packet *packet, const bt_stream *stream)
 {
-       struct bt_stream_class *stream_class = NULL;
-       struct bt_stream *writer_stream = NULL;
+       const bt_stream_class *stream_class = NULL;
+       const bt_stream *writer_stream = NULL;
        struct debug_info_trace *di_trace = NULL;
 
        stream_class = bt_stream_get_class(stream);
@@ -1233,25 +1233,25 @@ struct bt_stream *get_writer_stream(
                BT_LOGE_STR("Failed to find existing stream.");
                goto error;
        }
-       bt_object_get_ref(writer_stream);
+       bt_stream_get_ref(writer_stream);
 
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
+       BT_STREAM_PUT_REF_AND_RESET(writer_stream);
 end:
-       bt_object_put_ref(stream_class);
+       bt_stream_class_put_ref(stream_class);
        return writer_stream;
 }
 
 BT_HIDDEN
-struct bt_packet *debug_info_new_packet(
+const bt_packet *debug_info_new_packet(
                struct debug_info_iterator *debug_it,
-               struct bt_packet *packet)
+               const bt_packet *packet)
 {
-       struct bt_stream *stream = NULL, *writer_stream = NULL;
-       struct bt_packet *writer_packet = NULL;
-       struct bt_field *packet_context = NULL;
+       const bt_stream *stream = NULL, *writer_stream = NULL;
+       const bt_packet *writer_packet = NULL;
+       const bt_field *packet_context = NULL;
        struct debug_info_trace *di_trace;
        int int_ret;
 
@@ -1277,7 +1277,7 @@ struct bt_packet *debug_info_new_packet(
        writer_packet = lookup_packet(debug_it, packet, di_trace);
        if (writer_packet) {
                g_hash_table_remove(di_trace->packet_map, packet);
-               BT_OBJECT_PUT_REF_AND_RESET(writer_packet);
+               BT_PACKET_PUT_REF_AND_RESET(writer_packet);
        }
 
        writer_packet = insert_new_packet(debug_it, packet, writer_stream,
@@ -1298,25 +1298,25 @@ struct bt_packet *debug_info_new_packet(
                BT_OBJECT_PUT_REF_AND_RESET(packet_context);
        }
 
-       bt_object_get_ref(writer_packet);
+       bt_packet_get_ref(writer_packet);
        goto end;
 
 error:
 
 end:
        bt_object_put_ref(packet_context);
-       bt_object_put_ref(writer_stream);
-       bt_object_put_ref(stream);
+       bt_stream_put_ref(writer_stream);
+       bt_stream_put_ref(stream);
        return writer_packet;
 }
 
 BT_HIDDEN
-struct bt_packet *debug_info_close_packet(
+const bt_packet *debug_info_close_packet(
                struct debug_info_iterator *debug_it,
-               struct bt_packet *packet)
+               const bt_packet *packet)
 {
-       struct bt_packet *writer_packet = NULL;
-       struct bt_stream *stream = NULL;
+       const bt_packet *writer_packet = NULL;
+       const bt_stream *stream = NULL;
        struct debug_info_trace *di_trace;
 
        stream = bt_packet_get_stream(packet);
@@ -1333,20 +1333,20 @@ struct bt_packet *debug_info_close_packet(
                BT_LOGE_STR("Failed to find existing packet.");
                goto end;
        }
-       bt_object_get_ref(writer_packet);
+       bt_packet_get_ref(writer_packet);
        g_hash_table_remove(di_trace->packet_map, packet);
 
 end:
-       bt_object_put_ref(stream);
+       bt_stream_put_ref(stream);
        return writer_packet;
 }
 
 BT_HIDDEN
-struct bt_stream *debug_info_stream_begin(
+const bt_stream *debug_info_stream_begin(
                struct debug_info_iterator *debug_it,
-               struct bt_stream *stream)
+               const bt_stream *stream)
 {
-       struct bt_stream *writer_stream = NULL;
+       const bt_stream *writer_stream = NULL;
        enum debug_info_stream_state *state;
        struct debug_info_trace *di_trace = NULL;
 
@@ -1383,21 +1383,21 @@ struct bt_stream *debug_info_stream_begin(
        if (!writer_stream) {
                writer_stream = insert_new_stream(debug_it, stream, di_trace);
        }
-       bt_object_get_ref(writer_stream);
+       bt_stream_get_ref(writer_stream);
 
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
+       BT_STREAM_PUT_REF_AND_RESET(writer_stream);
 end:
        return writer_stream;
 }
 
 BT_HIDDEN
-struct bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_it,
-               struct bt_stream *stream)
+const bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_it,
+               const bt_stream *stream)
 {
-       struct bt_stream *writer_stream = NULL;
+       const bt_stream *writer_stream = NULL;
        struct debug_info_trace *di_trace = NULL;
        enum debug_info_stream_state *state;
 
@@ -1413,10 +1413,10 @@ struct bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_it,
                goto error;
        }
        /*
-        * Take the ref on the stream and keep it until the notification
+        * Take the ref on the stream and keep it until the message
         * is created.
         */
-       bt_object_get_ref(writer_stream);
+       bt_stream_get_ref(writer_stream);
 
        state = g_hash_table_lookup(di_trace->stream_states, stream);
        if (*state != DEBUG_INFO_ACTIVE_STREAM) {
@@ -1442,7 +1442,7 @@ struct bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_it,
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
+       BT_STREAM_PUT_REF_AND_RESET(writer_stream);
 
 end:
        return writer_stream;
@@ -1450,7 +1450,7 @@ end:
 
 static
 struct debug_info_source *lookup_debug_info(FILE *err,
-               struct bt_event *event,
+               const bt_event *event,
                struct debug_info *debug_info)
 {
        int64_t vpid;
@@ -1478,14 +1478,14 @@ end:
 }
 
 static
-int set_debug_info_field(FILE *err, struct bt_field *debug_field,
+int set_debug_info_field(FILE *err, const bt_field *debug_field,
                struct debug_info_source *dbg_info_src,
                struct debug_info_component *component)
 {
        int i, nr_fields, ret = 0;
-       struct bt_field_class *debug_field_class = NULL;
-       struct bt_field *field = NULL;
-       struct bt_field_class *field_class = NULL;
+       const bt_field_class *debug_field_class = NULL;
+       const bt_field *field = NULL;
+       const bt_field_class *field_class = NULL;
 
        debug_field_class = bt_field_get_class(debug_field);
        BT_ASSERT(debug_field_class);
@@ -1500,7 +1500,7 @@ int set_debug_info_field(FILE *err, struct bt_field *debug_field,
                                        field_name);
                        goto error;
                }
-               BT_OBJECT_PUT_REF_AND_RESET(field_class);
+               BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class);
 
                field = bt_field_structure_get_field_by_index(debug_field, i);
                if (!strcmp(field_name, "bin")) {
@@ -1560,25 +1560,25 @@ int set_debug_info_field(FILE *err, struct bt_field *debug_field,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        bt_object_put_ref(field);
-       bt_object_put_ref(debug_field_class);
+       bt_field_class_put_ref(debug_field_class);
        return ret;
 }
 
 static
 int copy_set_debug_info_stream_event_context(FILE *err,
-               struct bt_field *event_context,
-               struct bt_event *event,
-               struct bt_event *writer_event,
+               const bt_field *event_context,
+               const bt_event *event,
+               const bt_event *writer_event,
                struct debug_info *debug_info,
                struct debug_info_component *component)
 {
-       struct bt_field_class *writer_event_context_class = NULL,
+       const bt_field_class *writer_event_context_class = NULL,
                                 *event_context_class = NULL;
-       struct bt_field *writer_event_context = NULL;
-       struct bt_field *field = NULL, *copy_field = NULL, *debug_field = NULL;
-       struct bt_field_class *field_class = NULL;
+       const bt_field *writer_event_context = NULL;
+       const bt_field *field = NULL, *copy_field = NULL, *debug_field = NULL;
+       const bt_field_class *field_class = NULL;
        struct debug_info_source *dbg_info_src;
        int ret, nr_fields, i;
 
@@ -1654,7 +1654,7 @@ int copy_set_debug_info_stream_event_context(FILE *err,
                        }
                        BT_OBJECT_PUT_REF_AND_RESET(copy_field);
                }
-               BT_OBJECT_PUT_REF_AND_RESET(field_class);
+               BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class);
                BT_OBJECT_PUT_REF_AND_RESET(field);
        }
 
@@ -1664,22 +1664,22 @@ int copy_set_debug_info_stream_event_context(FILE *err,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(event_context_class);
-       bt_object_put_ref(writer_event_context_class);
+       bt_field_class_put_ref(event_context_class);
+       bt_field_class_put_ref(writer_event_context_class);
        bt_object_put_ref(writer_event_context);
        bt_object_put_ref(field);
        bt_object_put_ref(copy_field);
        bt_object_put_ref(debug_field);
-       bt_object_put_ref(field_class);
+       bt_field_class_put_ref(field_class);
        return ret;
 }
 
 static
-struct bt_clock_class *stream_class_get_clock_class(FILE *err,
-               struct bt_stream_class *stream_class)
+const bt_clock_class *stream_class_get_clock_class(FILE *err,
+               const bt_stream_class *stream_class)
 {
-       struct bt_trace *trace = NULL;
-       struct bt_clock_class *clock_class = NULL;
+       const bt_trace *trace = NULL;
+       const bt_clock_class *clock_class = NULL;
 
        trace = bt_stream_class_get_trace(stream_class);
        BT_ASSERT(trace);
@@ -1692,18 +1692,18 @@ struct bt_clock_class *stream_class_get_clock_class(FILE *err,
        /* FIXME multi-clock? */
        clock_class = bt_trace_get_clock_class_by_index(trace, 0);
 
-       bt_object_put_ref(trace);
+       bt_trace_put_ref(trace);
 
 end:
        return clock_class;
 }
 
 static
-struct bt_clock_class *event_get_clock_class(FILE *err, struct bt_event *event)
+const bt_clock_class *event_get_clock_class(FILE *err, const bt_event *event)
 {
-       struct bt_event_class *event_class = NULL;
-       struct bt_stream_class *stream_class = NULL;
-       struct bt_clock_class *clock_class = NULL;
+       const bt_event_class *event_class = NULL;
+       const bt_stream_class *stream_class = NULL;
+       const bt_clock_class *clock_class = NULL;
 
        event_class = bt_event_get_class(event);
        BT_ASSERT(event_class);
@@ -1715,17 +1715,17 @@ struct bt_clock_class *event_get_clock_class(FILE *err, struct bt_event *event)
        goto end;
 
 end:
-       bt_object_put_ref(stream_class);
-       bt_object_put_ref(event_class);
+       bt_stream_class_put_ref(stream_class);
+       bt_event_class_put_ref(event_class);
        return clock_class;
 }
 
 static
-int set_event_clock_value(FILE *err, struct bt_event *event,
-               struct bt_event *writer_event)
+int set_event_clock_snapshot(FILE *err, const bt_event *event,
+               const bt_event *writer_event)
 {
-       struct bt_clock_class *clock_class = NULL;
-       struct bt_clock_value *clock_value = NULL;
+       const bt_clock_class *clock_class = NULL;
+       bt_clock_snapshot *clock_snapshot = NULL;
        int ret = 0;
 
        clock_class = event_get_clock_class(err, event);
@@ -1734,8 +1734,8 @@ int set_event_clock_value(FILE *err, struct bt_event *event,
                goto end;
        }
 
-       clock_value = bt_event_get_clock_value(event, clock_class);
-       if (!clock_value) {
+       clock_snapshot = bt_event_get_clock_snapshot(event, clock_class);
+       if (!clock_snapshot) {
                ret = 0;
                goto end;
        }
@@ -1744,7 +1744,7 @@ int set_event_clock_value(FILE *err, struct bt_event *event,
         * We share the same clocks, so we can assign the clock value to the
         * writer event.
         */
-       ret = bt_event_set_clock_value(writer_event, clock_value);
+       ret = bt_event_set_clock_snapshot(writer_event, clock_snapshot);
        if (ret) {
                BT_LOGE_STR("Failed to set clock value.");
                goto error;
@@ -1756,19 +1756,19 @@ int set_event_clock_value(FILE *err, struct bt_event *event,
 error:
        ret = -1;
 end:
-       bt_object_put_ref(clock_class);
-       bt_object_put_ref(clock_value);
+       bt_clock_class_put_ref(clock_class);
+       bt_object_put_ref(clock_snapshot);
        return ret;
 }
 
 static
-struct bt_event *debug_info_copy_event(FILE *err, struct bt_event *event,
-               struct bt_event_class *writer_event_class,
+const bt_event *debug_info_copy_event(FILE *err, const bt_event *event,
+               const bt_event_class *writer_event_class,
                struct debug_info *debug_info,
                struct debug_info_component *component)
 {
-       struct bt_event *writer_event = NULL;
-       struct bt_field *field = NULL, *copy_field = NULL;
+       const bt_event *writer_event = NULL;
+       const bt_field *field = NULL, *copy_field = NULL;
        int ret;
 
        writer_event = bt_event_create(writer_event_class);
@@ -1777,7 +1777,7 @@ struct bt_event *debug_info_copy_event(FILE *err, struct bt_event *event,
                goto error;
        }
 
-       ret = set_event_clock_value(err, event, writer_event);
+       ret = set_event_clock_snapshot(err, event, writer_event);
        if (ret) {
                BT_LOGE_STR("Failed to set clock value.");
                goto error;
@@ -1850,16 +1850,16 @@ end:
 }
 
 BT_HIDDEN
-struct bt_event *debug_info_output_event(
+const bt_event *debug_info_output_event(
                struct debug_info_iterator *debug_it,
-               struct bt_event *event)
+               const bt_event *event)
 {
-       struct bt_event_class *event_class = NULL, *writer_event_class = NULL;
-       struct bt_stream_class *stream_class = NULL, *writer_stream_class = NULL;
-       struct bt_event *writer_event = NULL;
-       struct bt_packet *packet = NULL, *writer_packet = NULL;
-       struct bt_trace *writer_trace = NULL;
-       struct bt_stream *stream = NULL;
+       const bt_event_class *event_class = NULL, *writer_event_class = NULL;
+       const bt_stream_class *stream_class = NULL, *writer_stream_class = NULL;
+       const bt_event *writer_event = NULL;
+       const bt_packet *packet = NULL, *writer_packet = NULL;
+       const bt_trace *writer_trace = NULL;
+       const bt_stream *stream = NULL;
        struct debug_info_trace *di_trace;
        struct debug_info *debug_info;
        int int_ret;
@@ -1886,7 +1886,7 @@ struct bt_event *debug_info_output_event(
                BT_LOGE_STR("Failed to find existing stream_class.");
                goto error;
        }
-       bt_object_get_ref(writer_stream_class);
+       bt_stream_class_get_ref(writer_stream_class);
        writer_trace = bt_stream_class_get_trace(writer_stream_class);
        BT_ASSERT(writer_trace);
        writer_event_class = get_event_class(debug_it,
@@ -1928,7 +1928,7 @@ struct bt_event *debug_info_output_event(
                BT_LOGE_STR("Failed to find existing packet.");
                goto error;
        }
-       bt_object_get_ref(writer_packet);
+       bt_packet_get_ref(writer_packet);
 
        int_ret = bt_event_set_packet(writer_event, writer_packet);
        if (int_ret < 0) {
@@ -1944,13 +1944,13 @@ error:
        BT_OBJECT_PUT_REF_AND_RESET(writer_event);
 
 end:
-       bt_object_put_ref(stream);
-       bt_object_put_ref(writer_trace);
-       bt_object_put_ref(writer_packet);
-       bt_object_put_ref(packet);
-       bt_object_put_ref(writer_event_class);
-       bt_object_put_ref(writer_stream_class);
-       bt_object_put_ref(stream_class);
-       bt_object_put_ref(event_class);
+       bt_stream_put_ref(stream);
+       bt_trace_put_ref(writer_trace);
+       bt_packet_put_ref(writer_packet);
+       bt_packet_put_ref(packet);
+       bt_event_class_put_ref(writer_event_class);
+       bt_stream_class_put_ref(writer_stream_class);
+       bt_stream_class_put_ref(stream_class);
+       bt_event_class_put_ref(event_class);
        return writer_event;
 }
This page took 0.046884 seconds and 4 git commands to generate.