lib: trace IR, values: reset pointers to `NULL` on destruction
[babeltrace.git] / lib / trace-ir / trace.c
index 5c0546fe7e84ed273e59a2beb91b7d09f7491100..f5c66cb8332d22087d6ac4f1a0e5ccbd77542bde 100644 (file)
@@ -89,6 +89,7 @@ void destroy_trace(struct bt_object *obj)
                }
 
                g_array_free(trace->is_static_listeners, TRUE);
+               trace->is_static_listeners = NULL;
        }
 
        bt_object_pool_finalize(&trace->packet_header_field_pool);
@@ -96,28 +97,35 @@ void destroy_trace(struct bt_object *obj)
        if (trace->environment) {
                BT_LOGD_STR("Destroying environment attributes.");
                bt_attributes_destroy(trace->environment);
+               trace->environment = NULL;
        }
 
        if (trace->name.str) {
                g_string_free(trace->name.str, TRUE);
+               trace->name.str = NULL;
+               trace->name.value = NULL;
        }
 
        if (trace->streams) {
                BT_LOGD_STR("Destroying streams.");
                g_ptr_array_free(trace->streams, TRUE);
+               trace->streams = NULL;
        }
 
        if (trace->stream_classes) {
                BT_LOGD_STR("Destroying stream classes.");
                g_ptr_array_free(trace->stream_classes, TRUE);
+               trace->stream_classes = NULL;
        }
 
        if (trace->stream_classes_stream_count) {
                g_hash_table_destroy(trace->stream_classes_stream_count);
+               trace->stream_classes_stream_count = NULL;
        }
 
        BT_LOGD_STR("Putting packet header field classe.");
        bt_object_put_ref(trace->packet_header_fc);
+       trace->packet_header_fc = NULL;
        g_free(trace);
 }
 
@@ -228,7 +236,8 @@ bt_uuid bt_trace_get_uuid(struct bt_trace *trace)
        return trace->uuid.value;
 }
 
-int bt_private_trace_set_uuid(struct bt_private_trace *priv_trace, bt_uuid uuid)
+void bt_private_trace_set_uuid(struct bt_private_trace *priv_trace,
+               bt_uuid uuid)
 {
        struct bt_trace *trace = (void *) priv_trace;
 
@@ -238,7 +247,6 @@ int bt_private_trace_set_uuid(struct bt_private_trace *priv_trace, bt_uuid uuid)
        memcpy(trace->uuid.uuid, uuid, BABELTRACE_UUID_LEN);
        trace->uuid.value = trace->uuid.uuid;
        BT_LIB_LOGV("Set trace's UUID: %!+t", trace);
-       return 0;
 }
 
 BT_ASSERT_FUNC
@@ -266,7 +274,7 @@ int set_environment_entry(struct bt_trace *trace, const char *name,
                "%![trace-]+t, entry-name=\"%s\"", trace, name);
        ret = bt_attributes_set_field_value(trace->environment, name,
                value);
