X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Ftrace-ir%2Ftrace.c;h=d2b58899a2d74761effad899b5e598307b8ca62e;hb=05e2128659970c32648a01255ed870449f05d518;hp=5c0546fe7e84ed273e59a2beb91b7d09f7491100;hpb=e5be10efe4d5543ba697c7e607ca0a5c33fa3ccb;p=babeltrace.git diff --git a/lib/trace-ir/trace.c b/lib/trace-ir/trace.c index 5c0546fe..d2b58899 100644 --- a/lib/trace-ir/trace.c +++ b/lib/trace-ir/trace.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -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 @@ -253,7 +261,7 @@ bool trace_has_environment_entry(struct bt_trace *trace, const char *name) static int set_environment_entry(struct bt_trace *trace, const char *name, - struct bt_private_value *value) + struct bt_value *value) { int ret; @@ -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(value); if (ret) { BT_LIB_LOGE("Cannot set trace's environment entry: " "%![trace-]+t, entry-name=\"%s\"", trace, name); @@ -278,18 +286,18 @@ 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) { int ret; - struct bt_private_value *value_obj; + struct bt_value *value_obj; struct bt_trace *trace = (void *) priv_trace; BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_NON_NULL(value, "Value"); - value_obj = bt_private_value_string_create_init(value); + value_obj = bt_value_string_create_init(value); if (!value_obj) { BT_LOGE_STR("Cannot create a string value object."); ret = -1; @@ -304,17 +312,17 @@ 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) { int ret; - struct bt_private_value *value_obj; + struct bt_value *value_obj; struct bt_trace *trace = (void *) priv_trace; BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); - value_obj = bt_private_value_integer_create_init(value); + value_obj = bt_value_integer_create_init(value); if (!value_obj) { BT_LOGE_STR("Cannot create an integer value object."); ret = -1; @@ -341,40 +349,38 @@ uint64_t bt_trace_get_environment_entry_count(struct bt_trace *trace) void bt_trace_borrow_environment_entry_by_index( struct bt_trace *trace, uint64_t index, - const char **name, struct bt_value **value) + const char **name, const struct bt_value **value) { BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); 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( - bt_attributes_borrow_field_value(trace->environment, index)); + *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) + const char **name, const struct bt_value **value) { bt_trace_borrow_environment_entry_by_index((void *) trace, index, name, (void *) value); } -struct bt_value *bt_trace_borrow_environment_entry_value_by_name( +const struct bt_value *bt_trace_borrow_environment_entry_value_by_name( struct bt_trace *trace, const char *name) { BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); - return bt_value_borrow_from_private( - bt_attributes_borrow_field_value_by_name(trace->environment, - name)); + return bt_attributes_borrow_field_value_by_name(trace->environment, + name); } -struct bt_private_value * -bt_private_trace_borrow_private_environment_entry_value_by_name( +const struct bt_value * +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 +401,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 +450,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 +480,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 +493,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) { @@ -517,7 +523,8 @@ int bt_private_trace_set_packet_header_private_field_class( bt_field_class_make_part_of_trace(field_class); bt_object_put_ref(trace->packet_header_fc); - trace->packet_header_fc = bt_object_get_ref(field_class); + trace->packet_header_fc = field_class; + bt_object_get_no_null_check(trace->packet_header_fc); bt_field_class_freeze(field_class); BT_LIB_LOGV("Set trace's packet header field classe: %!+t", trace); @@ -667,7 +674,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 +684,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