lib: trace IR, values: reset pointers to `NULL` on destruction
[babeltrace.git] / lib / trace-ir / trace.c
index 2c572f67064dbe38a06e873248e76fc6d52fe819..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);
@@ -348,7 +356,7 @@ 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);
@@ -368,7 +376,7 @@ 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));
 }
@@ -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.025222 seconds and 4 git commands to generate.