-       bt_value_freeze(bt_value_borrow_from_private(value));
+       bt_value_freeze(bt_private_value_borrow_value(value));
        if (ret) {
                BT_LIB_LOGE("Cannot set trace's environment entry: "
                        "%![trace-]+t, entry-name=\"%s\"", trace, name);
@@ -278,7 +286,7 @@ int set_environment_entry(struct bt_trace *trace, const char *name,
        return ret;
 }
 
-int bt_private_trace_set_private_environment_entry_string(
+int bt_private_trace_set_environment_entry_string(
                struct bt_private_trace *priv_trace,
                const char *name, const char *value)
 {
@@ -304,7 +312,7 @@ end:
        return ret;
 }
 
-int bt_private_trace_set_private_environment_entry_integer(
+int bt_private_trace_set_environment_entry_integer(
                struct bt_private_trace *priv_trace,
                const char *name, int64_t value)
 {
@@ -348,14 +356,14 @@ void bt_trace_borrow_environment_entry_by_index(
        BT_ASSERT_PRE_NON_NULL(value, "Value");
        BT_ASSERT_PRE_VALID_INDEX(index,
                bt_attributes_get_count(trace->environment));
-       *value = bt_value_borrow_from_private(
+       *value = bt_private_value_borrow_value(
                bt_attributes_borrow_field_value(trace->environment, index));
        BT_ASSERT(*value);
        *name = bt_attributes_get_field_name(trace->environment, index);
        BT_ASSERT(*name);
 }
 
-void bt_private_trace_borrow_private_environment_entry_by_index(
+void bt_private_trace_borrow_environment_entry_by_index(
                struct bt_private_trace *trace, uint64_t index,
                const char **name, struct bt_private_value **value)
 {
@@ -368,13 +376,13 @@ struct bt_value *bt_trace_borrow_environment_entry_value_by_name(
 {
        BT_ASSERT_PRE_NON_NULL(trace, "Trace");
        BT_ASSERT_PRE_NON_NULL(name, "Name");
-       return bt_value_borrow_from_private(
+       return bt_private_value_borrow_value(
                bt_attributes_borrow_field_value_by_name(trace->environment,
                        name));
 }
 
 struct bt_private_value *
-bt_private_trace_borrow_private_environment_entry_value_by_name(
+bt_private_trace_borrow_environment_entry_value_by_name(
                struct bt_private_trace *trace, const char *name)
 {
        return (void *) bt_trace_borrow_environment_entry_value_by_name(
@@ -395,7 +403,7 @@ struct bt_stream *bt_trace_borrow_stream_by_index(
        return g_ptr_array_index(trace->streams, index);
 }
 
-struct bt_private_stream *bt_private_trace_borrow_private_stream_by_index(
+struct bt_private_stream *bt_private_trace_borrow_stream_by_index(
                struct bt_private_trace *trace, uint64_t index)
 {
        return (void *) bt_trace_borrow_stream_by_index((void *) trace, index);
@@ -444,7 +452,7 @@ struct bt_stream_class *bt_trace_borrow_stream_class_by_index(
 }
 
 struct bt_private_stream_class *
-bt_private_trace_borrow_private_stream_class_by_index(
+bt_private_trace_borrow_stream_class_by_index(
                struct bt_private_trace *trace, uint64_t index)
 {
        return (void *) bt_trace_borrow_stream_class_by_index(
@@ -474,7 +482,7 @@ end:
 }
 
 struct bt_private_stream_class *
-bt_private_trace_borrow_private_stream_class_by_id(
+bt_private_trace_borrow_stream_class_by_id(
                struct bt_private_trace *trace, uint64_t id)
 {
        return (void *) bt_trace_borrow_stream_class_by_id((void *) trace, id);
@@ -487,7 +495,7 @@ struct bt_field_class *bt_trace_borrow_packet_header_field_class(
        return trace->packet_header_fc;
 }
 
-int bt_private_trace_set_packet_header_private_field_class(
+int bt_private_trace_set_packet_header_field_class(
                struct bt_private_trace *priv_trace,
                struct bt_private_field_class *priv_field_class)
 {
@@ -667,7 +675,7 @@ bt_bool bt_trace_assigns_automatic_stream_class_id(struct bt_trace *trace)
        return (bt_bool) trace->assigns_automatic_stream_class_id;
 }
 
-int bt_private_trace_set_assigns_automatic_stream_class_id(
+void bt_private_trace_set_assigns_automatic_stream_class_id(
                struct bt_private_trace *priv_trace, bt_bool value)
 {
        struct bt_trace *trace = (void *) priv_trace;
@@ -677,7 +685,6 @@ int bt_private_trace_set_assigns_automatic_stream_class_id(
        trace->assigns_automatic_stream_class_id = (bool) value;
        BT_LIB_LOGV("Set trace's automatic stream class ID "
                "assignment property: %!+t", trace);
-       return 0;
 }
 
 BT_HIDDEN
This page took 0.026077 seconds and 4 git commands to generate.