From 65300d60e4b4f167e5fc8f584677757ce09a3844 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 15 Nov 2018 15:44:29 -0500 Subject: [PATCH] Rename: bt_put(), bt_get() -> bt_object_put_ref(), bt_object_get_ref() Because those function apply to any (shared) Babeltrace object, let's put them under the `bt_object` namespace and make it clear what we're putting and getting. Also, reference counting macros are renamed: * BT_PUT() -> BT_OBJECT_PUT_REF_AND_RESET() * BT_MOVE() -> BT_OBJECT_MOVE_REF() Signed-off-by: Philippe Proulx --- cli/babeltrace-cfg-cli-args-connect.c | 18 +- cli/babeltrace-cfg-cli-args-default.c | 4 +- cli/babeltrace-cfg-cli-args.c | 120 +++--- cli/babeltrace-cfg-cli-args.h | 2 +- cli/babeltrace-cfg.h | 4 +- cli/babeltrace.c | 92 ++--- include/Makefile.am | 2 +- include/babeltrace/babeltrace.h | 2 +- include/babeltrace/ctf-writer/clock.h | 6 +- .../ctf-writer/event-class-internal.h | 8 +- include/babeltrace/ctf-writer/event-fields.h | 8 +- .../babeltrace/ctf-writer/event-internal.h | 2 +- include/babeltrace/ctf-writer/event-types.h | 8 +- include/babeltrace/ctf-writer/event.h | 10 +- .../babeltrace/ctf-writer/fields-internal.h | 4 +- .../ctf-writer/stream-class-internal.h | 12 +- include/babeltrace/ctf-writer/stream-class.h | 6 +- include/babeltrace/ctf-writer/stream.h | 4 +- include/babeltrace/ctf-writer/visitor.h | 6 +- include/babeltrace/ctf-writer/writer.h | 4 +- include/babeltrace/graph/component.h | 6 +- include/babeltrace/graph/notification-event.h | 4 +- .../babeltrace/graph/notification-iterator.h | 4 +- .../babeltrace/graph/notification-packet.h | 8 +- .../babeltrace/graph/notification-stream.h | 8 +- include/babeltrace/{ref.h => object.h} | 62 ++-- include/babeltrace/plugin/plugin-internal.h | 10 +- include/babeltrace/trace-ir/event-internal.h | 2 +- include/babeltrace/trace-ir/field-classes.h | 4 +- include/babeltrace/values.h | 10 +- lib/Makefile.am | 2 +- lib/ctf-writer/attributes.c | 6 +- lib/ctf-writer/clock-class.c | 4 +- lib/ctf-writer/clock.c | 6 +- lib/ctf-writer/event-class.c | 18 +- lib/ctf-writer/event.c | 52 +-- lib/ctf-writer/field-path.c | 2 +- lib/ctf-writer/field-types.c | 128 +++---- lib/ctf-writer/fields.c | 46 +-- lib/ctf-writer/resolve.c | 34 +- lib/ctf-writer/stream-class.c | 64 ++-- lib/ctf-writer/stream.c | 108 +++--- lib/ctf-writer/trace.c | 42 +-- lib/ctf-writer/utils.c | 2 +- lib/ctf-writer/validation.c | 96 ++--- lib/ctf-writer/visitor.c | 4 +- lib/ctf-writer/writer.c | 22 +- lib/graph/component-class-sink-colander.c | 12 +- lib/graph/component-class.c | 4 +- lib/graph/component.c | 26 +- lib/graph/connection.c | 16 +- lib/graph/filter.c | 4 +- lib/graph/graph.c | 22 +- lib/graph/iterator.c | 46 +-- lib/graph/notification/event.c | 2 +- lib/graph/notification/inactivity.c | 2 +- lib/graph/notification/packet.c | 10 +- lib/graph/notification/stream.c | 8 +- lib/graph/port.c | 6 +- lib/graph/query-executor.c | 10 +- lib/graph/sink.c | 2 +- lib/graph/source.c | 4 +- lib/{ref.c => object.c} | 6 +- lib/plugin/plugin-so.c | 52 +-- lib/plugin/plugin.c | 32 +- lib/trace-ir/attributes.c | 6 +- lib/trace-ir/clock-class.c | 4 +- lib/trace-ir/clock-value.c | 12 +- lib/trace-ir/event-class.c | 16 +- lib/trace-ir/event.c | 6 +- lib/trace-ir/field-classes.c | 32 +- lib/trace-ir/field-path.c | 2 +- lib/trace-ir/fields.c | 16 +- lib/trace-ir/packet.c | 10 +- lib/trace-ir/resolve-field-path.c | 6 +- lib/trace-ir/stream-class.c | 28 +- lib/trace-ir/stream.c | 4 +- lib/trace-ir/trace.c | 14 +- lib/trace-ir/utils.c | 2 +- lib/values.c | 54 +-- plugins/ctf/common/bfcr/bfcr.c | 2 +- .../ctf/common/metadata/ctf-meta-translate.c | 24 +- .../ctf-meta-update-default-clock-classes.c | 2 +- plugins/ctf/common/metadata/ctf-meta.h | 10 +- .../ctf/common/metadata/visitor-generate-ir.c | 18 +- plugins/ctf/common/notif-iter/notif-iter.c | 32 +- plugins/ctf/fs-sink/write.c | 82 ++--- plugins/ctf/fs-sink/writer.c | 24 +- plugins/ctf/fs-src/data-stream-file.c | 6 +- plugins/ctf/fs-src/fs.c | 12 +- plugins/ctf/fs-src/metadata.c | 2 +- plugins/ctf/fs-src/query.c | 20 +- plugins/ctf/lttng-live/data-stream.c | 4 +- plugins/ctf/lttng-live/lttng-live.c | 56 +-- plugins/ctf/lttng-live/metadata.c | 6 +- plugins/ctf/lttng-live/viewer-connection.c | 22 +- plugins/libctfcopytrace/clock-fields.c | 80 ++-- plugins/libctfcopytrace/ctfcopytrace.c | 118 +++--- plugins/lttng-utils/copy.c | 246 ++++++------- plugins/lttng-utils/debug-info.c | 2 +- plugins/lttng-utils/plugin.c | 48 +-- plugins/text/dmesg/dmesg.c | 28 +- plugins/text/pretty/pretty.c | 12 +- plugins/utils/counter/counter.c | 10 +- plugins/utils/dummy/dummy.c | 8 +- plugins/utils/muxer/muxer.c | 30 +- plugins/utils/trimmer/copy.c | 40 +- plugins/utils/trimmer/iterator.c | 58 +-- plugins/utils/trimmer/trimmer.c | 6 +- .../python-plugin-provider.c | 8 +- tests/lib/test-plugin-plugins/sfs.c | 2 +- tests/lib/test_bt_notification_iterator.c | 50 +-- tests/lib/test_bt_values.c | 100 ++--- tests/lib/test_ctf_writer.c | 346 +++++++++--------- tests/lib/test_graph_topo.c | 92 ++--- tests/lib/test_plugin.c | 42 +-- tests/lib/test_trace_ir_ref.c | 74 ++-- 117 files changed, 1637 insertions(+), 1637 deletions(-) rename include/babeltrace/{ref.h => object.h} (75%) rename lib/{ref.c => object.c} (94%) diff --git a/cli/babeltrace-cfg-cli-args-connect.c b/cli/babeltrace-cfg-cli-args-connect.c index e9e8691a..fc692391 100644 --- a/cli/babeltrace-cfg-cli-args-connect.c +++ b/cli/babeltrace-cfg-cli-args-connect.c @@ -295,7 +295,7 @@ static struct bt_config_component *find_component_in_array(GPtrArray *comps, struct bt_config_component *comp = g_ptr_array_index(comps, i); if (strcmp(name, comp->instance_name->str) == 0) { - found_comp = bt_get(comp); + found_comp = bt_object_get_ref(comp); goto end; } } @@ -340,7 +340,7 @@ static int validate_all_endpoints_exist(struct bt_config *cfg, char *error_buf, struct bt_config_component *comp; comp = find_component(cfg, connection->upstream_comp_name->str); - bt_put(comp); + bt_object_put_ref(comp); if (!comp) { snprintf(error_buf, error_buf_size, "Invalid connection: cannot find upstream component `%s`:\n %s\n", @@ -351,7 +351,7 @@ static int validate_all_endpoints_exist(struct bt_config *cfg, char *error_buf, } comp = find_component(cfg, connection->downstream_comp_name->str); - bt_put(comp); + bt_object_put_ref(comp); if (!comp) { snprintf(error_buf, error_buf_size, "Invalid connection: cannot find downstream component `%s`:\n %s\n", @@ -415,13 +415,13 @@ static int validate_connection_directions(struct bt_config *cfg, goto end; } - BT_PUT(src_comp); - BT_PUT(dst_comp); + BT_OBJECT_PUT_REF_AND_RESET(src_comp); + BT_OBJECT_PUT_REF_AND_RESET(dst_comp); } end: - bt_put(src_comp); - bt_put(dst_comp); + bt_object_put_ref(src_comp); + bt_object_put_ref(dst_comp); return ret; } @@ -580,7 +580,7 @@ static int validate_all_components_connected(struct bt_config *cfg, } end: - bt_put(connected_components); + bt_object_put_ref(connected_components); return ret; } @@ -630,7 +630,7 @@ static int validate_no_duplicate_connection(struct bt_config *cfg, } end: - bt_put(flat_connection_names); + bt_object_put_ref(flat_connection_names); if (flat_connection_name) { g_string_free(flat_connection_name, TRUE); diff --git a/cli/babeltrace-cfg-cli-args-default.c b/cli/babeltrace-cfg-cli-args-default.c index 6dcd72d7..dad339ad 100644 --- a/cli/babeltrace-cfg-cli-args-default.c +++ b/cli/babeltrace-cfg-cli-args-default.c @@ -58,10 +58,10 @@ struct bt_config *bt_config_cli_args_create_with_default(int argc, error: *retcode = 1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: - bt_put(initial_plugin_paths); + bt_object_put_ref(initial_plugin_paths); return cfg; } diff --git a/cli/babeltrace-cfg-cli-args.c b/cli/babeltrace-cfg-cli-args.c index 145333a6..1fb9add0 100644 --- a/cli/babeltrace-cfg-cli-args.c +++ b/cli/babeltrace-cfg-cli-args.c @@ -422,7 +422,7 @@ success: } end: - BT_PUT(value); + BT_OBJECT_PUT_REF_AND_RESET(value); return ret; } @@ -539,7 +539,7 @@ struct bt_value *bt_value_from_ini(const char *arg, GString *ini_error) goto end; error: - BT_PUT(state.params); + BT_OBJECT_PUT_REF_AND_RESET(state.params); end: if (state.scanner) { @@ -762,7 +762,7 @@ void bt_config_component_destroy(struct bt_object *obj) g_string_free(bt_config_component->instance_name, TRUE); } - BT_PUT(bt_config_component->params); + BT_OBJECT_PUT_REF_AND_RESET(bt_config_component->params); g_free(bt_config_component); end: @@ -820,7 +820,7 @@ struct bt_config_component *bt_config_component_create( goto end; error: - BT_PUT(cfg_component); + BT_OBJECT_PUT_REF_AND_RESET(cfg_component); end: return cfg_component; @@ -856,7 +856,7 @@ struct bt_config_component *bt_config_component_from_arg(const char *arg) goto end; error: - BT_PUT(cfg_comp); + BT_OBJECT_PUT_REF_AND_RESET(cfg_comp); end: g_free(name); @@ -878,7 +878,7 @@ void bt_config_destroy(struct bt_object *obj) goto end; } - BT_PUT(cfg->plugin_paths); + BT_OBJECT_PUT_REF_AND_RESET(cfg->plugin_paths); switch (cfg->command) { case BT_CONFIG_COMMAND_RUN: @@ -902,10 +902,10 @@ void bt_config_destroy(struct bt_object *obj) case BT_CONFIG_COMMAND_LIST_PLUGINS: break; case BT_CONFIG_COMMAND_HELP: - BT_PUT(cfg->cmd_data.help.cfg_component); + BT_OBJECT_PUT_REF_AND_RESET(cfg->cmd_data.help.cfg_component); break; case BT_CONFIG_COMMAND_QUERY: - BT_PUT(cfg->cmd_data.query.cfg_component); + BT_OBJECT_PUT_REF_AND_RESET(cfg->cmd_data.query.cfg_component); if (cfg->cmd_data.query.object) { g_string_free(cfg->cmd_data.query.object, TRUE); @@ -1107,7 +1107,7 @@ end: return names; error: - BT_PUT(names); + BT_OBJECT_PUT_REF_AND_RESET(names); if (scanner) { g_scanner_destroy(scanner); } @@ -1180,7 +1180,7 @@ struct bt_value *fields_from_arg(const char *arg) goto end; error: - BT_PUT(fields); + BT_OBJECT_PUT_REF_AND_RESET(fields); end: if (scanner) { @@ -1364,7 +1364,7 @@ void add_run_cfg_comp(struct bt_config *cfg, struct bt_config_component *cfg_comp, enum bt_config_component_dest dest) { - bt_get(cfg_comp); + bt_object_get_ref(cfg_comp); switch (dest) { case BT_CONFIG_COMPONENT_DEST_SOURCE: @@ -1505,7 +1505,7 @@ struct bt_config *bt_config_base_create(enum bt_config_command command, cfg->command_needs_plugins = needs_plugins; if (initial_plugin_paths) { - cfg->plugin_paths = bt_get(initial_plugin_paths); + cfg->plugin_paths = bt_object_get_ref(initial_plugin_paths); } else { cfg->plugin_paths = bt_value_array_create(); if (!cfg->plugin_paths) { @@ -1517,7 +1517,7 @@ struct bt_config *bt_config_base_create(enum bt_config_command command, goto end; error: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: return cfg; @@ -1537,21 +1537,21 @@ struct bt_config *bt_config_run_create( } cfg->cmd_data.run.sources = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); if (!cfg->cmd_data.run.sources) { print_err_oom(); goto error; } cfg->cmd_data.run.filters = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); if (!cfg->cmd_data.run.filters) { print_err_oom(); goto error; } cfg->cmd_data.run.sinks = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); if (!cfg->cmd_data.run.sinks) { print_err_oom(); goto error; @@ -1567,7 +1567,7 @@ struct bt_config *bt_config_run_create( goto end; error: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: return cfg; @@ -1589,7 +1589,7 @@ struct bt_config *bt_config_list_plugins_create( goto end; error: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: return cfg; @@ -1618,7 +1618,7 @@ struct bt_config *bt_config_help_create( goto end; error: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: return cfg; @@ -1646,7 +1646,7 @@ struct bt_config *bt_config_query_create( goto end; error: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: return cfg; @@ -1680,7 +1680,7 @@ struct bt_config *bt_config_print_ctf_metadata_create( goto end; error: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: return cfg; @@ -1715,7 +1715,7 @@ struct bt_config *bt_config_print_lttng_live_sessions_create( goto end; error: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: return cfg; @@ -1876,7 +1876,7 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], case OPT_HELP: print_help_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; default: printf_err("Unknown command-line option specified (option code %d)\n", @@ -1919,7 +1919,7 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], } else { print_help_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; } @@ -1931,7 +1931,7 @@ struct bt_config *bt_config_help_from_args(int argc, const char *argv[], error: *retcode = 1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: g_free(plugin_name); @@ -2039,7 +2039,7 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[], break; case OPT_PARAMS: { - bt_put(params); + bt_object_put_ref(params); params = bt_value_from_arg(arg); if (!params) { printf_err("Invalid format for --params option's argument:\n %s\n", @@ -2051,7 +2051,7 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[], case OPT_HELP: print_query_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; default: printf_err("Unknown command-line option specified (option code %d)\n", @@ -2085,11 +2085,11 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[], } BT_ASSERT(params); - BT_MOVE(cfg->cmd_data.query.cfg_component->params, params); + BT_OBJECT_MOVE_REF(cfg->cmd_data.query.cfg_component->params, params); } else { print_query_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; } @@ -2104,7 +2104,7 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[], } else { print_query_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; } @@ -2122,14 +2122,14 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[], error: *retcode = 1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: if (pc) { poptFreeContext(pc); } - bt_put(params); + bt_object_put_ref(params); free(arg); return cfg; } @@ -2227,7 +2227,7 @@ struct bt_config *bt_config_list_plugins_from_args(int argc, const char *argv[], case OPT_HELP: print_list_plugins_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; default: printf_err("Unknown command-line option specified (option code %d)\n", @@ -2260,7 +2260,7 @@ struct bt_config *bt_config_list_plugins_from_args(int argc, const char *argv[], error: *retcode = 1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: if (pc) { @@ -2476,7 +2476,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], ret = add_run_cfg_comp_check_name(cfg, cur_cfg_comp, cur_cfg_comp_dest, instance_names); - BT_PUT(cur_cfg_comp); + BT_OBJECT_PUT_REF_AND_RESET(cur_cfg_comp); if (ret) { goto error; } @@ -2504,7 +2504,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], } BT_ASSERT(cur_base_params); - bt_put(cur_cfg_comp->params); + bt_object_put_ref(cur_cfg_comp->params); cur_cfg_comp->params = bt_value_copy(cur_base_params); if (!cur_cfg_comp->params) { print_err_oom(); @@ -2534,14 +2534,14 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], params_to_set = bt_value_map_extend(cur_cfg_comp->params, params); - BT_PUT(params); + BT_OBJECT_PUT_REF_AND_RESET(params); if (!params_to_set) { printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n", arg); goto error; } - BT_MOVE(cur_cfg_comp->params, params_to_set); + BT_OBJECT_MOVE_REF(cur_cfg_comp->params, params_to_set); break; } case OPT_KEY: @@ -2590,11 +2590,11 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], goto error; } - BT_MOVE(cur_base_params, params); + BT_OBJECT_MOVE_REF(cur_base_params, params); break; } case OPT_RESET_BASE_PARAMS: - BT_PUT(cur_base_params); + BT_OBJECT_PUT_REF_AND_RESET(cur_base_params); cur_base_params = bt_value_map_create(); if (!cur_base_params) { print_err_oom(); @@ -2621,7 +2621,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], case OPT_HELP: print_run_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; default: printf_err("Unknown command-line option specified (option code %d)\n", @@ -2650,7 +2650,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], if (cur_cfg_comp) { ret = add_run_cfg_comp_check_name(cfg, cur_cfg_comp, cur_cfg_comp_dest, instance_names); - BT_PUT(cur_cfg_comp); + BT_OBJECT_PUT_REF_AND_RESET(cur_cfg_comp); if (ret) { goto error; } @@ -2681,7 +2681,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], error: *retcode = 1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: if (pc) { @@ -2693,10 +2693,10 @@ end: } free(arg); - BT_PUT(cur_cfg_comp); - BT_PUT(cur_base_params); - BT_PUT(instance_names); - BT_PUT(connection_args); + BT_OBJECT_PUT_REF_AND_RESET(cur_cfg_comp); + BT_OBJECT_PUT_REF_AND_RESET(cur_base_params); + BT_OBJECT_PUT_REF_AND_RESET(instance_names); + BT_OBJECT_PUT_REF_AND_RESET(connection_args); return cfg; } @@ -3092,7 +3092,7 @@ void finalize_implicit_component_args(struct implicit_component_args *args) g_string_free(args->params_arg, TRUE); } - bt_put(args->extra_params); + bt_object_put_ref(args->extra_params); } static @@ -3539,7 +3539,7 @@ int fill_implicit_ctf_inputs_args(GPtrArray *implicit_ctf_inputs_args, * We need our own copy of the extra parameters because * this is where the unique path goes. */ - BT_PUT(impl_args->extra_params); + BT_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params); impl_args->extra_params = bt_value_copy(base_implicit_ctf_input_args->extra_params); if (!impl_args->extra_params) { @@ -3612,7 +3612,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], struct implicit_component_args implicit_debug_info_args = { 0 }; struct implicit_component_args implicit_muxer_args = { 0 }; struct implicit_component_args implicit_trimmer_args = { 0 }; - struct bt_value *plugin_paths = bt_get(initial_plugin_paths); + struct bt_value *plugin_paths = bt_object_get_ref(initial_plugin_paths); char error_buf[256] = { 0 }; size_t i; struct bt_common_lttng_live_url_parts lttng_live_url_parts = { 0 }; @@ -3939,7 +3939,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], case OPT_HELP: print_convert_usage(stdout); *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; case OPT_BEGIN: case OPT_CLOCK_CYCLES: @@ -4160,7 +4160,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], ret = insert_flat_params_from_array( implicit_text_args.params_arg, fields, "field"); - bt_put(fields); + bt_object_put_ref(fields); if (ret) { goto error; } @@ -4178,7 +4178,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], ret = insert_flat_params_from_array( implicit_text_args.params_arg, names, "name"); - bt_put(names); + bt_object_put_ref(names); if (ret) { goto error; } @@ -4706,7 +4706,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], } *retcode = -1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); goto end; } @@ -4722,7 +4722,7 @@ struct bt_config *bt_config_convert_from_args(int argc, const char *argv[], error: *retcode = 1; - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); end: if (pc) { @@ -4744,8 +4744,8 @@ end: g_ptr_array_free(implicit_ctf_inputs_args, TRUE); } - bt_put(run_args); - bt_put(all_names); + bt_object_put_ref(run_args); + bt_object_put_ref(all_names); destroy_glist_of_gstring(source_names); destroy_glist_of_gstring(filter_names); destroy_glist_of_gstring(sink_names); @@ -4758,7 +4758,7 @@ end: finalize_implicit_component_args(&implicit_debug_info_args); finalize_implicit_component_args(&implicit_muxer_args); finalize_implicit_component_args(&implicit_trimmer_args); - bt_put(plugin_paths); + bt_object_put_ref(plugin_paths); bt_common_destroy_lttng_live_url_parts(<tng_live_url_parts); return cfg; } @@ -4853,7 +4853,7 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[], goto end; } } else { - bt_get(initial_plugin_paths); + bt_object_get_ref(initial_plugin_paths); } if (argc <= 1) { @@ -5015,6 +5015,6 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[], } end: - bt_put(initial_plugin_paths); + bt_object_put_ref(initial_plugin_paths); return config; } diff --git a/cli/babeltrace-cfg-cli-args.h b/cli/babeltrace-cfg-cli-args.h index 1f29741e..a82da00f 100644 --- a/cli/babeltrace-cfg-cli-args.h +++ b/cli/babeltrace-cfg-cli-args.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/cli/babeltrace-cfg.h b/cli/babeltrace-cfg.h index 864f3daf..55d5e857 100644 --- a/cli/babeltrace-cfg.h +++ b/cli/babeltrace-cfg.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -129,7 +129,7 @@ static inline struct bt_config_component *bt_config_get_component(GPtrArray *array, size_t index) { - return bt_get(g_ptr_array_index(array, index)); + return bt_object_get_ref(g_ptr_array_index(array, index)); } enum bt_value_status bt_config_append_plugin_paths( diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 2d273bd1..514a934a 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -139,7 +139,7 @@ void set_signal_handler(void) static void init_static_data(void) { - loaded_plugins = g_ptr_array_new_with_free_func(bt_put); + loaded_plugins = g_ptr_array_new_with_free_func(bt_object_put_ref); } static @@ -165,7 +165,7 @@ int create_the_query_executor(void) static void destroy_the_query_executor(void) { - BT_PUT(the_query_executor); + BT_OBJECT_PUT_REF_AND_RESET(the_query_executor); } static @@ -254,7 +254,7 @@ error: end: destroy_the_query_executor(); - bt_put(result); + bt_object_put_ref(result); return ret; } @@ -285,7 +285,7 @@ struct bt_plugin *find_plugin(const char *name) } } - return bt_get(plugin); + return bt_object_get_ref(plugin); } static @@ -308,7 +308,7 @@ struct bt_component_class *find_component_class(const char *plugin_name, comp_class = bt_plugin_get_component_class_by_name_and_type(plugin, comp_class_name, comp_class_type); - BT_PUT(plugin); + BT_OBJECT_PUT_REF_AND_RESET(plugin); end: if (BT_LOG_ON_DEBUG) { @@ -592,7 +592,7 @@ void print_bt_config_components(GPtrArray *array) struct bt_config_component *cfg_component = bt_config_get_component(array, i); print_bt_config_component(cfg_component); - BT_PUT(cfg_component); + BT_OBJECT_PUT_REF_AND_RESET(cfg_component); } } @@ -732,15 +732,15 @@ void add_to_loaded_plugins(struct bt_plugin_set *plugin_set) bt_plugin_get_name(plugin), bt_plugin_get_path(plugin), bt_plugin_get_path(loaded_plugin)); - bt_put(loaded_plugin); + bt_object_put_ref(loaded_plugin); } else { /* Add to global array. */ BT_LOGD("Adding plugin to loaded plugins: plugin-path=\"%s\"", bt_plugin_get_name(plugin)); - g_ptr_array_add(loaded_plugins, bt_get(plugin)); + g_ptr_array_add(loaded_plugins, bt_object_get_ref(plugin)); } - bt_put(plugin); + bt_object_put_ref(plugin); } } @@ -791,7 +791,7 @@ int load_dynamic_plugins(struct bt_value *plugin_paths) } add_to_loaded_plugins(plugin_set); - bt_put(plugin_set); + bt_object_put_ref(plugin_set); } end: return ret; @@ -812,7 +812,7 @@ int load_static_plugins(void) } add_to_loaded_plugins(plugin_set); - bt_put(plugin_set); + bt_object_put_ref(plugin_set); end: return ret; } @@ -954,8 +954,8 @@ failed: ret = -1; end: - bt_put(comp_cls); - bt_put(results); + bt_object_put_ref(comp_cls); + bt_object_put_ref(results); return ret; } @@ -1013,7 +1013,7 @@ int cmd_help(struct bt_config *cfg) goto end; } - bt_put(needed_comp_cls); + bt_object_put_ref(needed_comp_cls); } for (i = 0; i < bt_plugin_get_component_class_count(plugin); i++) { @@ -1035,7 +1035,7 @@ int cmd_help(struct bt_config *cfg) if (strcmp(cfg->cmd_data.help.cfg_component->comp_cls_name->str, comp_class_name) != 0 || type != cfg->cmd_data.help.cfg_component->type) { - bt_put(comp_cls); + bt_object_put_ref(comp_cls); continue; } } @@ -1054,11 +1054,11 @@ int cmd_help(struct bt_config *cfg) printf("\n%s\n", comp_class_help); } - bt_put(comp_cls); + bt_object_put_ref(comp_cls); } end: - bt_put(plugin); + bt_object_put_ref(plugin); return ret; } @@ -1131,7 +1131,7 @@ int cmd_list_plugins(struct bt_config *cfg) } printf("\n"); - bt_put(comp_class); + bt_object_put_ref(comp_class); } } @@ -1277,9 +1277,9 @@ error: ret = -1; end: - bt_put(results); - bt_put(params); - bt_put(comp_cls); + bt_object_put_ref(results); + bt_object_put_ref(params); + bt_object_put_ref(comp_cls); if (out_stream && out_stream != stdout) { int fclose_ret = fclose(out_stream); @@ -1389,9 +1389,9 @@ failed: end: destroy_the_query_executor(); - bt_put(results); - bt_put(params); - bt_put(comp_cls); + bt_object_put_ref(results); + bt_object_put_ref(params); + bt_object_put_ref(comp_cls); if (out_stream && out_stream != stdout) { int fclose_ret = fclose(out_stream); @@ -1643,7 +1643,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( /* Skip port if it's already connected. */ if (bt_port_is_connected(downstream_port)) { - bt_put(downstream_port); + bt_object_put_ref(downstream_port); BT_LOGD("Skipping downstream port: already connected: " "port-addr=%p, port-name=\"%s\"", downstream_port, @@ -1659,7 +1659,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( if (!bt_common_star_glob_match( cfg_conn->downstream_port_glob->str, SIZE_MAX, downstream_port_name, SIZE_MAX)) { - bt_put(downstream_port); + bt_object_put_ref(downstream_port); continue; } @@ -1715,7 +1715,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( * Replace the current downstream port by the trimmer's * upstream port. */ - BT_MOVE(downstream_port, trimmer_input); + BT_OBJECT_MOVE_REF(downstream_port, trimmer_input); downstream_port_name = bt_port_get_name( downstream_port); if (!downstream_port_name) { @@ -1726,7 +1726,7 @@ int cmd_run_ctx_connect_upstream_port_to_downstream_component( /* We have a winner! */ status = bt_graph_connect_ports(ctx->graph, upstream_port, downstream_port, NULL); - BT_PUT(downstream_port); + BT_OBJECT_PUT_REF_AND_RESET(downstream_port); switch (status) { case BT_GRAPH_STATUS_OK: break; @@ -1822,11 +1822,11 @@ error: end: free(intersection_begin); free(intersection_end); - BT_PUT(trimmer_params); - BT_PUT(trimmer_class); - BT_PUT(trimmer); - BT_PUT(trimmer_input); - BT_PUT(trimmer_output); + BT_OBJECT_PUT_REF_AND_RESET(trimmer_params); + BT_OBJECT_PUT_REF_AND_RESET(trimmer_class); + BT_OBJECT_PUT_REF_AND_RESET(trimmer); + BT_OBJECT_PUT_REF_AND_RESET(trimmer_input); + BT_OBJECT_PUT_REF_AND_RESET(trimmer_output); return ret; } @@ -1904,7 +1904,7 @@ error: ret = -1; end: - bt_put(upstream_comp); + bt_object_put_ref(upstream_comp); return ret; } @@ -1946,7 +1946,7 @@ void graph_port_added_listener(struct bt_port *port, void *data) } end: - bt_put(comp); + bt_object_put_ref(comp); return; } @@ -1978,8 +1978,8 @@ void graph_ports_connected_listener(struct bt_port *upstream_port, upstream_port, bt_port_get_name(upstream_port), downstream_comp, bt_component_get_name(downstream_comp), downstream_port, bt_port_get_name(downstream_port)); - bt_put(upstream_comp); - bt_put(downstream_comp); + bt_object_put_ref(upstream_comp); + bt_object_put_ref(downstream_comp); } static @@ -2013,7 +2013,7 @@ void cmd_run_ctx_destroy(struct cmd_run_ctx *ctx) ctx->intersections = NULL; } - BT_PUT(ctx->graph); + BT_OBJECT_PUT_REF_AND_RESET(ctx->graph); the_graph = NULL; ctx->cfg = NULL; } @@ -2026,7 +2026,7 @@ int cmd_run_ctx_init(struct cmd_run_ctx *ctx, struct bt_config *cfg) ctx->cfg = cfg; ctx->connect_ports = false; ctx->components = g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, bt_put); + NULL, bt_object_put_ref); if (!ctx->components) { goto error; } @@ -2336,8 +2336,8 @@ error: path ? path : "(unknown)", bt_common_color_reset()); end: - bt_put(query_params); - bt_put(query_result); + bt_object_put_ref(query_params); + bt_object_put_ref(query_result); g_free(port_id); g_free(trace_range); return ret; @@ -2409,7 +2409,7 @@ int cmd_run_ctx_create_components_from_config_components( g_hash_table_insert(ctx->components, GUINT_TO_POINTER(quark), comp); comp = NULL; - BT_PUT(comp_cls); + BT_OBJECT_PUT_REF_AND_RESET(comp_cls); } goto end; @@ -2418,8 +2418,8 @@ error: ret = -1; end: - bt_put(comp); - bt_put(comp_cls); + bt_object_put_ref(comp); + bt_object_put_ref(comp_cls); return ret; } @@ -2479,7 +2479,7 @@ int cmd_run_ctx_connect_comp_ports(struct cmd_run_ctx *ctx, BT_ASSERT(upstream_port); ret = cmd_run_ctx_connect_upstream_port(ctx, upstream_port); - bt_put(upstream_port); + bt_object_put_ref(upstream_port); if (ret) { goto end; } @@ -2894,7 +2894,7 @@ int main(int argc, const char **argv) retcode = ret ? 1 : 0; end: - BT_PUT(cfg); + BT_OBJECT_PUT_REF_AND_RESET(cfg); fini_static_data(); return retcode; } diff --git a/include/Makefile.am b/include/Makefile.am index 6fb155e0..75ec755e 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -73,7 +73,7 @@ babeltraceincludedir = "$(includedir)/babeltrace" babeltraceinclude_HEADERS = \ babeltrace/babeltrace.h \ babeltrace/logging.h \ - babeltrace/ref.h \ + babeltrace/object.h \ babeltrace/types.h \ babeltrace/values.h \ babeltrace/version.h diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h index 5edbfc07..f75467e0 100644 --- a/include/babeltrace/babeltrace.h +++ b/include/babeltrace/babeltrace.h @@ -27,7 +27,7 @@ /* Core API */ #include -#include +#include #include #include #include diff --git a/include/babeltrace/ctf-writer/clock.h b/include/babeltrace/ctf-writer/clock.h index a1a53e82..508c6940 100644 --- a/include/babeltrace/ctf-writer/clock.h +++ b/include/babeltrace/ctf-writer/clock.h @@ -31,7 +31,7 @@ */ #include -#include +#include #include #ifdef __cplusplus @@ -273,14 +273,14 @@ extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, static inline void bt_ctf_clock_get(struct bt_ctf_clock *clock) { - bt_get(clock); + bt_object_get_ref(clock); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_clock_put(struct bt_ctf_clock *clock) { - bt_put(clock); + bt_object_put_ref(clock); } extern struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name, diff --git a/include/babeltrace/ctf-writer/event-class-internal.h b/include/babeltrace/ctf-writer/event-class-internal.h index cef39ae3..cd54739a 100644 --- a/include/babeltrace/ctf-writer/event-class-internal.h +++ b/include/babeltrace/ctf-writer/event-class-internal.h @@ -335,8 +335,8 @@ int bt_ctf_event_class_common_set_context_field_type( goto end; } - bt_put(event_class->context_field_type); - event_class->context_field_type = bt_get(context_ft); + bt_object_put_ref(event_class->context_field_type); + event_class->context_field_type = bt_object_get_ref(context_ft); BT_LOGV("Set event class's context field type: " "event-class-addr=%p, event-class-name=\"%s\", " "event-class-id=%" PRId64 ", context-ft-addr=%p", @@ -381,8 +381,8 @@ int bt_ctf_event_class_common_set_payload_field_type( goto end; } - bt_put(event_class->payload_field_type); - event_class->payload_field_type = bt_get(payload_ft); + bt_object_put_ref(event_class->payload_field_type); + event_class->payload_field_type = bt_object_get_ref(payload_ft); BT_LOGV("Set event class's payload field type: " "event-class-addr=%p, event-class-name=\"%s\", " "event-class-id=%" PRId64 ", payload-ft-addr=%p", diff --git a/include/babeltrace/ctf-writer/event-fields.h b/include/babeltrace/ctf-writer/event-fields.h index 089b1c5f..f0f55b77 100644 --- a/include/babeltrace/ctf-writer/event-fields.h +++ b/include/babeltrace/ctf-writer/event-fields.h @@ -30,7 +30,7 @@ * http://www.efficios.com/ctf */ -#include +#include #include #include @@ -42,7 +42,7 @@ extern "C" { * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the * field's reference count. * - * You may also use bt_get() and bt_put() with field objects. + * You may also use bt_object_get_ref() and bt_object_put_ref() with field objects. * * These functions ensure that the field won't be destroyed when it * is in use. The same number of get and put (plus one extra put to @@ -59,14 +59,14 @@ extern "C" { static inline void bt_ctf_field_get(struct bt_ctf_field *field) { - bt_get(field); + bt_object_get_ref(field); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_field_put(struct bt_ctf_field *field) { - bt_put(field); + bt_object_put_ref(field); } #ifdef __cplusplus diff --git a/include/babeltrace/ctf-writer/event-internal.h b/include/babeltrace/ctf-writer/event-internal.h index 3a06131b..aaac70bd 100644 --- a/include/babeltrace/ctf-writer/event-internal.h +++ b/include/babeltrace/ctf-writer/event-internal.h @@ -238,7 +238,7 @@ void bt_ctf_event_common_finalize(struct bt_object *obj, * common ancestor with it to guarantee they would both have the * same lifetime. */ - bt_put(event->class); + bt_object_put_ref(event->class); } } diff --git a/include/babeltrace/ctf-writer/event-types.h b/include/babeltrace/ctf-writer/event-types.h index 7b1748ba..d39af8da 100644 --- a/include/babeltrace/ctf-writer/event-types.h +++ b/include/babeltrace/ctf-writer/event-types.h @@ -30,7 +30,7 @@ * http://www.efficios.com/ctf */ -#include +#include #include #ifdef __cplusplus @@ -41,7 +41,7 @@ extern "C" { * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement * the field type's reference count. * - * You may also use bt_get() and bt_put() with field type objects. + * You may also use bt_object_get_ref() and bt_object_put_ref() with field type objects. * * These functions ensure that the field type won't be destroyed while it * is in use. The same number of get and put (plus one extra put to @@ -58,14 +58,14 @@ extern "C" { static inline void bt_ctf_field_type_get(struct bt_ctf_field_type *type) { - bt_get(type); + bt_object_get_ref(type); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_field_type_put(struct bt_ctf_field_type *type) { - bt_put(type); + bt_object_put_ref(type); } #ifdef __cplusplus diff --git a/include/babeltrace/ctf-writer/event.h b/include/babeltrace/ctf-writer/event.h index 4c7ec295..fb5fdb2a 100644 --- a/include/babeltrace/ctf-writer/event.h +++ b/include/babeltrace/ctf-writer/event.h @@ -30,7 +30,7 @@ * http://www.efficios.com/ctf */ -#include +#include #ifdef __cplusplus extern "C" { @@ -138,14 +138,14 @@ extern struct bt_ctf_event_class *bt_ctf_event_get_class( static inline void bt_ctf_event_get(struct bt_ctf_event *event) { - bt_get(event); + bt_object_get_ref(event); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_event_put(struct bt_ctf_event *event) { - bt_put(event); + bt_object_put_ref(event); } extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name); @@ -201,14 +201,14 @@ extern struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name( static inline void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class) { - bt_get(event_class); + bt_object_get_ref(event_class); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class) { - bt_put(event_class); + bt_object_put_ref(event_class); } #ifdef __cplusplus diff --git a/include/babeltrace/ctf-writer/fields-internal.h b/include/babeltrace/ctf-writer/fields-internal.h index 64d33a9a..6b66f693 100644 --- a/include/babeltrace/ctf-writer/fields-internal.h +++ b/include/babeltrace/ctf-writer/fields-internal.h @@ -357,7 +357,7 @@ void bt_ctf_field_common_initialize(struct bt_ctf_field_common *field, BT_ASSERT(ft); bt_object_init(&field->base, is_shared, release_func); field->methods = methods; - field->type = bt_get(ft); + field->type = bt_object_get_ref(ft); } static inline @@ -698,7 +698,7 @@ void bt_ctf_field_common_finalize(struct bt_ctf_field_common *field) { BT_ASSERT(field); BT_LOGD_STR("Putting field's type."); - bt_put(field->type); + bt_object_put_ref(field->type); } static inline diff --git a/include/babeltrace/ctf-writer/stream-class-internal.h b/include/babeltrace/ctf-writer/stream-class-internal.h index 91a60b4e..f1a90e1f 100644 --- a/include/babeltrace/ctf-writer/stream-class-internal.h +++ b/include/babeltrace/ctf-writer/stream-class-internal.h @@ -359,8 +359,8 @@ int bt_ctf_stream_class_common_set_packet_context_field_type( goto end; } - bt_put(stream_class->packet_context_field_type); - bt_get(packet_context_type); + bt_object_put_ref(stream_class->packet_context_field_type); + bt_object_get_ref(packet_context_type); stream_class->packet_context_field_type = packet_context_type; BT_LOGV("Set stream class's packet context field type: " "addr=%p, name=\"%s\", id=%" PRId64 ", " @@ -436,8 +436,8 @@ int bt_ctf_stream_class_common_set_event_header_field_type( goto end; } - bt_put(stream_class->event_header_field_type); - stream_class->event_header_field_type = bt_get(event_header_type); + bt_object_put_ref(stream_class->event_header_field_type); + stream_class->event_header_field_type = bt_object_get_ref(event_header_type); BT_LOGV("Set stream class's event header field type: " "addr=%p, name=\"%s\", id=%" PRId64 ", " "event-header-ft-addr=%p", @@ -505,8 +505,8 @@ int bt_ctf_stream_class_common_set_event_context_field_type( goto end; } - bt_put(stream_class->event_context_field_type); - stream_class->event_context_field_type = bt_get(event_context_type); + bt_object_put_ref(stream_class->event_context_field_type); + stream_class->event_context_field_type = bt_object_get_ref(event_context_type); BT_LOGV("Set stream class's event context field type: " "addr=%p, name=\"%s\", id=%" PRId64 ", " "event-context-ft-addr=%p", diff --git a/include/babeltrace/ctf-writer/stream-class.h b/include/babeltrace/ctf-writer/stream-class.h index 33f653dd..042b13a6 100644 --- a/include/babeltrace/ctf-writer/stream-class.h +++ b/include/babeltrace/ctf-writer/stream-class.h @@ -30,7 +30,7 @@ * http://www.efficios.com/ctf */ -#include +#include #ifdef __cplusplus extern "C" { @@ -107,14 +107,14 @@ extern struct bt_ctf_clock *bt_ctf_stream_class_get_clock( static inline void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class) { - bt_get(stream_class); + bt_object_get_ref(stream_class); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class) { - bt_put(stream_class); + bt_object_put_ref(stream_class); } #ifdef __cplusplus diff --git a/include/babeltrace/ctf-writer/stream.h b/include/babeltrace/ctf-writer/stream.h index e0b64748..0a73013e 100644 --- a/include/babeltrace/ctf-writer/stream.h +++ b/include/babeltrace/ctf-writer/stream.h @@ -172,14 +172,14 @@ extern int64_t bt_ctf_stream_get_id(struct bt_ctf_stream *stream); static inline void bt_ctf_stream_get(struct bt_ctf_stream *stream) { - bt_get(stream); + bt_object_get_ref(stream); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_stream_put(struct bt_ctf_stream *stream) { - bt_put(stream); + bt_object_put_ref(stream); } #ifdef __cplusplus diff --git a/include/babeltrace/ctf-writer/visitor.h b/include/babeltrace/ctf-writer/visitor.h index 0020e7b2..16069118 100644 --- a/include/babeltrace/ctf-writer/visitor.h +++ b/include/babeltrace/ctf-writer/visitor.h @@ -76,7 +76,7 @@ bt_object_get_object() accessors to get the type and wrapped CTF IR object of a CTF IR object wrapper. A CTF IR object wrapper has no reference count: do \em -not use bt_put() or bt_get() on it. +not use bt_object_put_ref() or bt_object_get_ref() on it. @sa ctfirvisitor */ @@ -116,7 +116,7 @@ bt_ctf_stream_class_visit() when visiting the CTF IR object wrapper \p object. \p object has no reference count: do \em not use -bt_put() or bt_get() on it. +bt_object_put_ref() or bt_object_get_ref() on it. @param[in] object Currently visited CTF IR object wrapper. @param[in] data User data. @@ -151,7 +151,7 @@ enum bt_ctf_visitor_object_type bt_ctf_visitor_object_get_type( wrapper \p object. The reference count of \p object is \em not incremented by this -function. On success, you must call bt_get() on the return value to +function. On success, you must call bt_object_get_ref() on the return value to have your own reference. @param[in] object Object wrapper of which to get the wrapped diff --git a/include/babeltrace/ctf-writer/writer.h b/include/babeltrace/ctf-writer/writer.h index f496d3c5..e12f6d47 100644 --- a/include/babeltrace/ctf-writer/writer.h +++ b/include/babeltrace/ctf-writer/writer.h @@ -189,14 +189,14 @@ extern int bt_ctf_writer_set_byte_order(struct bt_ctf_writer *writer, static inline void bt_ctf_writer_get(struct bt_ctf_writer *writer) { - bt_get(writer); + bt_object_get_ref(writer); } /* Pre-2.0 CTF writer compatibility */ static inline void bt_ctf_writer_put(struct bt_ctf_writer *writer) { - bt_put(writer); + bt_object_put_ref(writer); } #ifdef __cplusplus diff --git a/include/babeltrace/graph/component.h b/include/babeltrace/graph/component.h index f2db9d72..c35685aa 100644 --- a/include/babeltrace/graph/component.h +++ b/include/babeltrace/graph/component.h @@ -33,8 +33,8 @@ /* For bt_bool */ #include -/* For bt_get */ -#include +/* For bt_object_get_ref */ +#include #ifdef __cplusplus extern "C" { @@ -92,7 +92,7 @@ extern struct bt_graph *bt_component_borrow_graph(struct bt_component *component static inline struct bt_graph *bt_component_get_graph(struct bt_component *component) { - return bt_get(bt_component_borrow_graph(component)); + return bt_object_get_ref(bt_component_borrow_graph(component)); } #ifdef __cplusplus diff --git a/include/babeltrace/graph/notification-event.h b/include/babeltrace/graph/notification-event.h index 46a81cc2..888ab038 100644 --- a/include/babeltrace/graph/notification-event.h +++ b/include/babeltrace/graph/notification-event.h @@ -27,8 +27,8 @@ * SOFTWARE. */ -/* For bt_get() */ -#include +/* For bt_object_get_ref() */ +#include #ifdef __cplusplus extern "C" { diff --git a/include/babeltrace/graph/notification-iterator.h b/include/babeltrace/graph/notification-iterator.h index dcaafb0e..bcf6a659 100644 --- a/include/babeltrace/graph/notification-iterator.h +++ b/include/babeltrace/graph/notification-iterator.h @@ -27,8 +27,8 @@ * SOFTWARE. */ -/* For bt_get() */ -#include +/* For bt_object_get_ref() */ +#include #include diff --git a/include/babeltrace/graph/notification-packet.h b/include/babeltrace/graph/notification-packet.h index 3d03e7fe..356d2b4c 100644 --- a/include/babeltrace/graph/notification-packet.h +++ b/include/babeltrace/graph/notification-packet.h @@ -27,8 +27,8 @@ * SOFTWARE. */ -/* For bt_get() */ -#include +/* For bt_object_get_ref() */ +#include #ifdef __cplusplus extern "C" { @@ -56,7 +56,7 @@ static inline struct bt_packet *bt_notification_packet_begin_get_packet( struct bt_notification *notification) { - return bt_get(bt_notification_packet_begin_borrow_packet(notification)); + return bt_object_get_ref(bt_notification_packet_begin_borrow_packet(notification)); } extern struct bt_packet *bt_notification_packet_end_borrow_packet( @@ -66,7 +66,7 @@ static inline struct bt_packet *bt_notification_packet_end_get_packet( struct bt_notification *notification) { - return bt_get(bt_notification_packet_end_borrow_packet(notification)); + return bt_object_get_ref(bt_notification_packet_end_borrow_packet(notification)); } #ifdef __cplusplus diff --git a/include/babeltrace/graph/notification-stream.h b/include/babeltrace/graph/notification-stream.h index 18b10b9e..67881e79 100644 --- a/include/babeltrace/graph/notification-stream.h +++ b/include/babeltrace/graph/notification-stream.h @@ -29,8 +29,8 @@ #include -/* For bt_get() */ -#include +/* For bt_object_get_ref() */ +#include /* For bt_bool */ #include @@ -62,7 +62,7 @@ static inline struct bt_stream *bt_notification_stream_begin_get_stream( struct bt_notification *notification) { - return bt_get(bt_notification_stream_begin_borrow_stream(notification)); + return bt_object_get_ref(bt_notification_stream_begin_borrow_stream(notification)); } extern int bt_notification_stream_begin_set_default_clock_value( @@ -78,7 +78,7 @@ static inline struct bt_stream *bt_notification_stream_end_get_stream( struct bt_notification *notification) { - return bt_get(bt_notification_stream_end_borrow_stream(notification)); + return bt_object_get_ref(bt_notification_stream_end_borrow_stream(notification)); } extern int bt_notification_stream_end_set_default_clock_value( diff --git a/include/babeltrace/ref.h b/include/babeltrace/object.h similarity index 75% rename from include/babeltrace/ref.h rename to include/babeltrace/object.h index bea62028..c2b553a4 100644 --- a/include/babeltrace/ref.h +++ b/include/babeltrace/object.h @@ -1,5 +1,5 @@ -#ifndef BABELTRACE_REF_H -#define BABELTRACE_REF_H +#ifndef BABELTRACE_OBJECT_H +#define BABELTRACE_OBJECT_H /* * BabelTrace: common reference counting @@ -37,7 +37,7 @@ extern "C" { @brief Common reference counting management for all Babeltrace objects. @code -#include +#include @endcode The macros and functions of this module are everything that is needed @@ -62,7 +62,7 @@ The Babeltrace C API complies with the following key principles: In other words, the caller still owns the object after calling any API function: no function "steals" the user's reference (except - bt_put()). + bt_object_put_ref()). 2. An API function which \em returns a Babeltrace object pointer to the user returns a new reference. The caller becomes an @@ -71,7 +71,7 @@ The Babeltrace C API complies with the following key principles: @image html ref-count-api-returns.png It is your responsibility to discard the object when you don't - need it anymore with bt_put(). + need it anymore with bt_object_put_ref(). For example, see bt_value_array_get(). @@ -79,16 +79,16 @@ The Babeltrace C API complies with the following key principles: function called back from an API function is a borrowed, or weak reference: if you need a reference which is more persistent than the duration of the - user function, call bt_get() on the pointer. + user function, call bt_object_get_ref() on the pointer. @image html ref-count-callback.png For example, see bt_value_map_foreach_entry(). -The two macros BT_PUT() and BT_MOVE() operate on \em variables rather -than pointer values. You should use BT_PUT() instead of bt_put() when +The two macros BT_OBJECT_PUT_REF_AND_RESET() and BT_OBJECT_MOVE_REF() operate on \em variables rather +than pointer values. You should use BT_OBJECT_PUT_REF_AND_RESET() instead of bt_object_put_ref() when possible to avoid "double puts". For the same reason, you should use use -BT_MOVE() instead of performing manual reference moves between +BT_OBJECT_MOVE_REF() instead of performing manual reference moves between variables. @file @@ -100,13 +100,13 @@ variables. */ /** -@brief Calls bt_put() on a variable named \p _var, then +@brief Calls bt_object_put_ref() on a variable named \p _var, then sets \p _var to \c NULL. -Using this macro is considered safer than calling bt_put() because it +Using this macro is considered safer than calling bt_object_put_ref() because it makes sure that the variable which used to contain a reference to a -Babeltrace object is set to \c NULL so that a future BT_PUT() or -bt_put() call will not cause another, unwanted reference decrementation. +Babeltrace object is set to \c NULL so that a future BT_OBJECT_PUT_REF_AND_RESET() or +bt_object_put_ref() call will not cause another, unwanted reference decrementation. @param[in,out] _var Name of a variable containing a Babeltrace object's address (this address @@ -116,13 +116,13 @@ bt_put() call will not cause another, unwanted reference decrementation. its reference count is decremented. @post \p _var contains \c NULL. -@sa BT_MOVE(): Transfers the ownership of a Babeltrace object from a +@sa BT_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a variable to another. */ -#define BT_PUT(_var) \ - do { \ - bt_put(_var); \ - (_var) = NULL; \ +#define BT_OBJECT_PUT_REF_AND_RESET(_var) \ + do { \ + bt_object_put_ref(_var); \ + (_var) = NULL; \ } while (0) /** @@ -131,7 +131,7 @@ bt_put() call will not cause another, unwanted reference decrementation. This macro implements the following common pattern: - 1. Call bt_put() on \p _var_dst to make sure the previous reference + 1. Call bt_object_put_ref() on \p _var_dst to make sure the previous reference held by \p _var_dst is discarded. 2. Assign \p _var_src to \p _var_dst. 3. Set \p _var_src to \c NULL to avoid future, unwanted reference @@ -140,7 +140,7 @@ This macro implements the following common pattern: @warning You must \em not use this macro when both \p _var_dst and \p _var_src contain the same Babeltrace object address and the reference -count of this object is 1. The initial call to bt_put() on \p _var_dst +count of this object is 1. The initial call to bt_object_put_ref() on \p _var_dst would destroy the object and leave a dangling pointer in \p _var_dst. @param[in,out] _var_dst Name of the destination variable, containing @@ -159,11 +159,11 @@ would destroy the object and leave a dangling pointer in \p _var_dst. you called this macro. @post \p _var_src is \c NULL. -@sa BT_PUT(): Calls bt_put() on a variable, then sets it to \c NULL. +@sa BT_OBJECT_PUT_REF_AND_RESET(): Calls bt_object_put_ref() on a variable, then sets it to \c NULL. */ -#define BT_MOVE(_var_dst, _var_src) \ +#define BT_OBJECT_MOVE_REF(_var_dst, _var_src) \ do { \ - bt_put(_var_dst); \ + bt_object_put_ref(_var_dst); \ (_var_dst) = (_var_src); \ (_var_src) = NULL; \ } while (0) @@ -178,9 +178,9 @@ would destroy the object and leave a dangling pointer in \p _var_dst. @post If \c obj is not \c NULL, its reference count is incremented. -@sa bt_put(): Decrements the reference count of a Babeltrace object. +@sa bt_object_put_ref(): Decrements the reference count of a Babeltrace object. */ -void *bt_get(void *obj); +void *bt_object_get_ref(void *obj); /** @brief Decrements the reference count of the Babeltrace object @@ -190,7 +190,7 @@ When the object's reference count reaches 0, the object can no longer be accessed and is considered \em destroyed. @remarks -You should use the BT_PUT() macro instead of calling bt_put() since the +You should use the BT_OBJECT_PUT_REF_AND_RESET() macro instead of calling bt_object_put_ref() since the former is generally safer. @param[in] obj Babeltrace object of which to drop a reference @@ -199,12 +199,12 @@ former is generally safer. @post If \c obj is not \c NULL, its reference count is decremented. -@sa BT_PUT(): Calls bt_put() on a variable, then sets it to \c NULL. -@sa BT_MOVE(): Transfers the ownership of a Babeltrace object from a +@sa BT_OBJECT_PUT_REF_AND_RESET(): Calls bt_object_put_ref() on a variable, then sets it to \c NULL. +@sa BT_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a variable to another. -@sa bt_get(): Increments the reference count of a Babeltrace object. +@sa bt_object_get_ref(): Increments the reference count of a Babeltrace object. */ -void bt_put(void *obj); +void bt_object_put_ref(void *obj); /** @} @@ -214,4 +214,4 @@ void bt_put(void *obj); } #endif -#endif /* BABELTRACE_REF_H */ +#endif /* BABELTRACE_OBJECT_H */ diff --git a/include/babeltrace/plugin/plugin-internal.h b/include/babeltrace/plugin/plugin-internal.h index 4cb57513..b9579ff8 100644 --- a/include/babeltrace/plugin/plugin-internal.h +++ b/include/babeltrace/plugin/plugin-internal.h @@ -174,7 +174,7 @@ struct bt_plugin *bt_plugin_create_empty(enum bt_plugin_type type) /* Create empty array of component classes */ plugin->comp_classes = - g_ptr_array_new_with_free_func((GDestroyNotify) bt_put); + g_ptr_array_new_with_free_func((GDestroyNotify) bt_object_put_ref); if (!plugin->comp_classes) { BT_LOGE_STR("Failed to allocate a GPtrArray."); goto error; @@ -222,7 +222,7 @@ struct bt_plugin *bt_plugin_create_empty(enum bt_plugin_type type) goto end; error: - BT_PUT(plugin); + BT_OBJECT_PUT_REF_AND_RESET(plugin); end: return plugin; @@ -352,10 +352,10 @@ struct bt_plugin_set *bt_plugin_set_create(void) bt_object_init_shared(&plugin_set->base, bt_plugin_set_destroy); plugin_set->plugins = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); if (!plugin_set->plugins) { BT_LOGE_STR("Failed to allocate a GPtrArray."); - BT_PUT(plugin_set); + BT_OBJECT_PUT_REF_AND_RESET(plugin_set); goto end; } @@ -371,7 +371,7 @@ void bt_plugin_set_add_plugin(struct bt_plugin_set *plugin_set, { BT_ASSERT(plugin_set); BT_ASSERT(plugin); - g_ptr_array_add(plugin_set->plugins, bt_get(plugin)); + g_ptr_array_add(plugin_set->plugins, bt_object_get_ref(plugin)); BT_LOGV("Added plugin to plugin set: " "plugin-set-addr=%p, plugin-addr=%p, plugin-name=\"%s\", " "plugin-path=\"%s\"", diff --git a/include/babeltrace/trace-ir/event-internal.h b/include/babeltrace/trace-ir/event-internal.h index ef5bdf0b..45f79387 100644 --- a/include/babeltrace/trace-ir/event-internal.h +++ b/include/babeltrace/trace-ir/event-internal.h @@ -154,7 +154,7 @@ void bt_event_recycle(struct bt_event *event) * 2. Move the event class reference to our `event_class` * variable so that we can set the event's class member * to NULL before recycling it. We CANNOT do this after - * we put the event class reference because this bt_put() + * we put the event class reference because this bt_object_put_ref() * could destroy the event class, also destroying its * event pool, thus also destroying our event object (this * would result in an invalid write access). diff --git a/include/babeltrace/trace-ir/field-classes.h b/include/babeltrace/trace-ir/field-classes.h index 0c93847a..1a5ae540 100644 --- a/include/babeltrace/trace-ir/field-classes.h +++ b/include/babeltrace/trace-ir/field-classes.h @@ -30,8 +30,8 @@ * http://www.efficios.com/ctf */ -/* For bt_get() */ -#include +/* For bt_object_get_ref() */ +#include /* For bt_bool */ #include diff --git a/include/babeltrace/values.h b/include/babeltrace/values.h index 5139773c..76ac6895 100644 --- a/include/babeltrace/values.h +++ b/include/babeltrace/values.h @@ -32,8 +32,8 @@ /* For bt_bool */ #include -/* For bt_get() */ -#include +/* For bt_object_get_ref() */ +#include #ifdef __cplusplus extern "C" { @@ -201,7 +201,7 @@ one. You can compare any value object address to the null value object singleton to check if it's the null value object, or otherwise with bt_value_is_null(). -You can pass \ref bt_value_null to bt_get() or bt_put(): it has +You can pass \ref bt_value_null to bt_object_get_ref() or bt_object_put_ref(): it has no effect. The null value object singleton is always frozen (see @@ -1067,7 +1067,7 @@ extern struct bt_value *bt_value_map_borrow_entry_value( /** @brief User function type to use with bt_value_map_foreach_entry(). -\p object is a weak reference: you \em must pass it to bt_get() +\p object is a weak reference: you \em must pass it to bt_object_get_ref() if you need to keep a reference after this function returns. This function \em must return #BT_TRUE to continue the map value object @@ -1091,7 +1091,7 @@ typedef bt_bool (* bt_value_map_foreach_entry_cb)(const char *key, map value object \p map_obj. The value object passed to the user function is a weak reference: -you \em must pass it to bt_get() if you need to keep a persistent +you \em must pass it to bt_object_get_ref() if you need to keep a persistent reference after the user function returns. The key passed to the user function is only valid in the scope of diff --git a/lib/Makefile.am b/lib/Makefile.am index 04ece474..ab1aa771 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,7 +5,7 @@ lib_LTLIBRARIES = libbabeltrace.la libbabeltrace-ctf.la libbabeltrace_la_SOURCES = \ babeltrace.c \ values.c \ - ref.c \ + object.c \ lib-logging.c \ logging.c \ object-pool.c diff --git a/lib/ctf-writer/attributes.c b/lib/ctf-writer/attributes.c index bc421ace..ddec5c85 100644 --- a/lib/ctf-writer/attributes.c +++ b/lib/ctf-writer/attributes.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -74,7 +74,7 @@ BT_HIDDEN void bt_ctf_attributes_destroy(struct bt_value *attr_obj) { BT_LOGD("Destroying attributes object: addr=%p", attr_obj); - bt_put(attr_obj); + bt_object_put_ref(attr_obj); } BT_HIDDEN @@ -272,7 +272,7 @@ int bt_ctf_attributes_set_field_value(struct bt_value *attr_obj, } end: - bt_put(attr_field_obj); + bt_object_put_ref(attr_field_obj); return ret; } diff --git a/lib/ctf-writer/clock-class.c b/lib/ctf-writer/clock-class.c index fa468f37..02fe8b5b 100644 --- a/lib/ctf-writer/clock-class.c +++ b/lib/ctf-writer/clock-class.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -150,7 +150,7 @@ struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name, clock_class, name); return clock_class; error: - BT_PUT(clock_class); + BT_OBJECT_PUT_REF_AND_RESET(clock_class); return clock_class; } diff --git a/lib/ctf-writer/clock.c b/lib/ctf-writer/clock.c index f838adbf..fdb8f498 100644 --- a/lib/ctf-writer/clock.c +++ b/lib/ctf-writer/clock.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include static @@ -76,7 +76,7 @@ struct bt_ctf_clock *bt_ctf_clock_create(const char *name) return clock; error: - BT_PUT(clock); + BT_OBJECT_PUT_REF_AND_RESET(clock); return clock; } @@ -217,7 +217,7 @@ void bt_ctf_clock_destroy(struct bt_object *obj) struct bt_ctf_clock *clock; clock = container_of(obj, struct bt_ctf_clock, base); - bt_put(clock->clock_class); + bt_object_put_ref(clock->clock_class); g_free(clock); } diff --git a/lib/ctf-writer/event-class.c b/lib/ctf-writer/event-class.c index 713a4653..1c33dd96 100644 --- a/lib/ctf-writer/event-class.c +++ b/lib/ctf-writer/event-class.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -69,9 +69,9 @@ void bt_ctf_event_class_common_finalize(struct bt_object *obj) } BT_LOGD_STR("Putting context field type."); - bt_put(event_class->context_field_type); + bt_object_put_ref(event_class->context_field_type); BT_LOGD_STR("Putting payload field type."); - bt_put(event_class->payload_field_type); + bt_object_put_ref(event_class->payload_field_type); } BT_HIDDEN @@ -217,7 +217,7 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name) goto end; error: - bt_put(ctf_event_class); + bt_object_put_ref(ctf_event_class); end: return ctf_event_class; @@ -269,14 +269,14 @@ struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class( struct bt_ctf_event_class *event_class) { BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); - return bt_get(bt_ctf_event_class_common_borrow_stream_class( + return bt_object_get_ref(bt_ctf_event_class_common_borrow_stream_class( BT_CTF_TO_COMMON(event_class))); } struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type( struct bt_ctf_event_class *event_class) { - return bt_get(bt_ctf_event_class_common_borrow_payload_field_type( + return bt_object_get_ref(bt_ctf_event_class_common_borrow_payload_field_type( BT_CTF_TO_COMMON(event_class))); } @@ -291,7 +291,7 @@ int bt_ctf_event_class_set_payload_field_type( struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type( struct bt_ctf_event_class *event_class) { - return bt_get(bt_ctf_event_class_common_borrow_context_field_type( + return bt_object_get_ref(bt_ctf_event_class_common_borrow_context_field_type( BT_CTF_TO_COMMON(event_class))); } @@ -539,7 +539,7 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class, end: context->current_indentation_level = 0; - BT_PUT(attr_value); + BT_OBJECT_PUT_REF_AND_RESET(attr_value); return ret; } @@ -577,7 +577,7 @@ struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name( * No need to increment field_type's reference count since getting it * from the structure already does. */ - field_type = bt_get( + field_type = bt_object_get_ref( bt_ctf_field_type_common_structure_borrow_field_type_by_name( event_class->common.payload_field_type, name)); diff --git a/lib/ctf-writer/event.c b/lib/ctf-writer/event.c index 603b3cf0..e027880c 100644 --- a/lib/ctf-writer/event.c +++ b/lib/ctf-writer/event.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include static @@ -330,7 +330,7 @@ int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event, struct bt_ctf_field_common *event_payload = NULL; struct bt_ctf_validation_output validation_output = { 0 }; struct bt_ctf_clock_class *expected_clock_class = - init_expected_clock_class ? bt_get(init_expected_clock_class) : + init_expected_clock_class ? bt_object_get_ref(init_expected_clock_class) : NULL; BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); @@ -425,7 +425,7 @@ int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event, * from that point, the event and its class will share the same * lifetime. */ - event->class = bt_get(event_class); + event->class = bt_object_get_ref(event_class); ret = bt_ctf_event_common_create_fields(stream_class, &validation_output, @@ -472,7 +472,7 @@ int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event, * now because the stream class is frozen. */ if (expected_clock_class) { - BT_MOVE(stream_class->clock_class, expected_clock_class); + BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class); } /* @@ -491,7 +491,7 @@ int bt_ctf_event_common_initialize(struct bt_ctf_event_common *event, error: bt_ctf_validation_output_put_types(&validation_output); - bt_put(expected_clock_class); + bt_object_put_ref(expected_clock_class); if (event_header) { release_header_field_func(event_header, stream_class); @@ -535,7 +535,7 @@ static void destroy_event_header_field(struct bt_ctf_field_wrapper *field_wrapper) { BT_ASSERT(field_wrapper); - bt_put(field_wrapper->field); + bt_object_put_ref(field_wrapper->field); bt_ctf_field_wrapper_destroy(field_wrapper); } @@ -561,7 +561,7 @@ struct bt_ctf_field_wrapper *create_event_header_field( goto end; error: - bt_put(field); + bt_object_put_ref(field); if (field_wrapper) { destroy_event_header_field(field_wrapper); @@ -577,14 +577,14 @@ void release_event_header_field(struct bt_ctf_field_wrapper *field_wrapper, struct bt_ctf_event_common *event_common) { BT_ASSERT(field_wrapper); - BT_PUT(field_wrapper->field); + BT_OBJECT_PUT_REF_AND_RESET(field_wrapper->field); bt_ctf_field_wrapper_destroy(field_wrapper); } static void bt_ctf_event_destroy(struct bt_object *obj) { - bt_ctf_event_common_finalize(obj, (void *) bt_put, + bt_ctf_event_common_finalize(obj, (void *) bt_object_put_ref, (void *) release_event_header_field); g_free(obj); } @@ -618,7 +618,7 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) bt_ctf_field_type_copy, false, map_clock_classes_func, (create_field_func) bt_ctf_field_create, - (release_field_func) bt_put, + (release_field_func) bt_object_put_ref, (create_header_field_func) create_event_header_field, (release_header_field_func) destroy_event_header_field); if (ret) { @@ -629,7 +629,7 @@ struct bt_ctf_event *bt_ctf_event_create(struct bt_ctf_event_class *event_class) goto end; error: - BT_PUT(event); + BT_OBJECT_PUT_REF_AND_RESET(event); end: return event; @@ -638,7 +638,7 @@ end: struct bt_ctf_event_class *bt_ctf_event_get_class(struct bt_ctf_event *event) { BT_ASSERT_PRE_NON_NULL(event, "Event"); - return bt_get(bt_ctf_event_common_borrow_class(BT_CTF_TO_COMMON(event))); + return bt_object_get_ref(bt_ctf_event_common_borrow_class(BT_CTF_TO_COMMON(event))); } BT_HIDDEN @@ -652,7 +652,7 @@ struct bt_ctf_stream *bt_ctf_event_borrow_stream(struct bt_ctf_event *event) struct bt_ctf_stream *bt_ctf_event_get_stream(struct bt_ctf_event *event) { BT_ASSERT_PRE_NON_NULL(event, "Event"); - return bt_get(bt_ctf_event_borrow_stream(event)); + return bt_object_get_ref(bt_ctf_event_borrow_stream(event)); } int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, @@ -677,7 +677,7 @@ struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, BT_CTF_FROM_COMMON(event->common.payload_field), name); } else { field = BT_CTF_FROM_COMMON(event->common.payload_field); - bt_get(field); + bt_object_get_ref(field); } return field; @@ -686,23 +686,23 @@ struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, struct bt_ctf_field *bt_ctf_event_get_payload_field( struct bt_ctf_event *event) { - return bt_get(bt_ctf_event_common_borrow_payload(BT_CTF_TO_COMMON(event))); + return bt_object_get_ref(bt_ctf_event_common_borrow_payload(BT_CTF_TO_COMMON(event))); } struct bt_ctf_field *bt_ctf_event_get_header(struct bt_ctf_event *event) { - return bt_get(bt_ctf_event_common_borrow_header(BT_CTF_TO_COMMON(event))); + return bt_object_get_ref(bt_ctf_event_common_borrow_header(BT_CTF_TO_COMMON(event))); } struct bt_ctf_field *bt_ctf_event_get_context(struct bt_ctf_event *event) { - return bt_get(bt_ctf_event_common_borrow_context(BT_CTF_TO_COMMON(event))); + return bt_object_get_ref(bt_ctf_event_common_borrow_context(BT_CTF_TO_COMMON(event))); } struct bt_ctf_field *bt_ctf_event_get_stream_event_context( struct bt_ctf_event *event) { - return bt_get(bt_ctf_event_common_borrow_stream_event_context( + return bt_object_get_ref(bt_ctf_event_common_borrow_stream_event_context( BT_CTF_TO_COMMON(event))); } @@ -786,8 +786,8 @@ int bt_ctf_event_set_header(struct bt_ctf_event *event, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type); } - bt_put(event->common.header_field->field); - event->common.header_field->field = bt_get(header); + bt_object_put_ref(event->common.header_field->field); + event->common.header_field->field = bt_object_get_ref(header); BT_LOGV("Set event's header field: event-addr=%p, " "event-class-name=\"%s\", event-class-id=%" PRId64 ", " "header-field-addr=%p", @@ -820,8 +820,8 @@ int bt_ctf_event_common_set_payload(struct bt_ctf_event *event, event, event->common.class->payload_field_type); } - bt_put(event->common.payload_field); - event->common.payload_field = bt_get(payload); + bt_object_put_ref(event->common.payload_field); + event->common.payload_field = bt_object_get_ref(payload); BT_LOGV("Set event's payload field: event-addr=%p, " "event-class-name=\"%s\", event-class-id=%" PRId64 ", " "payload-field-addr=%p", @@ -853,8 +853,8 @@ int bt_ctf_event_set_context(struct bt_ctf_event *event, event, event->common.class->context_field_type); } - bt_put(event->common.context_field); - event->common.context_field = bt_get(context); + bt_object_put_ref(event->common.context_field); + event->common.context_field = bt_object_get_ref(context); BT_LOGV("Set event's context field: event-addr=%p, " "event-class-name=\"%s\", event-class-id=%" PRId64 ", " "context-field-addr=%p", @@ -888,8 +888,8 @@ int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event, bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type); } - bt_put(event->common.stream_event_context_field); - event->common.stream_event_context_field = bt_get(stream_event_context); + bt_object_put_ref(event->common.stream_event_context_field); + event->common.stream_event_context_field = bt_object_get_ref(stream_event_context); BT_LOGV("Set event's stream event context field: event-addr=%p, " "event-class-name=\"%s\", event-class-id=%" PRId64 ", " "stream-event-context-field-addr=%p", diff --git a/lib/ctf-writer/field-path.c b/lib/ctf-writer/field-path.c index 24ef9efc..21d4b692 100644 --- a/lib/ctf-writer/field-path.c +++ b/lib/ctf-writer/field-path.c @@ -79,7 +79,7 @@ struct bt_ctf_field_path *bt_ctf_field_path_create(void) return field_path; error: - BT_PUT(field_path); + BT_OBJECT_PUT_REF_AND_RESET(field_path); return NULL; } diff --git a/lib/ctf-writer/field-types.c b/lib/ctf-writer/field-types.c index c7938af1..ba7c7ecd 100644 --- a/lib/ctf-writer/field-types.c +++ b/lib/ctf-writer/field-types.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -125,7 +125,7 @@ void bt_ctf_field_type_common_enumeration_initialize( BT_LOGD("Initializing common enumeration field type object: int-ft-addr=%p", container_ft); ft->id = BT_CTF_FIELD_TYPE_ID_ENUM; - enum_ft->container_ft = bt_get(container_ft); + enum_ft->container_ft = bt_object_get_ref(container_ft); enum_ft->entries = g_ptr_array_new_with_free_func( (GDestroyNotify) destroy_enumeration_mapping); bt_ctf_field_type_common_initialize(ft, false, release_func, methods); @@ -180,7 +180,7 @@ void bt_ctf_field_type_common_array_initialize( BT_LOGD("Initializing common array field type object: element-ft-addr=%p, " "length=%u", element_ft, length); ft->id = BT_CTF_FIELD_TYPE_ID_ARRAY; - array_ft->element_ft = bt_get(element_ft); + array_ft->element_ft = bt_object_get_ref(element_ft); array_ft->length = length; bt_ctf_field_type_common_initialize(ft, false, release_func, methods); BT_LOGD("Initialized common array field type object: addr=%p, " @@ -203,7 +203,7 @@ void bt_ctf_field_type_common_sequence_initialize( BT_LOGD("Initializing common sequence field type object: element-ft-addr=%p, " "length-field-name=\"%s\"", element_ft, length_field_name); ft->id = BT_CTF_FIELD_TYPE_ID_SEQUENCE; - seq_ft->element_ft = bt_get(element_ft); + seq_ft->element_ft = bt_object_get_ref(element_ft); seq_ft->length_field_name = g_string_new(length_field_name); bt_ctf_field_type_common_initialize(ft, false, release_func, methods); BT_LOGD("Initialized common sequence field type object: addr=%p, " @@ -232,7 +232,7 @@ void bt_ctf_field_type_common_variant_initialize( sizeof(struct bt_ctf_field_type_common_variant_choice)); if (tag_ft) { - var_ft->tag_ft = bt_get(tag_ft); + var_ft->tag_ft = bt_object_get_ref(tag_ft); } bt_ctf_field_type_common_initialize(ft, true, release_func, methods); @@ -254,7 +254,7 @@ void bt_ctf_field_type_common_integer_destroy(struct bt_object *obj) BT_LOGD("Destroying integer field type object: addr=%p", ft); BT_LOGD_STR("Putting mapped clock class."); - bt_put(ft->mapped_clock_class); + bt_object_put_ref(ft->mapped_clock_class); g_free(ft); } @@ -283,7 +283,7 @@ void bt_ctf_field_type_common_enumeration_destroy_recursive(struct bt_object *ob BT_LOGD("Destroying enumeration field type object: addr=%p", ft); g_ptr_array_free(ft->entries, TRUE); BT_LOGD_STR("Putting container field type."); - bt_put(ft->container_ft); + bt_object_put_ref(ft->container_ft); g_free(ft); } @@ -312,7 +312,7 @@ void bt_ctf_field_type_common_structure_field_finalize( "addr=%p, field-ft-addr=%p, field-name=\"%s\"", field, field->type, g_quark_to_string(field->name)); BT_LOGD_STR("Putting field type."); - bt_put(field->type); + bt_object_put_ref(field->type); } BT_HIDDEN @@ -355,7 +355,7 @@ void bt_ctf_field_type_common_array_destroy_recursive(struct bt_object *obj) BT_LOGD("Destroying array field type object: addr=%p", ft); BT_LOGD_STR("Putting element field type."); - bt_put(ft->element_ft); + bt_object_put_ref(ft->element_ft); g_free(ft); } @@ -370,10 +370,10 @@ void bt_ctf_field_type_common_sequence_destroy_recursive(struct bt_object *obj) BT_LOGD("Destroying sequence field type object: addr=%p", ft); BT_LOGD_STR("Putting element field type."); - bt_put(ft->element_ft); + bt_object_put_ref(ft->element_ft); g_string_free(ft->length_field_name, TRUE); BT_LOGD_STR("Putting length field path."); - bt_put(ft->length_field_path); + bt_object_put_ref(ft->length_field_path); g_free(ft); } @@ -389,7 +389,7 @@ void bt_ctf_field_type_common_variant_choice_finalize( "addr=%p, field-ft-addr=%p, field-name=\"%s\"", choice, choice->type, g_quark_to_string(choice->name)); BT_LOGD_STR("Putting field type."); - bt_put(choice->type); + bt_object_put_ref(choice->type); if (choice->ranges) { g_array_free(choice->ranges, TRUE); @@ -427,9 +427,9 @@ void bt_ctf_field_type_common_variant_destroy_recursive(struct bt_object *obj) } BT_LOGD_STR("Putting tag field type."); - bt_put(ft->tag_ft); + bt_object_put_ref(ft->tag_ft); BT_LOGD_STR("Putting tag field path."); - bt_put(ft->tag_field_path); + bt_object_put_ref(ft->tag_field_path); g_free(ft); } @@ -568,7 +568,7 @@ int add_structure_variant_member(GArray *members, } *member_name = name_quark; - *member_ft = bt_get(field_type); + *member_ft = bt_object_get_ref(field_type); g_hash_table_insert(field_name_to_index, GUINT_TO_POINTER(name_quark), GUINT_TO_POINTER(members->len - 1)); @@ -609,7 +609,7 @@ void bt_ctf_field_type_enum_iter_destroy(struct bt_object *obj) BT_LOGD("Destroying enumeration field type mapping iterator: addr=%p", obj); BT_LOGD_STR("Putting parent enumeration field type."); - bt_put(iter->enumeration_ft); + bt_object_put_ref(iter->enumeration_ft); g_free(iter); } @@ -631,7 +631,7 @@ bt_ctf_field_type_common_enumeration_find_mappings_type( } bt_object_init_shared(&iter->base, bt_ctf_field_type_enum_iter_destroy); - iter->enumeration_ft = bt_get(ft); + iter->enumeration_ft = bt_object_get_ref(ft); iter->index = -1; iter->type = iterator_type; @@ -666,7 +666,7 @@ bt_ctf_field_type_common_enumeration_find_mappings_by_name( return iter; error: - bt_put(iter); + bt_object_put_ref(iter); return NULL; } @@ -773,7 +773,7 @@ bt_ctf_field_type_common_enumeration_signed_find_mappings_by_value( return iter; error: - bt_put(iter); + bt_object_put_ref(iter); return NULL; } @@ -804,7 +804,7 @@ bt_ctf_field_type_common_enumeration_unsigned_find_mappings_by_value( return iter; error: - bt_put(iter); + bt_object_put_ref(iter); return NULL; } @@ -1381,8 +1381,8 @@ int bt_ctf_field_type_common_integer_set_mapped_clock_class_no_check_frozen( goto end; } - bt_put(int_ft->mapped_clock_class); - int_ft->mapped_clock_class = bt_get(clock_class); + bt_object_put_ref(int_ft->mapped_clock_class); + int_ft->mapped_clock_class = bt_object_get_ref(clock_class); BT_LOGV("Set integer field type's mapped clock class: ft-addr=%p, " "clock-class-addr=%p, clock-class-name=\"%s\"", ft, clock_class, bt_ctf_clock_class_get_name(clock_class)); @@ -1832,8 +1832,8 @@ int bt_ctf_field_type_common_structure_replace_field( BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, i); if (field->name == name_quark) { - bt_put(field->type); - field->type = bt_get(field_type); + bt_object_put_ref(field->type); + field->type = bt_object_get_ref(field_type); } } @@ -2343,10 +2343,10 @@ int bt_ctf_field_type_common_array_set_element_field_type( } if (array_ft->element_ft) { - BT_PUT(array_ft->element_ft); + BT_OBJECT_PUT_REF_AND_RESET(array_ft->element_ft); } - array_ft->element_ft = bt_get(element_ft); + array_ft->element_ft = bt_object_get_ref(element_ft); BT_LOGV("Set array field type's element field type: array-ft-addr=%p, " "element-ft-addr=%p", ft, element_ft); @@ -2406,11 +2406,11 @@ int bt_ctf_field_type_common_sequence_set_element_field_type( } if (seq_ft->element_ft) { - BT_PUT(seq_ft->element_ft); + BT_OBJECT_PUT_REF_AND_RESET(seq_ft->element_ft); } seq_ft->element_ft = element_ft; - bt_get(seq_ft->element_ft); + bt_object_get_ref(seq_ft->element_ft); BT_LOGV("Set sequence field type's element field type: sequence-ft-addr=%p, " "element-ft-addr=%p", ft, element_ft); @@ -2925,8 +2925,8 @@ int bt_ctf_field_type_common_sequence_set_length_field_path( goto end; } - bt_get(path); - BT_MOVE(seq_ft->length_field_path, path); + bt_object_get_ref(path); + BT_OBJECT_MOVE_REF(seq_ft->length_field_path, path); BT_LOGV("Set sequence field type's length field path: ft-addr=%p, " "field-path-addr=%p", ft, path); @@ -2956,8 +2956,8 @@ int bt_ctf_field_type_common_variant_set_tag_field_path( goto end; } - bt_get(path); - BT_MOVE(var_ft->tag_field_path, path); + bt_object_get_ref(path); + BT_OBJECT_MOVE_REF(var_ft->tag_field_path, path); BT_LOGV("Set variant field type's tag field path: ft-addr=%p, " "field-path-addr=%p", ft, path); @@ -2993,8 +2993,8 @@ int bt_ctf_field_type_common_variant_set_tag_field_type( goto end; } - bt_put(var_ft->tag_ft); - var_ft->tag_ft = bt_get(tag_ft); + bt_object_put_ref(var_ft->tag_ft); + var_ft->tag_ft = bt_object_get_ref(tag_ft); BT_LOGV("Set variant field type's tag field type: variant-ft-addr=%p, " "tag-ft-addr=%p", ft, tag_ft); @@ -3093,7 +3093,7 @@ int bt_ctf_field_type_common_variant_update_choices(struct bt_ctf_field_type_com g_array_append_val(choice->ranges, range); } - bt_put(iter); + bt_object_put_ref(iter); } var_ft->choices_up_to_date = true; @@ -3891,7 +3891,7 @@ int bt_ctf_field_type_common_validate_single_clock_class( if (!*expected_clock_class) { /* Move reference to output parameter */ - *expected_clock_class = bt_get(mapped_clock_class); + *expected_clock_class = bt_object_get_ref(mapped_clock_class); mapped_clock_class = NULL; BT_LOGV("Setting expected clock class: " "expected-clock-class-addr=%p", @@ -3908,7 +3908,7 @@ int bt_ctf_field_type_common_validate_single_clock_class( bt_ctf_clock_class_get_name(mapped_clock_class), *expected_clock_class, bt_ctf_clock_class_get_name(*expected_clock_class)); - bt_put(mapped_clock_class); + bt_object_put_ref(mapped_clock_class); ret = -1; goto end; } @@ -4583,7 +4583,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_integer_create(unsigned int size) goto end; error: - BT_PUT(integer); + BT_OBJECT_PUT_REF_AND_RESET(integer); end: return (void *) integer; @@ -4641,7 +4641,7 @@ int bt_ctf_field_type_integer_set_encoding(struct bt_ctf_field_type *ft, struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class( struct bt_ctf_field_type *ft) { - return bt_get(bt_ctf_field_type_common_integer_borrow_mapped_clock_class( + return bt_object_get_ref(bt_ctf_field_type_common_integer_borrow_mapped_clock_class( (void *) ft)); } @@ -4710,7 +4710,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create( goto end; error: - BT_PUT(enumeration); + BT_OBJECT_PUT_REF_AND_RESET(enumeration); end: return (void *) enumeration; @@ -4719,7 +4719,7 @@ end: struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type( struct bt_ctf_field_type *ft) { - return bt_get( + return bt_object_get_ref( bt_ctf_field_type_common_enumeration_borrow_container_field_type( (void *) ft)); } @@ -4822,7 +4822,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void) goto end; error: - BT_PUT(structure); + BT_OBJECT_PUT_REF_AND_RESET(structure); end: return (void *) structure; @@ -4850,7 +4850,7 @@ int bt_ctf_field_type_structure_get_field_by_index( (void *) ft, field_name, (void *) field_type, index); if (ret == 0 && field_type) { - bt_get(*field_type); + bt_object_get_ref(*field_type); } return ret; @@ -4859,7 +4859,7 @@ int bt_ctf_field_type_structure_get_field_by_index( struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name( struct bt_ctf_field_type *ft, const char *name) { - return bt_get(bt_ctf_field_type_common_structure_borrow_field_type_by_name( + return bt_object_get_ref(bt_ctf_field_type_common_structure_borrow_field_type_by_name( (void *) ft, name)); } @@ -4897,7 +4897,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_create( goto end; error: - BT_PUT(var_ft); + BT_OBJECT_PUT_REF_AND_RESET(var_ft); end: return (void *) var_ft; @@ -4906,7 +4906,7 @@ end: struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type( struct bt_ctf_field_type *ft) { - return bt_get(bt_ctf_field_type_common_variant_borrow_tag_field_type( + return bt_object_get_ref(bt_ctf_field_type_common_variant_borrow_tag_field_type( (void *) ft)); } @@ -4933,7 +4933,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name( struct bt_ctf_field_type *ft, const char *field_name) { - return bt_get(bt_ctf_field_type_common_variant_borrow_field_type_by_name( + return bt_object_get_ref(bt_ctf_field_type_common_variant_borrow_field_type_by_name( (void *) ft, field_name)); } @@ -5005,7 +5005,7 @@ int bt_ctf_field_type_variant_get_field_by_index(struct bt_ctf_field_type *ft, (void *) ft, field_name, (void *) field_type, index); if (ret == 0 && field_type) { - bt_get(*field_type); + bt_object_get_ref(*field_type); } return ret; @@ -5047,7 +5047,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_array_create( goto end; error: - BT_PUT(array); + BT_OBJECT_PUT_REF_AND_RESET(array); end: return (void *) array; @@ -5056,7 +5056,7 @@ end: struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type( struct bt_ctf_field_type *ft) { - return bt_get(bt_ctf_field_type_common_array_borrow_element_field_type( + return bt_object_get_ref(bt_ctf_field_type_common_array_borrow_element_field_type( (void *) ft)); } @@ -5103,7 +5103,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_sequence_create( goto end; error: - BT_PUT(sequence); + BT_OBJECT_PUT_REF_AND_RESET(sequence); end: return (void *) sequence; @@ -5112,7 +5112,7 @@ end: struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type( struct bt_ctf_field_type *ft) { - return bt_get(bt_ctf_field_type_common_sequence_borrow_element_field_type( + return bt_object_get_ref(bt_ctf_field_type_common_sequence_borrow_element_field_type( (void *) ft)); } @@ -5206,7 +5206,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_integer_copy( goto end; } - copy_ft->mapped_clock_class = bt_get(int_ft->mapped_clock_class); + copy_ft->mapped_clock_class = bt_object_get_ref(int_ft->mapped_clock_class); copy_ft->user_byte_order = int_ft->user_byte_order; copy_ft->is_signed = int_ft->is_signed; copy_ft->size = int_ft->size; @@ -5266,12 +5266,12 @@ struct bt_ctf_field_type *bt_ctf_field_type_enumeration_copy_recursive( ft, copy_ft); end: - bt_put(container_copy_ft); + bt_object_put_ref(container_copy_ft); return (void *) copy_ft; error: - bt_put(container_copy_ft); - BT_PUT(copy_ft); + bt_object_put_ref(container_copy_ft); + BT_OBJECT_PUT_REF_AND_RESET(copy_ft); return (void *) copy_ft; } @@ -5359,7 +5359,7 @@ end: return (void *) copy_ft; error: - BT_PUT(copy_ft); + BT_OBJECT_PUT_REF_AND_RESET(copy_ft); return NULL; } @@ -5455,12 +5455,12 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_copy_recursive( ft, copy_ft); end: - bt_put(tag_ft_copy); + bt_object_put_ref(tag_ft_copy); return (void *) copy_ft; error: - bt_put(tag_ft_copy); - BT_PUT(copy_ft); + bt_object_put_ref(tag_ft_copy); + BT_OBJECT_PUT_REF_AND_RESET(copy_ft); return NULL; } @@ -5491,7 +5491,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_array_copy_recursive( ft, copy_ft); end: - bt_put(container_ft_copy); + bt_object_put_ref(container_ft_copy); return (void *) copy_ft; } @@ -5534,11 +5534,11 @@ struct bt_ctf_field_type *bt_ctf_field_type_sequence_copy_recursive( ft, copy_ft); end: - bt_put(container_ft_copy); + bt_object_put_ref(container_ft_copy); return (void *) copy_ft; error: - bt_put(container_ft_copy); - BT_PUT(copy_ft); + bt_object_put_ref(container_ft_copy); + BT_OBJECT_PUT_REF_AND_RESET(copy_ft); return NULL; } diff --git a/lib/ctf-writer/fields.c b/lib/ctf-writer/fields.c index c7cadabf..7583ad5b 100644 --- a/lib/ctf-writer/fields.c +++ b/lib/ctf-writer/fields.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -806,7 +806,7 @@ void bt_ctf_field_enumeration_destroy_recursive(struct bt_ctf_field *field) BT_LOGD("Destroying CTF writer enumeration field object: addr=%p", field); BT_LOGD_STR("Putting container field."); - bt_put(enumeration->container); + bt_object_put_ref(enumeration->container); bt_ctf_field_common_finalize((void *) field); g_free(field); } @@ -826,7 +826,7 @@ void bt_ctf_field_variant_destroy_recursive(struct bt_ctf_field *field) BT_LOGD("Destroying CTF writer variant field object: addr=%p", field); BT_LOGD_STR("Putting tag field."); - bt_put(variant->tag); + bt_object_put_ref(variant->tag); bt_ctf_field_common_variant_finalize_recursive((void *) field); g_free(field); } @@ -1184,8 +1184,8 @@ int bt_ctf_field_string_serialize(struct bt_ctf_field_common *field, } end: - bt_put(character); - bt_put(character_type); + bt_object_put_ref(character); + bt_object_put_ref(character_type); return ret; } @@ -1212,7 +1212,7 @@ end: struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field) { - return bt_get(bt_ctf_field_common_borrow_type((void *) field)); + return bt_object_get_ref(bt_ctf_field_common_borrow_type((void *) field)); } enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field) @@ -1253,28 +1253,28 @@ int bt_ctf_field_sequence_set_length(struct bt_ctf_field *field, struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index( struct bt_ctf_field *field, uint64_t index) { - return bt_get(bt_ctf_field_common_structure_borrow_field_by_index( + return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_index( (void *) field, index)); } struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name( struct bt_ctf_field *field, const char *name) { - return bt_get(bt_ctf_field_common_structure_borrow_field_by_name( + return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_name( (void *) field, name)); } struct bt_ctf_field *bt_ctf_field_array_get_field( struct bt_ctf_field *field, uint64_t index) { - return bt_get( + return bt_object_get_ref( bt_ctf_field_common_array_borrow_field((void *) field, index)); } struct bt_ctf_field *bt_ctf_field_sequence_get_field( struct bt_ctf_field *field, uint64_t index) { - return bt_get( + return bt_object_get_ref( bt_ctf_field_common_sequence_borrow_field((void *) field, index)); } @@ -1329,8 +1329,8 @@ struct bt_ctf_field *bt_ctf_field_variant_get_field(struct bt_ctf_field *field, goto end; } - bt_put(variant_field->tag); - variant_field->tag = bt_get(tag_field); + bt_object_put_ref(variant_field->tag); + variant_field->tag = bt_object_get_ref(tag_field); current_field = bt_ctf_field_variant_get_current_field(field); BT_ASSERT(current_field); @@ -1341,7 +1341,7 @@ end: struct bt_ctf_field *bt_ctf_field_variant_get_current_field( struct bt_ctf_field *variant_field) { - return bt_get(bt_ctf_field_common_variant_borrow_current_field( + return bt_object_get_ref(bt_ctf_field_common_variant_borrow_current_field( (void *) variant_field)); } @@ -1361,7 +1361,7 @@ struct bt_ctf_field *bt_ctf_field_enumeration_borrow_container( struct bt_ctf_field *bt_ctf_field_enumeration_get_container( struct bt_ctf_field *field) { - return bt_get(bt_ctf_field_enumeration_borrow_container(field)); + return bt_object_get_ref(bt_ctf_field_enumeration_borrow_container(field)); } int bt_ctf_field_integer_signed_get_value(struct bt_ctf_field *field, @@ -1528,7 +1528,7 @@ struct bt_ctf_field *bt_ctf_field_enumeration_create( enumeration->container = (void *) bt_ctf_field_create( BT_CTF_FROM_COMMON(enum_ft->container_ft)); if (!enumeration->container) { - BT_PUT(enumeration); + BT_OBJECT_PUT_REF_AND_RESET(enumeration); goto end; } @@ -1589,11 +1589,11 @@ struct bt_ctf_field *bt_ctf_field_structure_create( bt_ctf_field_structure_destroy_recursive, &bt_ctf_field_structure_methods, (bt_ctf_field_common_create_func) bt_ctf_field_create, - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); structure->common.spec.writer.serialize_func = (bt_ctf_field_serialize_recursive_func) bt_ctf_field_structure_serialize_recursive; if (iret) { - BT_PUT(structure); + BT_OBJECT_PUT_REF_AND_RESET(structure); goto end; } @@ -1624,7 +1624,7 @@ struct bt_ctf_field *bt_ctf_field_variant_create(struct bt_ctf_field_type *type) bt_ctf_field_variant_destroy_recursive, &bt_ctf_field_variant_methods, (bt_ctf_field_common_create_func) bt_ctf_field_create, - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); variant->tag = (void *) bt_ctf_field_create( BT_CTF_FROM_COMMON(var_ft->tag_ft)); variant->common.common.spec.writer.serialize_func = @@ -1657,11 +1657,11 @@ struct bt_ctf_field *bt_ctf_field_array_create(struct bt_ctf_field_type *type) bt_ctf_field_array_destroy_recursive, &bt_ctf_field_array_methods, (bt_ctf_field_common_create_func) bt_ctf_field_create, - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); array->common.spec.writer.serialize_func = (bt_ctf_field_serialize_recursive_func) bt_ctf_field_array_serialize_recursive; if (ret) { - BT_PUT(array); + BT_OBJECT_PUT_REF_AND_RESET(array); goto end; } @@ -1686,7 +1686,7 @@ struct bt_ctf_field *bt_ctf_field_sequence_create(struct bt_ctf_field_type *type true, (bt_object_release_func) bt_ctf_field_sequence_destroy_recursive, &bt_ctf_field_sequence_methods, - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); sequence->common.spec.writer.serialize_func = (bt_ctf_field_serialize_recursive_func) bt_ctf_field_sequence_serialize_recursive; BT_LOGD("Created CTF writer sequence field object: addr=%p, ft-addr=%p", @@ -1905,8 +1905,8 @@ int bt_ctf_field_structure_set_field_by_name(struct bt_ctf_field *field, ret = -1; goto end; } - bt_get(value); - BT_MOVE(structure->fields->pdata[index], value); + bt_object_get_ref(value); + BT_OBJECT_MOVE_REF(structure->fields->pdata[index], value); end: return ret; diff --git a/lib/ctf-writer/resolve.c b/lib/ctf-writer/resolve.c index 90ace158..c0388cd7 100644 --- a/lib/ctf-writer/resolve.c +++ b/lib/ctf-writer/resolve.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -115,7 +115,7 @@ void type_stack_destroy_notify(gpointer data) { struct type_stack_frame *frame = data; - BT_PUT(frame->type); + BT_OBJECT_PUT_REF_AND_RESET(frame->type); g_free(frame); } @@ -165,7 +165,7 @@ int type_stack_push(type_stack *stack, struct bt_ctf_field_type_common *type) BT_LOGV("Pushing field type on context's stack: " "ft-addr=%p, stack-size-before=%u", type, stack->len); - frame->type = bt_get(type); + frame->type = bt_object_get_ref(type); g_ptr_array_add(stack, frame); end: @@ -402,7 +402,7 @@ int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path, bt_bool first_level_done = BT_FALSE; /* Get our own reference */ - bt_get(type); + bt_object_get_ref(type); /* Locate target */ while (cur_ptoken) { @@ -460,12 +460,12 @@ int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path, } /* Move child type to current type */ - bt_get(child_type); - BT_MOVE(type, child_type); + bt_object_get_ref(child_type); + BT_OBJECT_MOVE_REF(type, child_type); } end: - bt_put(type); + bt_object_put_ref(type); return ret; } @@ -617,7 +617,7 @@ int relative_ptokens_to_field_path(GList *ptokens, } end: - BT_PUT(tail_field_path); + BT_OBJECT_PUT_REF_AND_RESET(tail_field_path); return ret; } @@ -704,7 +704,7 @@ struct bt_ctf_field_path *pathstr_to_field_path(const char *pathstr, end: if (ret) { - BT_PUT(field_path); + BT_OBJECT_PUT_REF_AND_RESET(field_path); } ptokens_destroy(ptokens); @@ -727,7 +727,7 @@ struct bt_ctf_field_type_common *field_path_to_field_type( /* Start with root type */ type = get_type_from_ctx(ctx, field_path->root); - bt_get(type); + bt_object_get_ref(type); if (!type) { /* Error: root type is not available */ BT_LOGW("Root field type is not available: root-scope=%s", @@ -751,14 +751,14 @@ struct bt_ctf_field_type_common *field_path_to_field_type( } /* Move child type to current type */ - bt_get(child_type); - BT_MOVE(type, child_type); + bt_object_get_ref(child_type); + BT_OBJECT_MOVE_REF(type, child_type); } return type; error: - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); return type; } @@ -792,7 +792,7 @@ struct bt_ctf_field_path *get_ctx_stack_field_path(struct resolve_context *ctx) return field_path; error: - BT_PUT(field_path); + BT_OBJECT_PUT_REF_AND_RESET(field_path); return field_path; } @@ -988,7 +988,7 @@ int validate_target_field_path(struct bt_ctf_field_path *target_field_path, } end: - BT_PUT(ctx_field_path); + BT_OBJECT_PUT_REF_AND_RESET(ctx_field_path); return ret; } @@ -1104,8 +1104,8 @@ end: g_string_free(target_field_path_pretty, TRUE); } - BT_PUT(target_field_path); - BT_PUT(target_type); + BT_OBJECT_PUT_REF_AND_RESET(target_field_path); + BT_OBJECT_PUT_REF_AND_RESET(target_type); return ret; } diff --git a/lib/ctf-writer/stream-class.c b/lib/ctf-writer/stream-class.c index 7e3b8518..63bf4a79 100644 --- a/lib/ctf-writer/stream-class.c +++ b/lib/ctf-writer/stream-class.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -84,7 +84,7 @@ void bt_ctf_stream_class_common_finalize(struct bt_ctf_stream_class_common *stre BT_LOGD("Finalizing common stream class: addr=%p, name=\"%s\", id=%" PRId64, stream_class, bt_ctf_stream_class_common_get_name(stream_class), bt_ctf_stream_class_common_get_id(stream_class)); - bt_put(stream_class->clock_class); + bt_object_put_ref(stream_class->clock_class); if (stream_class->event_classes_ht) { g_hash_table_destroy(stream_class->event_classes_ht); @@ -99,11 +99,11 @@ void bt_ctf_stream_class_common_finalize(struct bt_ctf_stream_class_common *stre } BT_LOGD_STR("Putting event header field type."); - bt_put(stream_class->event_header_field_type); + bt_object_put_ref(stream_class->event_header_field_type); BT_LOGD_STR("Putting packet context field type."); - bt_put(stream_class->packet_context_field_type); + bt_object_put_ref(stream_class->packet_context_field_type); BT_LOGD_STR("Putting event context field type."); - bt_put(stream_class->event_context_field_type); + bt_object_put_ref(stream_class->event_context_field_type); } static @@ -198,7 +198,7 @@ int bt_ctf_stream_class_common_add_event_class( * context) could change before the next call to one of * those two functions. */ - expected_clock_class = bt_get(stream_class->clock_class); + expected_clock_class = bt_object_get_ref(stream_class->clock_class); /* * At this point, `expected_clock_class` can be NULL, @@ -370,7 +370,7 @@ int bt_ctf_stream_class_common_add_event_class( if (stream_class->frozen && expected_clock_class) { BT_ASSERT(!stream_class->clock_class || stream_class->clock_class == expected_clock_class); - BT_MOVE(stream_class->clock_class, expected_clock_class); + BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class); } BT_LOGD("Added event class to stream class: " @@ -385,7 +385,7 @@ int bt_ctf_stream_class_common_add_event_class( end: bt_ctf_validation_output_put_types(&validation_output); - bt_put(expected_clock_class); + bt_object_put_ref(expected_clock_class); g_free(event_id); return ret; } @@ -587,18 +587,18 @@ int init_event_header(struct bt_ctf_stream_class *stream_class) goto end; } - bt_put(stream_class->common.event_header_field_type); + bt_object_put_ref(stream_class->common.event_header_field_type); stream_class->common.event_header_field_type = (void *) event_header_type; event_header_type = NULL; end: if (ret) { - bt_put(event_header_type); + bt_object_put_ref(event_header_type); } - bt_put(_uint32_t); - bt_put(_uint64_t); + bt_object_put_ref(_uint32_t); + bt_object_put_ref(_uint64_t); return ret; } @@ -664,19 +664,19 @@ int init_packet_context(struct bt_ctf_stream_class *stream_class) goto end; } - bt_put(stream_class->common.packet_context_field_type); + bt_object_put_ref(stream_class->common.packet_context_field_type); stream_class->common.packet_context_field_type = (void *) packet_context_type; packet_context_type = NULL; end: if (ret) { - bt_put(packet_context_type); + bt_object_put_ref(packet_context_type); goto end; } - bt_put(_uint64_t); - bt_put(ts_begin_end_uint64_t); + bt_object_put_ref(_uint64_t); + bt_object_put_ref(ts_begin_end_uint64_t); return ret; } @@ -690,7 +690,7 @@ void bt_ctf_stream_class_destroy(struct bt_object *obj) stream_class, bt_ctf_stream_class_get_name(stream_class), bt_ctf_stream_class_get_id(stream_class)); bt_ctf_stream_class_common_finalize(BT_CTF_TO_COMMON(stream_class)); - bt_put(stream_class->clock); + bt_object_put_ref(stream_class->clock); g_free(stream_class); } @@ -730,7 +730,7 @@ struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name) return stream_class; error: - BT_PUT(stream_class); + BT_OBJECT_PUT_REF_AND_RESET(stream_class); return stream_class; } @@ -781,7 +781,7 @@ int try_map_clock_class(struct bt_ctf_stream_class *stream_class, ret = bt_ctf_field_type_common_structure_replace_field( (void *) parent_ft, field_name, (void *) ft_copy); - bt_put(ft_copy); + bt_object_put_ref(ft_copy); BT_LOGV("Automatically mapped field type to stream class's clock class: " "stream-class-addr=%p, stream-class-name=\"%s\", " "stream-class-id=%" PRId64 ", ft-addr=%p, " @@ -792,8 +792,8 @@ int try_map_clock_class(struct bt_ctf_stream_class *stream_class, } end: - bt_put(ft); - bt_put(mapped_clock_class); + bt_object_put_ref(ft); + bt_object_put_ref(mapped_clock_class); return ret; } @@ -860,7 +860,7 @@ struct bt_ctf_clock *bt_ctf_stream_class_get_clock( goto end; } - clock = bt_get(stream_class->clock); + clock = bt_object_get_ref(stream_class->clock); end: return clock; @@ -891,8 +891,8 @@ int bt_ctf_stream_class_set_clock( } /* Replace the current clock of this stream class. */ - bt_put(stream_class->clock); - stream_class->clock = bt_get(clock); + bt_object_put_ref(stream_class->clock); + stream_class->clock = bt_object_get_ref(clock); BT_LOGV("Set stream class's clock: " "addr=%p, name=\"%s\", id=%" PRId64 ", " "clock-addr=%p, clock-name=\"%s\"", @@ -961,7 +961,7 @@ int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class, "\tid = %" PRId64 ";\n", stream_class->common.id); } - bt_put(stream_id_type); + bt_object_put_ref(stream_id_type); } if (stream_class->common.event_header_field_type) { BT_LOGD_STR("Serializing stream class's event header field type's metadata."); @@ -1025,7 +1025,7 @@ int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class, } end: - bt_put(packet_header_type); + bt_object_put_ref(packet_header_type); context->current_indentation_level = 0; return ret; } @@ -1033,7 +1033,7 @@ end: struct bt_ctf_trace *bt_ctf_stream_class_get_trace( struct bt_ctf_stream_class *stream_class) { - return bt_get(bt_ctf_stream_class_common_borrow_trace( + return bt_object_get_ref(bt_ctf_stream_class_common_borrow_trace( BT_CTF_TO_COMMON(stream_class))); } @@ -1065,7 +1065,7 @@ int bt_ctf_stream_class_set_id( struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type( struct bt_ctf_stream_class *stream_class) { - return bt_get( + return bt_object_get_ref( bt_ctf_stream_class_common_borrow_packet_context_field_type( BT_CTF_TO_COMMON(stream_class))); } @@ -1082,7 +1082,7 @@ struct bt_ctf_field_type * bt_ctf_stream_class_get_event_header_type( struct bt_ctf_stream_class *stream_class) { - return bt_get( + return bt_object_get_ref( bt_ctf_stream_class_common_borrow_event_header_field_type( BT_CTF_TO_COMMON(stream_class))); } @@ -1099,7 +1099,7 @@ struct bt_ctf_field_type * bt_ctf_stream_class_get_event_context_type( struct bt_ctf_stream_class *stream_class) { - return bt_get( + return bt_object_get_ref( bt_ctf_stream_class_common_borrow_event_context_field_type( BT_CTF_TO_COMMON(stream_class))); } @@ -1122,7 +1122,7 @@ int64_t bt_ctf_stream_class_get_event_class_count( struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index( struct bt_ctf_stream_class *stream_class, uint64_t index) { - return bt_get( + return bt_object_get_ref( bt_ctf_stream_class_common_borrow_event_class_by_index( BT_CTF_TO_COMMON(stream_class), index)); } @@ -1130,7 +1130,7 @@ struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index( struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id( struct bt_ctf_stream_class *stream_class, uint64_t id) { - return bt_get( + return bt_object_get_ref( bt_ctf_stream_class_common_borrow_event_class_by_id( BT_CTF_TO_COMMON(stream_class), id)); } diff --git a/lib/ctf-writer/stream.c b/lib/ctf-writer/stream.c index 455027ce..6fedfb68 100644 --- a/lib/ctf-writer/stream.c +++ b/lib/ctf-writer/stream.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -191,7 +191,7 @@ int set_integer_field_value(struct bt_ctf_field* field, uint64_t value) } } end: - bt_put(field_type); + bt_object_put_ref(field_type); return ret; } @@ -228,7 +228,7 @@ int set_packet_header_magic(struct bt_ctf_stream *stream) magic_field, (uint64_t) magic_value); } end: - bt_put(magic_field); + bt_object_put_ref(magic_field); return ret; } @@ -260,7 +260,7 @@ int set_packet_header_uuid(struct bt_ctf_stream *stream) ret = bt_ctf_field_integer_unsigned_set_value( uuid_element, (uint64_t) trace->common.uuid[i]); - bt_put(uuid_element); + bt_object_put_ref(uuid_element); if (ret) { BT_LOGW("Cannot set integer field's value (for `uuid` packet header field): " "stream-addr=%p, stream-name=\"%s\", field-addr=%p, " @@ -276,8 +276,8 @@ int set_packet_header_uuid(struct bt_ctf_stream *stream) stream, bt_ctf_stream_get_name(stream), uuid_field); end: - bt_put(uuid_field); - BT_PUT(trace); + bt_object_put_ref(uuid_field); + BT_OBJECT_PUT_REF_AND_RESET(trace); return ret; } static @@ -313,7 +313,7 @@ int set_packet_header_stream_id(struct bt_ctf_stream *stream) } end: - bt_put(stream_id_field); + bt_object_put_ref(stream_id_field); return ret; } @@ -390,7 +390,7 @@ int set_packet_context_packet_size(struct bt_ctf_stream *stream) } end: - bt_put(field); + bt_object_put_ref(field); return ret; } @@ -426,7 +426,7 @@ int set_packet_context_content_size(struct bt_ctf_stream *stream) } end: - bt_put(field); + bt_object_put_ref(field); return ret; } @@ -494,7 +494,7 @@ int set_packet_context_events_discarded(struct bt_ctf_stream *stream) } end: - bt_put(field); + bt_object_put_ref(field); return ret; } @@ -554,7 +554,7 @@ int visit_field_update_clock_value(struct bt_ctf_field *field, uint64_t *val) goto end; } - bt_put(cc); + bt_object_put_ref(cc); val_size = bt_ctf_field_type_integer_get_size( (void *) field_common->type); BT_ASSERT(val_size >= 1); @@ -584,7 +584,7 @@ int visit_field_update_clock_value(struct bt_ctf_field *field, uint64_t *val) BT_ASSERT(int_field); ret = visit_field_update_clock_value(int_field, val); - bt_put(int_field); + bt_object_put_ref(int_field); break; } case BT_CTF_FIELD_TYPE_ID_ARRAY: @@ -601,7 +601,7 @@ int visit_field_update_clock_value(struct bt_ctf_field *field, uint64_t *val) BT_ASSERT(elem_field); ret = visit_field_update_clock_value(elem_field, val); - bt_put(elem_field); + bt_object_put_ref(elem_field); if (ret) { goto end; } @@ -625,7 +625,7 @@ int visit_field_update_clock_value(struct bt_ctf_field *field, uint64_t *val) BT_ASSERT(elem_field); ret = visit_field_update_clock_value(elem_field, val); - bt_put(elem_field); + bt_object_put_ref(elem_field); if (ret) { goto end; } @@ -646,7 +646,7 @@ int visit_field_update_clock_value(struct bt_ctf_field *field, uint64_t *val) BT_ASSERT(member_field); ret = visit_field_update_clock_value(member_field, val); - bt_put(member_field); + bt_object_put_ref(member_field); if (ret) { goto end; } @@ -664,7 +664,7 @@ int visit_field_update_clock_value(struct bt_ctf_field *field, uint64_t *val) } ret = visit_field_update_clock_value(cur_field, val); - bt_put(cur_field); + bt_object_put_ref(cur_field); break; } default: @@ -682,7 +682,7 @@ int visit_event_update_clock_value(struct bt_ctf_event *event, uint64_t *val) field = bt_ctf_event_get_header(event); ret = visit_field_update_clock_value(field, val); - bt_put(field); + bt_object_put_ref(field); if (ret) { BT_LOGW_STR("Cannot automatically update clock value in " "event's header."); @@ -691,7 +691,7 @@ int visit_event_update_clock_value(struct bt_ctf_event *event, uint64_t *val) field = bt_ctf_event_get_stream_event_context(event); ret = visit_field_update_clock_value(field, val); - bt_put(field); + bt_object_put_ref(field); if (ret) { BT_LOGW_STR("Cannot automatically update clock value in " "event's stream event context."); @@ -700,7 +700,7 @@ int visit_event_update_clock_value(struct bt_ctf_event *event, uint64_t *val) field = bt_ctf_event_get_context(event); ret = visit_field_update_clock_value(field, val); - bt_put(field); + bt_object_put_ref(field); if (ret) { BT_LOGW_STR("Cannot automatically update clock value in " "event's context."); @@ -709,7 +709,7 @@ int visit_event_update_clock_value(struct bt_ctf_event *event, uint64_t *val) field = bt_ctf_event_get_payload_field(event); ret = visit_field_update_clock_value(field, val); - bt_put(field); + bt_object_put_ref(field); if (ret) { BT_LOGW_STR("Cannot automatically update clock value in " "event's payload."); @@ -796,31 +796,31 @@ int set_packet_context_timestamps(struct bt_ctf_stream *stream) if (strcmp(member_name, "packet_size") == 0 && !bt_ctf_field_is_set_recursive(member_field)) { - bt_put(member_field); + bt_object_put_ref(member_field); continue; } if (strcmp(member_name, "content_size") == 0 && !bt_ctf_field_is_set_recursive(member_field)) { - bt_put(member_field); + bt_object_put_ref(member_field); continue; } if (strcmp(member_name, "events_discarded") == 0 && !bt_ctf_field_is_set_recursive(member_field)) { - bt_put(member_field); + bt_object_put_ref(member_field); continue; } if (strcmp(member_name, "packet_seq_num") == 0 && !bt_ctf_field_is_set_recursive(member_field)) { - bt_put(member_field); + bt_object_put_ref(member_field); continue; } ret = visit_field_update_clock_value(member_field, &cur_clock_value); - bt_put(member_field); + bt_object_put_ref(member_field); if (ret) { BT_LOGW("Cannot automatically update clock value " "in stream's packet context: " @@ -894,8 +894,8 @@ int set_packet_context_timestamps(struct bt_ctf_stream *stream) } end: - bt_put(ts_begin_field); - bt_put(ts_end_field); + bt_object_put_ref(ts_begin_field); + bt_object_put_ref(ts_end_field); return ret; } @@ -959,8 +959,8 @@ void release_event(struct bt_ctf_event *event) * existence of its event class for the duration of its * lifetime. */ - bt_get(event->common.class); - BT_PUT(event->common.base.parent); + bt_object_get_ref(event->common.class); + BT_OBJECT_PUT_REF_AND_RESET(event->common.base.parent); } else { bt_object_try_spec_release(&event->common.base); } @@ -1187,10 +1187,10 @@ struct bt_ctf_stream *bt_ctf_stream_create_with_id( goto end; error: - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); end: - bt_put(writer); + bt_object_put_ref(writer); return stream; } @@ -1260,7 +1260,7 @@ int set_packet_context_events_discarded_field(struct bt_ctf_stream *stream, } end: - bt_put(events_discarded_field); + bt_object_put_ref(events_discarded_field); return ret; } @@ -1317,7 +1317,7 @@ void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream, stream, bt_ctf_stream_get_name(stream), event_count); end: - bt_put(events_discarded_field); + bt_object_put_ref(events_discarded_field); } static int auto_populate_event_header(struct bt_ctf_stream *stream, @@ -1404,9 +1404,9 @@ static int auto_populate_event_header(struct bt_ctf_stream *stream, stream, bt_ctf_stream_get_name(stream), event); end: - bt_put(id_field); - bt_put(timestamp_field); - bt_put(mapped_clock_class); + bt_object_put_ref(id_field); + bt_object_put_ref(timestamp_field); + bt_object_put_ref(mapped_clock_class); return ret; } @@ -1480,7 +1480,7 @@ int bt_ctf_stream_append_event(struct bt_ctf_stream *stream, * longer needed. */ BT_LOGV_STR("Putting the event's class."); - bt_put(event->common.class); + bt_object_put_ref(event->common.class); BT_LOGV("Appended event to stream: " "stream-addr=%p, stream-name=\"%s\", event-addr=%p, " "event-class-name=\"%s\", event-class-id=%" PRId64, @@ -1520,7 +1520,7 @@ struct bt_ctf_field *bt_ctf_stream_get_packet_context(struct bt_ctf_stream *stre packet_context = stream->packet_context; if (packet_context) { - bt_get(packet_context); + bt_object_get_ref(packet_context); } end: return packet_context; @@ -1557,9 +1557,9 @@ int bt_ctf_stream_set_packet_context(struct bt_ctf_stream *stream, goto end; } - bt_put(field_type); - bt_put(stream->packet_context); - stream->packet_context = bt_get(field); + bt_object_put_ref(field_type); + bt_object_put_ref(stream->packet_context); + stream->packet_context = bt_object_get_ref(field); BT_LOGV("Set stream's packet context field: " "stream-addr=%p, stream-name=\"%s\", " "packet-context-field-addr=%p", @@ -1586,7 +1586,7 @@ struct bt_ctf_field *bt_ctf_stream_get_packet_header(struct bt_ctf_stream *strea packet_header = stream->packet_header; if (packet_header) { - bt_get(packet_header); + bt_object_get_ref(packet_header); } end: return packet_header; @@ -1645,15 +1645,15 @@ int bt_ctf_stream_set_packet_header(struct bt_ctf_stream *stream, } skip_validation: - bt_put(stream->packet_header); - stream->packet_header = bt_get(field); + bt_object_put_ref(stream->packet_header); + stream->packet_header = bt_object_get_ref(field); BT_LOGV("Set stream's packet header field: " "stream-addr=%p, stream-name=\"%s\", " "packet-header-field-addr=%p", stream, bt_ctf_stream_get_name(stream), field); end: - BT_PUT(trace); - bt_put(field_type); + BT_OBJECT_PUT_REF_AND_RESET(trace); + bt_object_put_ref(field_type); return ret; } @@ -1665,7 +1665,7 @@ void reset_structure_field(struct bt_ctf_field *structure, const char *name) member = bt_ctf_field_structure_get_field_by_name(structure, name); if (member) { bt_ctf_field_common_reset_recursive((void *) member); - bt_put(member); + bt_object_put_ref(member); } } @@ -1696,7 +1696,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream) packet_size_field = bt_ctf_field_structure_get_field_by_name( stream->packet_context, "packet_size"); has_packet_size = (packet_size_field != NULL); - bt_put(packet_size_field); + bt_object_put_ref(packet_size_field); } if (stream->flushed_packet_count == 1) { @@ -1846,7 +1846,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream) struct bt_ctf_field *field = bt_ctf_field_structure_get_field_by_name( stream->packet_context, "content_size"); - bt_put(field); + bt_object_put_ref(field); if (!field) { if (stream->pos.offset != stream->pos.packet_size) { BT_LOGW("Stream's packet context's `content_size` field is missing, " @@ -1958,9 +1958,9 @@ void bt_ctf_stream_destroy(struct bt_object *obj) } BT_LOGD_STR("Putting packet header field."); - bt_put(stream->packet_header); + bt_object_put_ref(stream->packet_header); BT_LOGD_STR("Putting packet context field."); - bt_put(stream->packet_context); + bt_object_put_ref(stream->packet_context); g_free(stream); } @@ -2016,8 +2016,8 @@ int _set_structure_field_integer(struct bt_ctf_field *structure, char *name, } ret = !ret ? 1 : ret; end: - bt_put(integer); - bt_put(field_type); + bt_object_put_ref(integer); + bt_object_put_ref(field_type); return ret; } @@ -2037,7 +2037,7 @@ int try_set_structure_field_integer(struct bt_ctf_field *structure, char *name, struct bt_ctf_stream_class *bt_ctf_stream_get_class( struct bt_ctf_stream *stream) { - return bt_get(bt_ctf_stream_common_borrow_class(BT_CTF_TO_COMMON(stream))); + return bt_object_get_ref(bt_ctf_stream_common_borrow_class(BT_CTF_TO_COMMON(stream))); } const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream) diff --git a/lib/ctf-writer/trace.c b/lib/ctf-writer/trace.c index 0ab61ab8..24842faa 100644 --- a/lib/ctf-writer/trace.c +++ b/lib/ctf-writer/trace.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -66,7 +66,7 @@ int bt_ctf_trace_common_initialize(struct bt_ctf_trace_common *trace, trace->native_byte_order = BT_CTF_BYTE_ORDER_UNSPECIFIED; bt_object_init_shared_with_parent(&trace->base, release_func); trace->clock_classes = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); if (!trace->clock_classes) { BT_LOGE_STR("Failed to allocate one GPtrArray."); goto error; @@ -134,7 +134,7 @@ void bt_ctf_trace_common_finalize(struct bt_ctf_trace_common *trace) } BT_LOGD_STR("Putting packet header field type."); - bt_put(trace->packet_header_field_type); + bt_object_put_ref(trace->packet_header_field_type); } BT_HIDDEN @@ -337,7 +337,7 @@ int bt_ctf_trace_common_set_environment_field_string(struct bt_ctf_trace_common env_value_string_obj); end: - bt_put(env_value_string_obj); + bt_object_put_ref(env_value_string_obj); return ret; } @@ -360,7 +360,7 @@ int bt_ctf_trace_common_set_environment_field_integer( env_value_integer_obj); end: - bt_put(env_value_integer_obj); + bt_object_put_ref(env_value_integer_obj); return ret; } @@ -397,7 +397,7 @@ int bt_ctf_trace_common_add_clock_class(struct bt_ctf_trace_common *trace, goto end; } - bt_get(clock_class); + bt_object_get_ref(clock_class); g_ptr_array_add(trace->clock_classes, clock_class); if (trace->frozen) { @@ -867,7 +867,7 @@ int check_packet_header_type_has_no_clock_class(struct bt_ctf_trace_common *trac ret = bt_ctf_field_type_common_validate_single_clock_class( trace->packet_header_field_type, &clock_class); - bt_put(clock_class); + bt_object_put_ref(clock_class); if (ret || clock_class) { BT_LOGW("Trace's packet header field type cannot " "contain a field type which is mapped to " @@ -912,7 +912,7 @@ int bt_ctf_trace_common_add_stream_class(struct bt_ctf_trace_common *trace, int64_t event_class_count; struct bt_ctf_trace_common *current_parent_trace = NULL; struct bt_ctf_clock_class *expected_clock_class = - bt_get(init_expected_clock_class); + bt_object_get_ref(init_expected_clock_class); BT_ASSERT(copy_field_type_func); @@ -1236,7 +1236,7 @@ int bt_ctf_trace_common_add_stream_class(struct bt_ctf_trace_common *trace, * now because the stream class is frozen. */ if (expected_clock_class) { - BT_MOVE(stream_class->clock_class, expected_clock_class); + BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class); } BT_LOGD("Added stream class to trace: " @@ -1261,7 +1261,7 @@ end: g_free(ec_validation_outputs); bt_ctf_validation_output_put_types(&trace_sc_validation_output); - bt_put(expected_clock_class); + bt_object_put_ref(expected_clock_class); return ret; } @@ -1359,8 +1359,8 @@ int bt_ctf_trace_common_set_packet_header_field_type(struct bt_ctf_trace_common goto end; } - bt_put(trace->packet_header_field_type); - trace->packet_header_field_type = bt_get(packet_header_type); + bt_object_put_ref(trace->packet_header_field_type); + trace->packet_header_field_type = bt_object_get_ref(packet_header_type); BT_LOGV("Set trace's packet header field type: " "addr=%p, name=\"%s\", packet-context-ft-addr=%p", trace, bt_ctf_trace_common_get_name(trace), packet_header_type); @@ -1452,7 +1452,7 @@ struct bt_ctf_trace *bt_ctf_trace_create(void) return trace; error: - BT_PUT(trace); + BT_OBJECT_PUT_REF_AND_RESET(trace); return trace; } @@ -1504,14 +1504,14 @@ bt_ctf_trace_get_environment_field_name_by_index(struct bt_ctf_trace *trace, struct bt_value *bt_ctf_trace_get_environment_field_value_by_index( struct bt_ctf_trace *trace, uint64_t index) { - return bt_get(bt_ctf_trace_common_borrow_environment_field_value_by_index( + return bt_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_index( BT_CTF_TO_COMMON(trace), index)); } struct bt_value *bt_ctf_trace_get_environment_field_value_by_name( struct bt_ctf_trace *trace, const char *name) { - return bt_get(bt_ctf_trace_common_borrow_environment_field_value_by_name( + return bt_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_name( BT_CTF_TO_COMMON(trace), name)); } @@ -1533,7 +1533,7 @@ BT_HIDDEN struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index( struct bt_ctf_trace *trace, uint64_t index) { - return bt_get(bt_ctf_trace_common_borrow_clock_class_by_index( + return bt_object_get_ref(bt_ctf_trace_common_borrow_clock_class_by_index( BT_CTF_TO_COMMON(trace), index)); } @@ -1650,7 +1650,7 @@ int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace) struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index( struct bt_ctf_trace *trace, uint64_t index) { - return bt_get(bt_ctf_trace_common_borrow_stream_by_index( + return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_by_index( BT_CTF_TO_COMMON(trace), index)); } @@ -1662,14 +1662,14 @@ int64_t bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace) struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index( struct bt_ctf_trace *trace, uint64_t index) { - return bt_get(bt_ctf_trace_common_borrow_stream_class_by_index( + return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_index( BT_CTF_TO_COMMON(trace), index)); } struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id( struct bt_ctf_trace *trace, uint64_t id) { - return bt_get(bt_ctf_trace_common_borrow_stream_class_by_id( + return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_id( BT_CTF_TO_COMMON(trace), id)); } @@ -1677,7 +1677,7 @@ BT_HIDDEN struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name( struct bt_ctf_trace *trace, const char *name) { - return bt_get( + return bt_object_get_ref( bt_ctf_trace_common_borrow_clock_class_by_name(BT_CTF_TO_COMMON(trace), name)); } @@ -1872,7 +1872,7 @@ int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace, struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_field_type( struct bt_ctf_trace *trace) { - return bt_get(bt_ctf_trace_common_borrow_packet_header_field_type( + return bt_object_get_ref(bt_ctf_trace_common_borrow_packet_header_field_type( BT_CTF_TO_COMMON(trace))); } diff --git a/lib/ctf-writer/utils.c b/lib/ctf-writer/utils.c index 67c4ecaf..17cc4c0b 100644 --- a/lib/ctf-writer/utils.c +++ b/lib/ctf-writer/utils.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/ctf-writer/validation.c b/lib/ctf-writer/validation.c index 92e56268..15309b2a 100644 --- a/lib/ctf-writer/validation.c +++ b/lib/ctf-writer/validation.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include /* @@ -309,12 +309,12 @@ int bt_ctf_validate_class_types(struct bt_value *environment, } /* Own the type parameters */ - bt_get(packet_header_type); - bt_get(packet_context_type); - bt_get(event_header_type); - bt_get(stream_event_ctx_type); - bt_get(event_context_type); - bt_get(event_payload_type); + bt_object_get_ref(packet_header_type); + bt_object_get_ref(packet_context_type); + bt_object_get_ref(event_header_type); + bt_object_get_ref(stream_event_ctx_type); + bt_object_get_ref(event_context_type); + bt_object_get_ref(event_payload_type); /* Validate trace */ if ((validate_flags & BT_CTF_VALIDATION_FLAG_TRACE) && !trace_valid) { @@ -331,7 +331,7 @@ int bt_ctf_validate_class_types(struct bt_value *environment, } else if (!contains_seq_var) { /* No copy is needed */ packet_header_type_copy = packet_header_type; - bt_get(packet_header_type_copy); + bt_object_get_ref(packet_header_type_copy); goto skip_packet_header_type_copy; } @@ -354,7 +354,7 @@ int bt_ctf_validate_class_types(struct bt_value *environment, skip_packet_header_type_copy: /* Put original reference and move copy */ - BT_MOVE(packet_header_type, packet_header_type_copy); + BT_OBJECT_MOVE_REF(packet_header_type, packet_header_type_copy); /* Validate trace field types */ valid_ret = validate_trace_types(environment, @@ -382,7 +382,7 @@ skip_packet_header_type_copy: } else if (!contains_seq_var) { /* No copy is needed */ packet_context_type_copy = packet_context_type; - bt_get(packet_context_type_copy); + bt_object_get_ref(packet_context_type_copy); goto skip_packet_context_type_copy; } @@ -413,7 +413,7 @@ skip_packet_context_type_copy: } else if (!contains_seq_var) { /* No copy is needed */ event_header_type_copy = event_header_type; - bt_get(event_header_type_copy); + bt_object_get_ref(event_header_type_copy); goto skip_event_header_type_copy; } @@ -445,7 +445,7 @@ skip_event_header_type_copy: /* No copy is needed */ stream_event_ctx_type_copy = stream_event_ctx_type; - bt_get(stream_event_ctx_type_copy); + bt_object_get_ref(stream_event_ctx_type_copy); goto skip_stream_event_ctx_type_copy; } @@ -467,9 +467,9 @@ skip_event_header_type_copy: skip_stream_event_ctx_type_copy: /* Put original references and move copies */ - BT_MOVE(packet_context_type, packet_context_type_copy); - BT_MOVE(event_header_type, event_header_type_copy); - BT_MOVE(stream_event_ctx_type, stream_event_ctx_type_copy); + BT_OBJECT_MOVE_REF(packet_context_type, packet_context_type_copy); + BT_OBJECT_MOVE_REF(event_header_type, event_header_type_copy); + BT_OBJECT_MOVE_REF(stream_event_ctx_type, stream_event_ctx_type_copy); /* Validate stream class field types */ valid_ret = validate_stream_class_types(environment, @@ -483,9 +483,9 @@ skip_stream_event_ctx_type_copy: goto sc_validation_done; sc_validation_error: - BT_PUT(packet_context_type_copy); - BT_PUT(event_header_type_copy); - BT_PUT(stream_event_ctx_type_copy); + BT_OBJECT_PUT_REF_AND_RESET(packet_context_type_copy); + BT_OBJECT_PUT_REF_AND_RESET(event_header_type_copy); + BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type_copy); ret = -1; goto error; } @@ -507,7 +507,7 @@ sc_validation_done: } else if (!contains_seq_var) { /* No copy is needed */ event_context_type_copy = event_context_type; - bt_get(event_context_type_copy); + bt_object_get_ref(event_context_type_copy); goto skip_event_context_type_copy; } @@ -538,7 +538,7 @@ skip_event_context_type_copy: } else if (!contains_seq_var) { /* No copy is needed */ event_payload_type_copy = event_payload_type; - bt_get(event_payload_type_copy); + bt_object_get_ref(event_payload_type_copy); goto skip_event_payload_type_copy; } @@ -560,8 +560,8 @@ skip_event_context_type_copy: skip_event_payload_type_copy: /* Put original references and move copies */ - BT_MOVE(event_context_type, event_context_type_copy); - BT_MOVE(event_payload_type, event_payload_type_copy); + BT_OBJECT_MOVE_REF(event_context_type, event_context_type_copy); + BT_OBJECT_MOVE_REF(event_payload_type, event_payload_type_copy); /* Validate event class field types */ valid_ret = validate_event_class_types(environment, @@ -576,8 +576,8 @@ skip_event_payload_type_copy: goto ec_validation_done; ec_validation_error: - BT_PUT(event_context_type_copy); - BT_PUT(event_payload_type_copy); + BT_OBJECT_PUT_REF_AND_RESET(event_context_type_copy); + BT_OBJECT_PUT_REF_AND_RESET(event_payload_type_copy); ret = -1; goto error; } @@ -588,21 +588,21 @@ ec_validation_done: * to validate (and that were possibly altered by the validation * process) to the output values. */ - BT_MOVE(output->packet_header_type, packet_header_type); - BT_MOVE(output->packet_context_type, packet_context_type); - BT_MOVE(output->event_header_type, event_header_type); - BT_MOVE(output->stream_event_ctx_type, stream_event_ctx_type); - BT_MOVE(output->event_context_type, event_context_type); - BT_MOVE(output->event_payload_type, event_payload_type); + BT_OBJECT_MOVE_REF(output->packet_header_type, packet_header_type); + BT_OBJECT_MOVE_REF(output->packet_context_type, packet_context_type); + BT_OBJECT_MOVE_REF(output->event_header_type, event_header_type); + BT_OBJECT_MOVE_REF(output->stream_event_ctx_type, stream_event_ctx_type); + BT_OBJECT_MOVE_REF(output->event_context_type, event_context_type); + BT_OBJECT_MOVE_REF(output->event_payload_type, event_payload_type); return ret; error: - BT_PUT(packet_header_type); - BT_PUT(packet_context_type); - BT_PUT(event_header_type); - BT_PUT(stream_event_ctx_type); - BT_PUT(event_context_type); - BT_PUT(event_payload_type); + BT_OBJECT_PUT_REF_AND_RESET(packet_header_type); + BT_OBJECT_PUT_REF_AND_RESET(packet_context_type); + BT_OBJECT_PUT_REF_AND_RESET(event_header_type); + BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type); + BT_OBJECT_PUT_REF_AND_RESET(event_context_type); + BT_OBJECT_PUT_REF_AND_RESET(event_payload_type); return ret; } @@ -615,7 +615,7 @@ void bt_ctf_validation_replace_types(struct bt_ctf_trace_common *trace, { if ((replace_flags & BT_CTF_VALIDATION_FLAG_TRACE) && trace) { bt_ctf_field_type_common_freeze(trace->packet_header_field_type); - BT_MOVE(trace->packet_header_field_type, + BT_OBJECT_MOVE_REF(trace->packet_header_field_type, output->packet_header_type); } @@ -623,19 +623,19 @@ void bt_ctf_validation_replace_types(struct bt_ctf_trace_common *trace, bt_ctf_field_type_common_freeze(stream_class->packet_context_field_type); bt_ctf_field_type_common_freeze(stream_class->event_header_field_type); bt_ctf_field_type_common_freeze(stream_class->event_context_field_type); - BT_MOVE(stream_class->packet_context_field_type, + BT_OBJECT_MOVE_REF(stream_class->packet_context_field_type, output->packet_context_type); - BT_MOVE(stream_class->event_header_field_type, + BT_OBJECT_MOVE_REF(stream_class->event_header_field_type, output->event_header_type); - BT_MOVE(stream_class->event_context_field_type, + BT_OBJECT_MOVE_REF(stream_class->event_context_field_type, output->stream_event_ctx_type); } if ((replace_flags & BT_CTF_VALIDATION_FLAG_EVENT) && event_class) { bt_ctf_field_type_common_freeze(event_class->context_field_type); bt_ctf_field_type_common_freeze(event_class->payload_field_type); - BT_MOVE(event_class->context_field_type, output->event_context_type); - BT_MOVE(event_class->payload_field_type, output->event_payload_type); + BT_OBJECT_MOVE_REF(event_class->context_field_type, output->event_context_type); + BT_OBJECT_MOVE_REF(event_class->payload_field_type, output->event_payload_type); } } @@ -643,10 +643,10 @@ BT_HIDDEN void bt_ctf_validation_output_put_types( struct bt_ctf_validation_output *output) { - BT_PUT(output->packet_header_type); - BT_PUT(output->packet_context_type); - BT_PUT(output->event_header_type); - BT_PUT(output->stream_event_ctx_type); - BT_PUT(output->event_context_type); - BT_PUT(output->event_payload_type); + BT_OBJECT_PUT_REF_AND_RESET(output->packet_header_type); + BT_OBJECT_PUT_REF_AND_RESET(output->packet_context_type); + BT_OBJECT_PUT_REF_AND_RESET(output->event_header_type); + BT_OBJECT_PUT_REF_AND_RESET(output->stream_event_ctx_type); + BT_OBJECT_PUT_REF_AND_RESET(output->event_context_type); + BT_OBJECT_PUT_REF_AND_RESET(output->event_payload_type); } diff --git a/lib/ctf-writer/visitor.c b/lib/ctf-writer/visitor.c index 726512c6..e416e7be 100644 --- a/lib/ctf-writer/visitor.c +++ b/lib/ctf-writer/visitor.c @@ -27,7 +27,7 @@ */ #include -#include +#include BT_HIDDEN int bt_ctf_visitor_helper(struct bt_ctf_visitor_object *root, @@ -59,7 +59,7 @@ int bt_ctf_visitor_helper(struct bt_ctf_visitor_object *root, goto end; } ret = child_visitor(child, visitor, data); - BT_PUT(child); + BT_OBJECT_PUT_REF_AND_RESET(child); if (ret) { goto end; } diff --git a/lib/ctf-writer/writer.c b/lib/ctf-writer/writer.c index c9909d9d..7365243c 100644 --- a/lib/ctf-writer/writer.c +++ b/lib/ctf-writer/writer.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -95,10 +95,10 @@ int init_trace_packet_header(struct bt_ctf_trace *trace) goto end; } end: - bt_put(uuid_array_type); - bt_put(_uint32_t); - bt_put(_uint8_t); - bt_put(trace_packet_header_type); + bt_object_put_ref(uuid_array_type); + bt_object_put_ref(_uint32_t); + bt_object_put_ref(_uint8_t); + bt_object_put_ref(trace_packet_header_type); return ret; } @@ -149,7 +149,7 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path) } bt_object_set_parent(&writer->trace->common.base, &writer->base); - bt_put(writer->trace); + bt_object_put_ref(writer->trace); /* Default to little-endian */ ret = bt_ctf_writer_set_byte_order(writer, BT_CTF_BYTE_ORDER_NATIVE); @@ -173,7 +173,7 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path) return writer; error_destroy: - BT_PUT(writer); + BT_OBJECT_PUT_REF_AND_RESET(writer); error: g_free(metadata_path); return writer; @@ -208,7 +208,7 @@ struct bt_ctf_trace *bt_ctf_writer_get_trace(struct bt_ctf_writer *writer) } trace = writer->trace; - bt_get(trace); + bt_object_get_ref(trace); end: return trace; } @@ -240,7 +240,7 @@ struct bt_ctf_stream *bt_ctf_writer_create_stream(struct bt_ctf_writer *writer, stream_class_found = BT_TRUE; } - BT_PUT(existing_stream_class); + BT_OBJECT_PUT_REF_AND_RESET(existing_stream_class); if (stream_class_found) { break; @@ -264,7 +264,7 @@ struct bt_ctf_stream *bt_ctf_writer_create_stream(struct bt_ctf_writer *writer, return stream; error: - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); return stream; } @@ -422,7 +422,7 @@ struct bt_ctf_field_type *get_field_type(enum field_type_alias alias) field_type = bt_ctf_field_type_integer_create(size); ret = bt_ctf_field_type_set_alignment(field_type, alignment); if (ret) { - BT_PUT(field_type); + BT_OBJECT_PUT_REF_AND_RESET(field_type); } end: return field_type; diff --git a/lib/graph/component-class-sink-colander.c b/lib/graph/component-class-sink-colander.c index 1422b266..d1b75fea 100644 --- a/lib/graph/component-class-sink-colander.c +++ b/lib/graph/component-class-sink-colander.c @@ -23,7 +23,7 @@ #define BT_LOG_TAG "COLANDER" #include -#include +#include #include #include #include @@ -93,7 +93,7 @@ void colander_finalize(struct bt_private_component *priv_comp) } if (colander_data->notif_iter) { - bt_put(colander_data->notif_iter); + bt_object_put_ref(colander_data->notif_iter); } g_free(colander_data); @@ -113,7 +113,7 @@ enum bt_component_status colander_port_connected(struct bt_private_component *pr BT_ASSERT(priv_conn); BT_ASSERT(colander_data); - BT_PUT(colander_data->notif_iter); + BT_OBJECT_PUT_REF_AND_RESET(colander_data->notif_iter); conn_status = bt_private_connection_create_notification_iterator( priv_conn, &colander_data->notif_iter); if (conn_status) { @@ -124,7 +124,7 @@ enum bt_component_status colander_port_connected(struct bt_private_component *pr } end: - bt_put(priv_conn); + bt_object_put_ref(priv_conn); return status; } @@ -195,10 +195,10 @@ struct bt_component_class *bt_component_class_sink_colander_get(void) (void) bt_component_class_freeze(colander_comp_cls); end: - return bt_get(colander_comp_cls); + return bt_object_get_ref(colander_comp_cls); } __attribute__((destructor)) static void put_colander(void) { - BT_PUT(colander_comp_cls); + BT_OBJECT_PUT_REF_AND_RESET(colander_comp_cls); } diff --git a/lib/graph/component-class.c b/lib/graph/component-class.c index 7ce6667f..5a306fb8 100644 --- a/lib/graph/component-class.c +++ b/lib/graph/component-class.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -114,7 +114,7 @@ int bt_component_class_init(struct bt_component_class *class, goto end; error: - BT_PUT(class); + BT_OBJECT_PUT_REF_AND_RESET(class); ret = -1; end: diff --git a/lib/graph/component.c b/lib/graph/component.c index 9fa449db..170a88fa 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -81,9 +81,9 @@ void bt_component_destroy(struct bt_object *obj) * The component's reference count is 0 if we're here. Increment * it to avoid a double-destroy (possibly infinitely recursive). * This could happen for example if the component's finalization - * function does bt_get() (or anything that causes bt_get() to + * function does bt_object_get_ref() (or anything that causes bt_object_get_ref() to * be called) on itself (ref. count goes from 0 to 1), and then - * bt_put(): the reference count would go from 1 to 0 again and + * bt_object_put_ref(): the reference count would go from 1 to 0 again and * this function would be called again. */ obj->ref_count++; @@ -140,7 +140,7 @@ void bt_component_destroy(struct bt_object *obj) } BT_LOGD("Putting component class."); - bt_put(component_class); + bt_object_put_ref(component_class); g_free(component); } @@ -216,7 +216,7 @@ struct bt_port *bt_component_add_port( graph = bt_component_get_graph(component); if (graph) { bt_graph_notify_port_added(graph, new_port); - BT_PUT(graph); + BT_OBJECT_PUT_REF_AND_RESET(graph); } BT_LOGD("Created and added port to component: comp-addr=%p, comp-name=\"%s\", " @@ -268,7 +268,7 @@ enum bt_component_status bt_component_create( bt_object_init_shared_with_parent(&component->base, bt_component_destroy); - component->class = bt_get(component_class); + component->class = bt_object_get_ref(component_class); component->destroy = component_destroy_funcs[type]; component->name = g_string_new(name); if (!component->name) { @@ -305,10 +305,10 @@ enum bt_component_status bt_component_create( "comp-cls-addr=%p, comp-cls-type=%s, name=\"%s\", comp-addr=%p", component_class, bt_component_class_type_string(type), name, component); - BT_MOVE(*user_component, component); + BT_OBJECT_MOVE_REF(*user_component, component); end: - bt_put(component); + bt_object_put_ref(component); return status; } @@ -330,7 +330,7 @@ end: struct bt_component_class *bt_component_get_class( struct bt_component *component) { - return component ? bt_get(component->class) : NULL; + return component ? bt_object_get_ref(component->class) : NULL; } void *bt_private_component_get_user_data( @@ -396,7 +396,7 @@ struct bt_port *bt_component_get_port_by_name(GPtrArray *ports, } if (!strcmp(name, port_name)) { - ret_port = bt_get(port); + ret_port = bt_object_get_ref(port); break; } } @@ -434,7 +434,7 @@ struct bt_port *bt_component_get_port_by_index(GPtrArray *ports, uint64_t index) goto end; } - port = bt_get(g_ptr_array_index(ports, index)); + port = bt_object_get_ref(g_ptr_array_index(ports, index)); end: return port; } @@ -503,7 +503,7 @@ void bt_component_remove_port_by_index(struct bt_component *component, g_ptr_array_remove_index(ports, index); /* Detach port from its component parent */ - BT_PUT(port->base.parent); + BT_OBJECT_PUT_REF_AND_RESET(port->base.parent); /* * Notify the graph's creator that a port is removed. @@ -511,7 +511,7 @@ void bt_component_remove_port_by_index(struct bt_component *component, graph = bt_component_get_graph(component); if (graph) { bt_graph_notify_port_removed(graph, component, port); - BT_PUT(graph); + BT_OBJECT_PUT_REF_AND_RESET(graph); } BT_LOGD("Removed port from component: " diff --git a/lib/graph/connection.c b/lib/graph/connection.c index 163a760b..3993f070 100644 --- a/lib/graph/connection.c +++ b/lib/graph/connection.c @@ -70,7 +70,7 @@ void bt_connection_destroy(struct bt_object *obj) g_ptr_array_free(connection->iterators, TRUE); /* - * No bt_put on ports as a connection only holds _weak_ + * No bt_object_put_ref on ports as a connection only holds _weak_ * references to them. */ g_free(connection); @@ -158,7 +158,7 @@ struct bt_connection *bt_connection_create( connection->iterators = g_ptr_array_new(); if (!connection->iterators) { BT_LOGE_STR("Failed to allocate a GPtrArray."); - BT_PUT(connection); + BT_OBJECT_PUT_REF_AND_RESET(connection); goto end; } @@ -233,8 +233,8 @@ void bt_connection_end(struct bt_connection *conn, downstream_comp, upstream_port, downstream_port); } - bt_put(downstream_comp); - bt_put(upstream_comp); + bt_object_put_ref(downstream_comp); + bt_object_put_ref(upstream_comp); /* * Because this connection is ended, finalize (cancel) each @@ -267,13 +267,13 @@ void bt_connection_end(struct bt_connection *conn, struct bt_port *bt_connection_get_upstream_port( struct bt_connection *connection) { - return connection ? bt_get(connection->upstream_port) : NULL; + return connection ? bt_object_get_ref(connection->upstream_port) : NULL; } struct bt_port *bt_connection_get_downstream_port( struct bt_connection *connection) { - return connection ? bt_get(connection->downstream_port) : NULL; + return connection ? bt_object_get_ref(connection->downstream_port) : NULL; } enum bt_connection_status @@ -407,8 +407,8 @@ bt_private_connection_create_notification_iterator( iterator = NULL; end: - bt_put(upstream_component); - bt_put(iterator); + bt_object_put_ref(upstream_component); + bt_object_put_ref(iterator); return status; } diff --git a/lib/graph/filter.c b/lib/graph/filter.c index a82270e7..539443ef 100644 --- a/lib/graph/filter.c +++ b/lib/graph/filter.c @@ -295,7 +295,7 @@ enum bt_component_status bt_private_component_filter_add_input_private_port( } end: - bt_put(port); + bt_object_put_ref(port); return status; } @@ -371,6 +371,6 @@ enum bt_component_status bt_private_component_filter_add_output_private_port( } end: - bt_put(port); + bt_object_put_ref(port); return status; } diff --git a/lib/graph/graph.c b/lib/graph/graph.c index 6c88f55e..b4350414 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -292,7 +292,7 @@ struct bt_graph *bt_graph_create(void) end: return graph; error: - BT_PUT(graph); + BT_OBJECT_PUT_REF_AND_RESET(graph); goto end; } @@ -519,11 +519,11 @@ enum bt_graph_status bt_graph_connect_ports(struct bt_graph *graph, } end: - bt_put(upstream_graph); - bt_put(downstream_graph); - bt_put(upstream_component); - bt_put(downstream_component); - bt_put(connection); + bt_object_put_ref(upstream_graph); + bt_object_put_ref(downstream_graph); + bt_object_put_ref(upstream_component); + bt_object_put_ref(downstream_component); + bt_object_put_ref(connection); if (graph) { (void) init_can_consume; bt_graph_set_can_consume(graph, init_can_consume); @@ -1035,7 +1035,7 @@ enum bt_graph_status bt_graph_add_component_with_init_method_data( size_t i; bt_bool init_can_consume; - bt_get(params); + bt_object_get_ref(params); if (!graph) { BT_LOGW_STR("Invalid parameter: graph is NULL."); @@ -1182,8 +1182,8 @@ enum bt_graph_status bt_graph_add_component_with_init_method_data( } end: - bt_put(component); - bt_put(params); + bt_object_put_ref(component); + bt_object_put_ref(params); if (graph) { graph->can_consume = init_can_consume; } @@ -1222,7 +1222,7 @@ int bt_graph_remove_unconnected_component(struct bt_graph *graph, bt_component_get_input_port_by_index(component, i); BT_ASSERT(port); - bt_put(port); + bt_object_put_ref(port); if (bt_port_is_connected(port)) { BT_LOGW("Cannot remove component from graph: " @@ -1244,7 +1244,7 @@ int bt_graph_remove_unconnected_component(struct bt_graph *graph, bt_component_get_output_port_by_index(component, i); BT_ASSERT(port); - bt_put(port); + bt_object_put_ref(port); if (bt_port_is_connected(port)) { BT_LOGW("Cannot remove component from graph: " diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 3c68b8c5..c709eae4 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -83,9 +83,9 @@ void destroy_stream_state(struct stream_state *stream_state) BT_LOGV("Destroying stream state: stream-state-addr=%p", stream_state); BT_LOGV_STR("Putting stream state's current packet."); - bt_put(stream_state->cur_packet); + bt_object_put_ref(stream_state->cur_packet); BT_LOGV_STR("Putting stream state's stream."); - bt_put(stream_state->stream); + bt_object_put_ref(stream_state->stream); g_free(stream_state); } @@ -103,7 +103,7 @@ struct stream_state *create_stream_state(struct bt_stream *stream) /* * We keep a reference to the stream until we know it's ended. */ - stream_state->stream = bt_get(stream); + stream_state->stream = bt_object_get_ref(stream); BT_LOGV("Created stream state: stream-addr=%p, stream-name=\"%s\", " "stream-state-addr=%p", stream, bt_stream_get_name(stream), stream_state); @@ -137,9 +137,9 @@ void bt_private_connection_notification_iterator_destroy(struct bt_object *obj) * The notification iterator's reference count is 0 if we're * here. Increment it to avoid a double-destroy (possibly * infinitely recursive). This could happen for example if the - * notification iterator's finalization function does bt_get() - * (or anything that causes bt_get() to be called) on itself - * (ref. count goes from 0 to 1), and then bt_put(): the + * notification iterator's finalization function does bt_object_get_ref() + * (or anything that causes bt_object_get_ref() to be called) on itself + * (ref. count goes from 0 to 1), and then bt_object_put_ref(): the * reference count would go from 1 to 0 again and this function * would be called again. */ @@ -348,7 +348,7 @@ enum bt_connection_status bt_private_connection_notification_iterator_create( iterator = NULL; end: - bt_put(iterator); + bt_object_put_ref(iterator); return status; } @@ -544,7 +544,7 @@ bool validate_notification( goto end; } stream_state->expected_notif_seq_num++; - stream_state->cur_packet = bt_get(packet); + stream_state->cur_packet = bt_object_get_ref(packet); goto end; case BT_NOTIFICATION_TYPE_PACKET_END: if (!stream_state->cur_packet) { @@ -559,7 +559,7 @@ bool validate_notification( goto end; } stream_state->expected_notif_seq_num++; - BT_PUT(stream_state->cur_packet); + BT_OBJECT_PUT_REF_AND_RESET(stream_state->cur_packet); goto end; case BT_NOTIFICATION_TYPE_EVENT: if (packet != stream_state->cur_packet) { @@ -718,7 +718,7 @@ bt_private_connection_notification_iterator_next( * created. In this case, said connection is ended, and * all its notification iterators are finalized. * - * Only bt_put() the returned notification if + * Only bt_object_put_ref() the returned notification if * the status is * BT_NOTIFICATION_ITERATOR_STATUS_OK because * otherwise this field could be garbage. @@ -729,7 +729,7 @@ bt_private_connection_notification_iterator_next( (void *) user_iterator->notifs->pdata; for (i = 0; i < *user_count; i++) { - bt_put(notifs[i]); + bt_object_put_ref(notifs[i]); } } @@ -834,7 +834,7 @@ struct bt_component *bt_private_connection_notification_iterator_get_component( "Notification iterator was not created from a private connection: " "%!+i", iterator); iter_priv_conn = (void *) iterator; - return bt_get(iter_priv_conn->upstream_component); + return bt_object_get_ref(iter_priv_conn->upstream_component); } struct bt_private_component * @@ -855,9 +855,9 @@ void bt_output_port_notification_iterator_destroy(struct bt_object *obj) BT_LOGD("Destroying output port notification iterator object: addr=%p", iterator); BT_LOGD_STR("Putting graph."); - bt_put(iterator->graph); + bt_object_put_ref(iterator->graph); BT_LOGD_STR("Putting colander sink component."); - bt_put(iterator->colander); + bt_object_put_ref(iterator->colander); destroy_base_notification_iterator(obj); } @@ -901,7 +901,7 @@ struct bt_notification_iterator *bt_output_port_notification_iterator_create( bt_output_port_notification_iterator_destroy); if (ret) { /* init_notification_iterator() logs errors */ - BT_PUT(iterator); + BT_OBJECT_PUT_REF_AND_RESET(iterator); goto end; } @@ -912,7 +912,7 @@ struct bt_notification_iterator *bt_output_port_notification_iterator_create( goto error; } - BT_MOVE(iterator->graph, graph); + BT_OBJECT_MOVE_REF(iterator->graph, graph); colander_comp_name = colander_component_name ? colander_component_name : "colander"; colander_data.notifs = (void *) iterator->base.notifs->pdata; @@ -963,7 +963,7 @@ error: /* Remove created colander component from graph if any */ colander_comp = iterator->colander; - BT_PUT(iterator->colander); + BT_OBJECT_PUT_REF_AND_RESET(iterator->colander); /* * At this point the colander component's reference @@ -981,13 +981,13 @@ error: BT_ASSERT(ret == 0); } - BT_PUT(iterator); + BT_OBJECT_PUT_REF_AND_RESET(iterator); end: - bt_put(colander_in_port); - bt_put(colander_comp_cls); - bt_put(output_port_comp); - bt_put(graph); + bt_object_put_ref(colander_in_port); + bt_object_put_ref(colander_comp_cls); + bt_object_put_ref(output_port_comp); + bt_object_put_ref(graph); return (void *) iterator; } diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c index d8178eca..aec13e6c 100644 --- a/lib/graph/notification/event.c +++ b/lib/graph/notification/event.c @@ -70,7 +70,7 @@ struct bt_notification *bt_notification_event_new( goto end; error: - BT_PUT(notification); + BT_OBJECT_PUT_REF_AND_RESET(notification); end: return (void *) notification; diff --git a/lib/graph/notification/inactivity.c b/lib/graph/notification/inactivity.c index becf17e0..605942e7 100644 --- a/lib/graph/notification/inactivity.c +++ b/lib/graph/notification/inactivity.c @@ -76,7 +76,7 @@ struct bt_notification *bt_notification_inactivity_create( goto end; error: - BT_PUT(ret_notif); + BT_OBJECT_PUT_REF_AND_RESET(ret_notif); end: return ret_notif; diff --git a/lib/graph/notification/packet.c b/lib/graph/notification/packet.c index 8e02201d..acf0ce5f 100644 --- a/lib/graph/notification/packet.c +++ b/lib/graph/notification/packet.c @@ -59,7 +59,7 @@ struct bt_notification *bt_notification_packet_begin_new(struct bt_graph *graph) goto end; error: - BT_PUT(notification); + BT_OBJECT_PUT_REF_AND_RESET(notification); end: return (void *) notification; @@ -123,7 +123,7 @@ void bt_notification_packet_begin_destroy(struct bt_notification *notif) BT_LOGD("Destroying packet beginning notification: addr=%p", notif); BT_LOGD_STR("Putting packet."); - BT_PUT(packet_begin_notif->packet); + BT_OBJECT_PUT_REF_AND_RESET(packet_begin_notif->packet); g_free(notif); } @@ -180,7 +180,7 @@ struct bt_notification *bt_notification_packet_end_new(struct bt_graph *graph) goto end; error: - BT_PUT(notification); + BT_OBJECT_PUT_REF_AND_RESET(notification); end: return (void *) notification; @@ -244,7 +244,7 @@ void bt_notification_packet_end_destroy(struct bt_notification *notif) BT_LOGD("Destroying packet end notification: addr=%p", notif); BT_LOGD_STR("Putting packet."); - BT_PUT(packet_end_notif->packet); + BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet); g_free(notif); } @@ -263,7 +263,7 @@ void bt_notification_packet_end_recycle(struct bt_notification *notif) BT_LOGD("Recycling packet end notification: addr=%p", notif); bt_notification_reset(notif); - BT_PUT(packet_end_notif->packet); + BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet); graph = notif->graph; notif->graph = NULL; bt_object_pool_recycle_object(&graph->packet_end_notif_pool, notif); diff --git a/lib/graph/notification/stream.c b/lib/graph/notification/stream.c index fbb0cc78..54293b42 100644 --- a/lib/graph/notification/stream.c +++ b/lib/graph/notification/stream.c @@ -46,7 +46,7 @@ void bt_notification_stream_end_destroy(struct bt_object *obj) BT_LOGD("Destroying stream end notification: addr=%p", notification); BT_LOGD_STR("Putting stream."); - BT_PUT(notification->stream); + BT_OBJECT_PUT_REF_AND_RESET(notification->stream); if (notification->default_cv) { bt_clock_value_recycle(notification->default_cv); @@ -82,7 +82,7 @@ struct bt_notification *bt_notification_stream_end_create( bt_notification_init(¬ification->parent, BT_NOTIFICATION_TYPE_STREAM_END, bt_notification_stream_end_destroy, NULL); - notification->stream = bt_get(stream); + notification->stream = bt_object_get_ref(stream); BT_LOGD("Created stream end notification object: " "stream-addr=%p, stream-name=\"%s\", " "stream-class-addr=%p, stream-class-name=\"%s\", " @@ -158,7 +158,7 @@ void bt_notification_stream_begin_destroy(struct bt_object *obj) BT_LOGD("Destroying stream beginning notification: addr=%p", notification); BT_LOGD_STR("Putting stream."); - BT_PUT(notification->stream); + BT_OBJECT_PUT_REF_AND_RESET(notification->stream); if (notification->default_cv) { bt_clock_value_recycle(notification->default_cv); @@ -194,7 +194,7 @@ struct bt_notification *bt_notification_stream_begin_create( bt_notification_init(¬ification->parent, BT_NOTIFICATION_TYPE_STREAM_BEGIN, bt_notification_stream_begin_destroy, NULL); - notification->stream = bt_get(stream); + notification->stream = bt_object_get_ref(stream); BT_LOGD("Created stream beginning notification object: " "stream-addr=%p, stream-name=\"%s\", " "stream-class-addr=%p, stream-class-name=\"%s\", " diff --git a/lib/graph/port.c b/lib/graph/port.c index 5ed5f932..4e1b44bb 100644 --- a/lib/graph/port.c +++ b/lib/graph/port.c @@ -89,7 +89,7 @@ struct bt_port *bt_port_create(struct bt_component *parent_component, port->name = g_string_new(name); if (!port->name) { BT_LOGE_STR("Failed to allocate one GString."); - BT_PUT(port); + BT_OBJECT_PUT_REF_AND_RESET(port); goto end; } @@ -130,7 +130,7 @@ struct bt_connection *bt_port_get_connection(struct bt_port *port) goto end; } - connection = bt_get(port->connection); + connection = bt_object_get_ref(port->connection); end: return connection; @@ -201,7 +201,7 @@ enum bt_port_status bt_private_port_remove_from_component( } end: - bt_put(comp); + bt_object_put_ref(comp); return status; } diff --git a/lib/graph/query-executor.c b/lib/graph/query-executor.c index bd9b5377..fa44b07e 100644 --- a/lib/graph/query-executor.c +++ b/lib/graph/query-executor.c @@ -123,7 +123,7 @@ enum bt_query_status bt_query_executor_query( BT_LOGD("User method returned: status=%s, result-addr=%p", bt_query_status_string(ret.status), ret.result); if (query_exec->canceled) { - BT_PUT(ret.result); + BT_OBJECT_PUT_REF_AND_RESET(ret.result); ret.status = BT_QUERY_STATUS_EXECUTOR_CANCELED; goto end; } else { @@ -132,7 +132,7 @@ enum bt_query_status bt_query_executor_query( * The user cannot decide that the executor is * canceled if it's not. */ - BT_PUT(ret.result); + BT_OBJECT_PUT_REF_AND_RESET(ret.result); ret.status = BT_QUERY_STATUS_ERROR; goto end; } @@ -144,7 +144,7 @@ enum bt_query_status bt_query_executor_query( * This is reserved for invalid parameters passed to * this function. */ - BT_PUT(ret.result); + BT_OBJECT_PUT_REF_AND_RESET(ret.result); ret.status = BT_QUERY_STATUS_ERROR; break; case BT_QUERY_STATUS_OK: @@ -157,7 +157,7 @@ enum bt_query_status bt_query_executor_query( BT_LOGW("User method did not return BT_QUERY_STATUS_OK, but result is not NULL: " "status=%s, result-addr=%p", bt_query_status_string(ret.status), ret.result); - BT_PUT(ret.result); + BT_OBJECT_PUT_REF_AND_RESET(ret.result); } } @@ -167,7 +167,7 @@ end: ret.result = NULL; } - bt_put(ret.result); + bt_object_put_ref(ret.result); return ret.status; } diff --git a/lib/graph/sink.c b/lib/graph/sink.c index 9ef89d3f..5a8996fc 100644 --- a/lib/graph/sink.c +++ b/lib/graph/sink.c @@ -213,6 +213,6 @@ enum bt_component_status bt_private_component_sink_add_input_private_port( } end: - bt_put(port); + bt_object_put_ref(port); return status; } diff --git a/lib/graph/source.c b/lib/graph/source.c index 52ac8c81..a573df15 100644 --- a/lib/graph/source.c +++ b/lib/graph/source.c @@ -29,7 +29,7 @@ #define BT_LOG_TAG "COMP-SOURCE" #include -#include +#include #include #include #include @@ -214,6 +214,6 @@ enum bt_component_status bt_private_component_source_add_output_private_port( } end: - bt_put(port); + bt_object_put_ref(port); return status; } diff --git a/lib/ref.c b/lib/object.c similarity index 94% rename from lib/ref.c rename to lib/object.c index ae2cef01..0f7261a9 100644 --- a/lib/ref.c +++ b/lib/object.c @@ -24,13 +24,13 @@ * SOFTWARE. */ -#define BT_LOG_TAG "REF" +#define BT_LOG_TAG "OBJECT" #include #include #include -void *bt_get(void *ptr) +void *bt_object_get_ref(void *ptr) { struct bt_object *obj = ptr; @@ -45,7 +45,7 @@ end: return ptr; } -void bt_put(void *ptr) +void bt_object_put_ref(void *ptr) { struct bt_object *obj = ptr; diff --git a/lib/plugin/plugin-so.c b/lib/plugin/plugin-so.c index 648f95d1..c0fb97b5 100644 --- a/lib/plugin/plugin-so.c +++ b/lib/plugin/plugin-so.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -96,7 +96,7 @@ void fini_comp_class_list(void) bt_list_for_each_entry_safe(comp_class, tmp, &component_class_list, node) { bt_list_del(&comp_class->node); - BT_PUT(comp_class->so_handle); + BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle); } BT_LOGD_STR("Released references from all component classes to shared library handles."); } @@ -205,7 +205,7 @@ struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create( goto end; error: - BT_PUT(shared_lib_handle); + BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle); end: if (shared_lib_handle) { @@ -227,7 +227,7 @@ void bt_plugin_so_destroy_spec_data(struct bt_plugin *plugin) BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO); BT_ASSERT(spec); - BT_PUT(spec->shared_lib_handle); + BT_OBJECT_PUT_REF_AND_RESET(spec->shared_lib_handle); g_free(plugin->spec_data); plugin->spec_data = NULL; } @@ -581,7 +581,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's description."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -592,7 +592,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's help string."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -603,7 +603,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's initialization method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -614,7 +614,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's finalization method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -625,7 +625,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's query method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -636,7 +636,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's \"accept port connection\" method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -647,7 +647,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's \"port connected\" method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -658,7 +658,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's \"port disconnected\" method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -672,7 +672,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set component class's notification iterator initialization method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -684,7 +684,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set source component class's notification iterator finalization method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -697,7 +697,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set filter component class's notification iterator initialization method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -709,7 +709,7 @@ enum bt_plugin_status bt_plugin_so_init( if (ret) { BT_LOGE_STR("Cannot set filter component class's notification iterator finalization method."); status = BT_PLUGIN_STATUS_ERROR; - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); goto end; } } @@ -730,7 +730,7 @@ enum bt_plugin_status bt_plugin_so_init( */ status = bt_plugin_add_component_class(plugin, comp_class); - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); if (status < 0) { BT_LOGE("Cannot add component class to plugin."); goto end; @@ -770,11 +770,11 @@ struct bt_plugin *bt_plugin_so_create_empty( } spec = plugin->spec_data; - spec->shared_lib_handle = bt_get(shared_lib_handle); + spec->shared_lib_handle = bt_object_get_ref(shared_lib_handle); goto end; error: - BT_PUT(plugin); + BT_OBJECT_PUT_REF_AND_RESET(plugin); end: return plugin; @@ -893,19 +893,19 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections( * even a warning. */ BT_LOGD_STR("Cannot initialize SO plugin object from sections."); - BT_PUT(plugin); + BT_OBJECT_PUT_REF_AND_RESET(plugin); goto error; } /* Add to plugin set */ bt_plugin_set_add_plugin(plugin_set, plugin); - bt_put(plugin); + bt_object_put_ref(plugin); } goto end; error: - BT_PUT(plugin_set); + BT_OBJECT_PUT_REF_AND_RESET(plugin_set); end: return plugin_set; @@ -934,7 +934,7 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_static(void) __bt_get_end_section_component_class_descriptor_attributes()); end: - BT_PUT(shared_lib_handle); + BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle); return plugin_set; } @@ -1114,7 +1114,7 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path) cc_descr_attrs_begin, cc_descr_attrs_end); end: - BT_PUT(shared_lib_handle); + BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle); return plugin_set; } @@ -1123,7 +1123,7 @@ void plugin_comp_class_destroy_listener(struct bt_component_class *comp_class, void *data) { bt_list_del(&comp_class->node); - BT_PUT(comp_class->so_handle); + BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle); BT_LOGV("Component class destroyed: removed entry from list: " "comp-cls-addr=%p", comp_class); } @@ -1138,7 +1138,7 @@ void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin, BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO); bt_list_add(&comp_class->node, &component_class_list); - comp_class->so_handle = bt_get(spec->shared_lib_handle); + comp_class->so_handle = bt_object_get_ref(spec->shared_lib_handle); /* Add our custom destroy listener */ bt_component_class_add_destroy_listener(comp_class, diff --git a/lib/plugin/plugin.c b/lib/plugin/plugin.c index 59b87273..eb935905 100644 --- a/lib/plugin/plugin.c +++ b/lib/plugin/plugin.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include #include @@ -147,7 +147,7 @@ struct bt_plugin *bt_plugin_set_get_plugin(struct bt_plugin_set *plugin_set, goto end; } - plugin = bt_get(g_ptr_array_index(plugin_set->plugins, index)); + plugin = bt_object_get_ref(g_ptr_array_index(plugin_set->plugins, index)); end: return plugin; @@ -279,7 +279,7 @@ struct bt_plugin *bt_plugin_find(const char *plugin_name) for (i = 0; i < dirs->len; i++) { GString *dir = g_ptr_array_index(dirs, i); - BT_PUT(plugin_set); + BT_OBJECT_PUT_REF_AND_RESET(plugin_set); /* * Skip this if the directory does not exist because @@ -307,7 +307,7 @@ struct bt_plugin *bt_plugin_find(const char *plugin_name) plugin_name) == 0) { BT_LOGD("Plugin found in directory: name=\"%s\", path=\"%s\"", plugin_name, dir->str); - plugin = bt_get(candidate_plugin); + plugin = bt_object_get_ref(candidate_plugin); goto end; } } @@ -316,7 +316,7 @@ struct bt_plugin *bt_plugin_find(const char *plugin_name) plugin_name, dir->str); } - bt_put(plugin_set); + bt_object_put_ref(plugin_set); plugin_set = bt_plugin_create_all_from_static(); if (plugin_set) { for (j = 0; j < plugin_set->plugins->len; j++) { @@ -327,7 +327,7 @@ struct bt_plugin *bt_plugin_find(const char *plugin_name) plugin_name) == 0) { BT_LOGD("Plugin found in built-in plugins: " "name=\"%s\"", plugin_name); - plugin = bt_get(candidate_plugin); + plugin = bt_object_get_ref(candidate_plugin); goto end; } } @@ -335,7 +335,7 @@ struct bt_plugin *bt_plugin_find(const char *plugin_name) end: free(home_plugin_dir); - bt_put(plugin_set); + bt_object_put_ref(plugin_set); if (dirs) { g_ptr_array_free(dirs, TRUE); @@ -388,7 +388,7 @@ struct bt_component_class *bt_plugin_find_component_class( } end: - bt_put(plugin); + bt_object_put_ref(plugin); return comp_cls; } @@ -438,7 +438,7 @@ int nftw_append_all_from_dir(const char *file, const struct stat *sb, int flag, bt_plugin_set_add_plugin(append_all_from_dir_info.plugin_set, plugin); } - bt_put(plugins_from_file); + bt_object_put_ref(plugins_from_file); } break; } @@ -527,7 +527,7 @@ struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path, goto end; error: - BT_PUT(plugin_set); + BT_OBJECT_PUT_REF_AND_RESET(plugin_set); end: return plugin_set; @@ -679,11 +679,11 @@ struct bt_component_class *bt_plugin_get_component_class_by_index( } comp_class = g_ptr_array_index(plugin->comp_classes, index); - bt_get(comp_class); + bt_object_get_ref(comp_class); goto end; error: - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); end: return comp_class; @@ -719,7 +719,7 @@ struct bt_component_class *bt_plugin_get_component_class_by_name_and_type( if (strcmp(name, comp_class_cand_name) == 0 && comp_class_cand_type == type) { - comp_class = bt_get(comp_class_candidate); + comp_class = bt_object_get_ref(comp_class_candidate); break; } } @@ -727,7 +727,7 @@ struct bt_component_class *bt_plugin_get_component_class_by_name_and_type( goto end; error: - BT_PUT(comp_class); + BT_OBJECT_PUT_REF_AND_RESET(comp_class); end: return comp_class; @@ -775,7 +775,7 @@ enum bt_plugin_status bt_plugin_add_component_class( /* Add new component class */ comp_class_index = plugin->comp_classes->len; - g_ptr_array_add(plugin->comp_classes, bt_get(comp_class)); + g_ptr_array_add(plugin->comp_classes, bt_object_get_ref(comp_class)); /* Special case for a shared object plugin */ if (plugin->type == BT_PLUGIN_TYPE_SO) { @@ -803,6 +803,6 @@ error: status = BT_PLUGIN_STATUS_ERROR; end: - bt_put(comp_class_dup); + bt_object_put_ref(comp_class_dup); return status; } diff --git a/lib/trace-ir/attributes.c b/lib/trace-ir/attributes.c index caabda3f..c1c92032 100644 --- a/lib/trace-ir/attributes.c +++ b/lib/trace-ir/attributes.c @@ -28,7 +28,7 @@ #define BT_LOG_TAG "ATTRS" #include -#include +#include #include #include #include @@ -74,7 +74,7 @@ BT_HIDDEN void bt_attributes_destroy(struct bt_value *attr_obj) { BT_LOGD("Destroying attributes object: addr=%p", attr_obj); - bt_put(attr_obj); + bt_object_put_ref(attr_obj); } BT_HIDDEN @@ -272,7 +272,7 @@ int bt_attributes_set_field_value(struct bt_value *attr_obj, } end: - bt_put(attr_field_obj); + bt_object_put_ref(attr_field_obj); return ret; } diff --git a/lib/trace-ir/clock-class.c b/lib/trace-ir/clock-class.c index c8e5f3fd..7c63d66e 100644 --- a/lib/trace-ir/clock-class.c +++ b/lib/trace-ir/clock-class.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -150,7 +150,7 @@ struct bt_clock_class *bt_clock_class_create(void) goto end; error: - BT_PUT(clock_class); + BT_OBJECT_PUT_REF_AND_RESET(clock_class); end: return clock_class; diff --git a/lib/trace-ir/clock-value.c b/lib/trace-ir/clock-value.c index 97242118..877d8687 100644 --- a/lib/trace-ir/clock-value.c +++ b/lib/trace-ir/clock-value.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -39,7 +39,7 @@ BT_HIDDEN void bt_clock_value_destroy(struct bt_clock_value *clock_value) { BT_LIB_LOGD("Destroying clock value: %!+k", clock_value); - bt_put(clock_value->clock_class); + bt_object_put_ref(clock_value->clock_class); g_free(clock_value); } @@ -58,7 +58,7 @@ struct bt_clock_value *bt_clock_value_new(struct bt_clock_class *clock_class) } bt_object_init_unique(&ret->base); - ret->clock_class = bt_get(clock_class); + ret->clock_class = bt_object_get_ref(clock_class); bt_clock_class_freeze(clock_class); BT_LIB_LOGD("Created clock value object: %!+k", ret); @@ -80,7 +80,7 @@ struct bt_clock_value *bt_clock_value_create(struct bt_clock_class *clock_class) } if (likely(!clock_value->clock_class)) { - clock_value->clock_class = bt_get(clock_class); + clock_value->clock_class = bt_object_get_ref(clock_class); } goto end; @@ -116,7 +116,7 @@ void bt_clock_value_recycle(struct bt_clock_value *clock_value) * variable so that we can set the clock value's clock class * member to NULL before recycling it. We CANNOT do this * after we put the clock class reference because this - * bt_put() could destroy the clock class, also destroying + * bt_object_put_ref() could destroy the clock class, also destroying * its clock value pool, thus also destroying our clock value * object (this would result in an invalid write access). * @@ -129,7 +129,7 @@ void bt_clock_value_recycle(struct bt_clock_value *clock_value) BT_ASSERT(clock_class); clock_value->clock_class = NULL; bt_object_pool_recycle_object(&clock_class->cv_pool, clock_value); - bt_put(clock_class); + bt_object_put_ref(clock_class); } uint64_t bt_clock_value_get_value(struct bt_clock_value *clock_value) diff --git a/lib/trace-ir/event-class.c b/lib/trace-ir/event-class.c index 3df6320b..895557aa 100644 --- a/lib/trace-ir/event-class.c +++ b/lib/trace-ir/event-class.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -71,9 +71,9 @@ void destroy_event_class(struct bt_object *obj) } BT_LOGD_STR("Putting context field classe."); - bt_put(event_class->specific_context_fc); + bt_object_put_ref(event_class->specific_context_fc); BT_LOGD_STR("Putting payload field classe."); - bt_put(event_class->payload_fc); + bt_object_put_ref(event_class->payload_fc); bt_object_pool_finalize(&event_class->event_pool); g_free(obj); } @@ -161,7 +161,7 @@ struct bt_event_class *create_event_class_with_id( goto end; error: - BT_PUT(event_class); + BT_OBJECT_PUT_REF_AND_RESET(event_class); end: return event_class; @@ -303,8 +303,8 @@ int bt_event_class_set_specific_context_field_class( } bt_field_class_make_part_of_trace(field_class); - bt_put(event_class->specific_context_fc); - event_class->specific_context_fc = bt_get(field_class); + bt_object_put_ref(event_class->specific_context_fc); + event_class->specific_context_fc = bt_object_get_ref(field_class); bt_field_class_freeze(field_class); BT_LIB_LOGV("Set event class's specific context field classe: %!+E", event_class); @@ -358,8 +358,8 @@ int bt_event_class_set_payload_field_class(struct bt_event_class *event_class, } bt_field_class_make_part_of_trace(field_class); - bt_put(event_class->payload_fc); - event_class->payload_fc = bt_get(field_class); + bt_object_put_ref(event_class->payload_fc); + event_class->payload_fc = bt_object_get_ref(field_class); bt_field_class_freeze(field_class); BT_LIB_LOGV("Set event class's payload field classe: %!+E", event_class); diff --git a/lib/trace-ir/event.c b/lib/trace-ir/event.c index ed42d0a2..2df8fe8c 100644 --- a/lib/trace-ir/event.c +++ b/lib/trace-ir/event.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include @@ -280,14 +280,14 @@ void bt_event_destroy(struct bt_event *event) } BT_LOGD_STR("Putting event's class."); - bt_put(event->class); + bt_object_put_ref(event->class); if (event->default_cv) { bt_clock_value_recycle(event->default_cv); } BT_LOGD_STR("Putting event's packet."); - bt_put(event->packet); + bt_object_put_ref(event->packet); g_free(event); } diff --git a/lib/trace-ir/field-classes.c b/lib/trace-ir/field-classes.c index bd43b6f2..4aa36f1a 100644 --- a/lib/trace-ir/field-classes.c +++ b/lib/trace-ir/field-classes.c @@ -35,11 +35,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include #include #include @@ -101,7 +101,7 @@ struct bt_field_class *create_integer_field_class(enum bt_field_class_type type) goto end; error: - BT_PUT(int_fc); + BT_OBJECT_PUT_REF_AND_RESET(int_fc); end: return (void *) int_fc; @@ -255,7 +255,7 @@ struct bt_field_class *create_enumeration_field_class(enum bt_field_class_type t goto end; error: - BT_PUT(enum_fc); + BT_OBJECT_PUT_REF_AND_RESET(enum_fc); end: return (void *) enum_fc; @@ -591,7 +591,7 @@ struct bt_field_class *bt_field_class_real_create(void) goto end; error: - BT_PUT(real_fc); + BT_OBJECT_PUT_REF_AND_RESET(real_fc); end: return (void *) real_fc; @@ -661,7 +661,7 @@ void finalize_named_field_class(struct bt_named_field_class *named_fc) } BT_LOGD_STR("Putting named field classe's field classe."); - bt_put(named_fc->fc); + bt_object_put_ref(named_fc->fc); } static @@ -718,7 +718,7 @@ struct bt_field_class *bt_field_class_structure_create(void) goto end; error: - BT_PUT(struct_fc); + BT_OBJECT_PUT_REF_AND_RESET(struct_fc); end: return (void *) struct_fc; @@ -753,7 +753,7 @@ int append_named_field_class_to_container_field_class( named_fc = &g_array_index(container_fc->named_fcs, struct bt_named_field_class, container_fc->named_fcs->len - 1); named_fc->name = name_str; - named_fc->fc = bt_get(fc); + named_fc->fc = bt_object_get_ref(fc); g_hash_table_insert(container_fc->name_to_index, named_fc->name->str, GUINT_TO_POINTER(container_fc->named_fcs->len - 1)); bt_field_class_freeze(fc); @@ -850,7 +850,7 @@ void destroy_variant_field_class(struct bt_object *obj) BT_LIB_LOGD("Destroying variant field classe object: %!+F", fc); finalize_named_field_classes_container((void *) fc); BT_LOGD_STR("Putting selector field path."); - bt_put(fc->selector_field_path); + bt_object_put_ref(fc->selector_field_path); g_free(fc); } @@ -876,7 +876,7 @@ struct bt_field_class *bt_field_class_variant_create(void) goto end; error: - BT_PUT(var_fc); + BT_OBJECT_PUT_REF_AND_RESET(var_fc); end: return (void *) var_fc; @@ -952,7 +952,7 @@ void init_array_field_class(struct bt_field_class_array *fc, { BT_ASSERT(element_fc); init_field_class((void *) fc, type, release_func); - fc->element_fc = bt_get(element_fc); + fc->element_fc = bt_object_get_ref(element_fc); bt_field_class_freeze(element_fc); } @@ -961,7 +961,7 @@ void finalize_array_field_class(struct bt_field_class_array *array_fc) { BT_ASSERT(array_fc); BT_LOGD_STR("Putting element field classe."); - bt_put(array_fc->element_fc); + bt_object_put_ref(array_fc->element_fc); } static @@ -993,7 +993,7 @@ struct bt_field_class *bt_field_class_static_array_create( goto end; error: - BT_PUT(array_fc); + BT_OBJECT_PUT_REF_AND_RESET(array_fc); end: return (void *) array_fc; @@ -1028,7 +1028,7 @@ void destroy_dynamic_array_field_class(struct bt_object *obj) BT_LIB_LOGD("Destroying dynamic array field classe object: %!+F", fc); finalize_array_field_class((void *) fc); BT_LOGD_STR("Putting length field path."); - bt_put(fc->length_field_path); + bt_object_put_ref(fc->length_field_path); g_free(fc); } @@ -1051,7 +1051,7 @@ struct bt_field_class *bt_field_class_dynamic_array_create( goto end; error: - BT_PUT(array_fc); + BT_OBJECT_PUT_REF_AND_RESET(array_fc); end: return (void *) array_fc; @@ -1109,7 +1109,7 @@ struct bt_field_class *bt_field_class_string_create(void) goto end; error: - BT_PUT(string_fc); + BT_OBJECT_PUT_REF_AND_RESET(string_fc); end: return (void *) string_fc; diff --git a/lib/trace-ir/field-path.c b/lib/trace-ir/field-path.c index 5cb2a96d..d6414e89 100644 --- a/lib/trace-ir/field-path.c +++ b/lib/trace-ir/field-path.c @@ -74,7 +74,7 @@ struct bt_field_path *bt_field_path_create(void) goto end; error: - BT_PUT(field_path); + BT_OBJECT_PUT_REF_AND_RESET(field_path); end: return field_path; diff --git a/lib/trace-ir/fields.c b/lib/trace-ir/fields.c index 9872dd77..fc1d0042 100644 --- a/lib/trace-ir/fields.c +++ b/lib/trace-ir/fields.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -224,7 +224,7 @@ void init_field(struct bt_field *field, struct bt_field_class *fc, BT_ASSERT(fc); bt_object_init_unique(&field->base); field->methods = methods; - field->class = bt_get(fc); + field->class = bt_object_get_ref(fc); } static @@ -282,7 +282,7 @@ struct bt_field *create_string_field(struct bt_field_class *fc) sizeof(char), 1); if (!string_field->buf) { BT_LOGE_STR("Failed to allocate a GArray."); - BT_PUT(string_field); + BT_OBJECT_PUT_REF_AND_RESET(string_field); goto end; } @@ -350,7 +350,7 @@ struct bt_field *create_structure_field(struct bt_field_class *fc) &struct_field->fields)) { BT_LIB_LOGE("Cannot create structure member fields: " "%![fc-]+F", fc); - BT_PUT(struct_field); + BT_OBJECT_PUT_REF_AND_RESET(struct_field); goto end; } @@ -378,7 +378,7 @@ struct bt_field *create_variant_field(struct bt_field_class *fc) &var_field->fields)) { BT_LIB_LOGE("Cannot create variant member fields: " "%![fc-]+F", fc); - BT_PUT(var_field); + BT_OBJECT_PUT_REF_AND_RESET(var_field); goto end; } @@ -442,7 +442,7 @@ struct bt_field *create_static_array_field(struct bt_field_class *fc) if (init_array_field_fields(array_field)) { BT_LIB_LOGE("Cannot create static array fields: " "%![fc-]+F", fc); - BT_PUT(array_field); + BT_OBJECT_PUT_REF_AND_RESET(array_field); goto end; } @@ -469,7 +469,7 @@ struct bt_field *create_dynamic_array_field(struct bt_field_class *fc) if (init_array_field_fields(array_field)) { BT_LIB_LOGE("Cannot create dynamic array fields: " "%![fc-]+F", fc); - BT_PUT(array_field); + BT_OBJECT_PUT_REF_AND_RESET(array_field); goto end; } @@ -822,7 +822,7 @@ void bt_field_finalize(struct bt_field *field) { BT_ASSERT(field); BT_LOGD_STR("Putting field's class."); - bt_put(field->class); + bt_object_put_ref(field->class); } static diff --git a/lib/trace-ir/packet.c b/lib/trace-ir/packet.c index 50851bd2..a6a12235 100644 --- a/lib/trace-ir/packet.c +++ b/lib/trace-ir/packet.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -172,7 +172,7 @@ void bt_packet_recycle(struct bt_packet *packet) * 2. Move the stream reference to our `stream` * variable so that we can set the packet's stream member * to NULL before recycling it. We CANNOT do this after - * we put the stream reference because this bt_put() + * we put the stream reference because this bt_object_put_ref() * could destroy the stream, also destroying its * packet pool, thus also destroying our packet object (this * would result in an invalid write access). @@ -226,7 +226,7 @@ void bt_packet_destroy(struct bt_packet *packet) } BT_LOGD_STR("Putting packet's stream."); - bt_put(packet->stream); + bt_object_put_ref(packet->stream); g_free(packet); } @@ -246,7 +246,7 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream) bt_object_init_shared(&packet->base, (bt_object_release_func) bt_packet_recycle); - packet->stream = bt_get(stream); + packet->stream = bt_object_get_ref(stream); trace = bt_stream_class_borrow_trace_inline(stream->class); BT_ASSERT(trace); @@ -297,7 +297,7 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream) goto end; error: - BT_PUT(packet); + BT_OBJECT_PUT_REF_AND_RESET(packet); end: return packet; diff --git a/lib/trace-ir/resolve-field-path.c b/lib/trace-ir/resolve-field-path.c index 8334d18b..32b289d1 100644 --- a/lib/trace-ir/resolve-field-path.c +++ b/lib/trace-ir/resolve-field-path.c @@ -109,7 +109,7 @@ int find_field_class(struct bt_field_class *root_fc, field_path->root = root_scope; if (!find_field_class_recursive(root_fc, tgt_fc, field_path)) { /* Not found here */ - BT_PUT(field_path); + BT_OBJECT_PUT_REF_AND_RESET(field_path); } end: @@ -510,8 +510,8 @@ bool field_path_is_valid(struct bt_field_class *src_fc, } end: - bt_put(src_field_path); - bt_put(tgt_field_path); + bt_object_put_ref(src_field_path); + bt_object_put_ref(tgt_field_path); return is_valid; } diff --git a/lib/trace-ir/stream-class.c b/lib/trace-ir/stream-class.c index 91255fc6..cc51cced 100644 --- a/lib/trace-ir/stream-class.c +++ b/lib/trace-ir/stream-class.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ void destroy_stream_class(struct bt_object *obj) BT_LIB_LOGD("Destroying stream class: %!+S", stream_class); BT_LOGD_STR("Putting default clock class."); - bt_put(stream_class->default_clock_class); + bt_object_put_ref(stream_class->default_clock_class); if (stream_class->event_classes) { BT_LOGD_STR("Destroying event classes."); @@ -70,11 +70,11 @@ void destroy_stream_class(struct bt_object *obj) } BT_LOGD_STR("Putting event header field classe."); - bt_put(stream_class->event_header_fc); + bt_object_put_ref(stream_class->event_header_fc); BT_LOGD_STR("Putting packet context field classe."); - bt_put(stream_class->packet_context_fc); + bt_object_put_ref(stream_class->packet_context_fc); BT_LOGD_STR("Putting event common context field classe."); - bt_put(stream_class->event_common_context_fc); + bt_object_put_ref(stream_class->event_common_context_fc); bt_object_pool_finalize(&stream_class->event_header_field_pool); bt_object_pool_finalize(&stream_class->packet_context_field_pool); g_free(stream_class); @@ -174,7 +174,7 @@ struct bt_stream_class *create_stream_class_with_id(struct bt_trace *trace, goto end; error: - BT_PUT(stream_class); + BT_OBJECT_PUT_REF_AND_RESET(stream_class); end: return stream_class; @@ -303,8 +303,8 @@ int bt_stream_class_set_packet_context_field_class( } bt_field_class_make_part_of_trace(field_class); - bt_put(stream_class->packet_context_fc); - stream_class->packet_context_fc = bt_get(field_class); + bt_object_put_ref(stream_class->packet_context_fc); + stream_class->packet_context_fc = bt_object_get_ref(field_class); bt_field_class_freeze(field_class); BT_LIB_LOGV("Set stream class's packet context field classe: %!+S", stream_class); @@ -350,8 +350,8 @@ int bt_stream_class_set_event_header_field_class( } bt_field_class_make_part_of_trace(field_class); - bt_put(stream_class->event_header_fc); - stream_class->event_header_fc = bt_get(field_class); + bt_object_put_ref(stream_class->event_header_fc); + stream_class->event_header_fc = bt_object_get_ref(field_class); bt_field_class_freeze(field_class); BT_LIB_LOGV("Set stream class's event header field classe: %!+S", stream_class); @@ -398,8 +398,8 @@ int bt_stream_class_set_event_common_context_field_class( } bt_field_class_make_part_of_trace(field_class); - bt_put(stream_class->event_common_context_fc); - stream_class->event_common_context_fc = bt_get(field_class); + bt_object_put_ref(stream_class->event_common_context_fc); + stream_class->event_common_context_fc = bt_object_get_ref(field_class); bt_field_class_freeze(field_class); BT_LIB_LOGV("Set stream class's event common context field classe: %!+S", stream_class); @@ -424,8 +424,8 @@ int bt_stream_class_set_default_clock_class( BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); - bt_put(stream_class->default_clock_class); - stream_class->default_clock_class = bt_get(clock_class); + bt_object_put_ref(stream_class->default_clock_class); + stream_class->default_clock_class = bt_object_get_ref(clock_class); bt_clock_class_freeze(clock_class); BT_LIB_LOGV("Set stream class's default clock class: %!+S", stream_class); diff --git a/lib/trace-ir/stream.c b/lib/trace-ir/stream.c index 445dbac6..53f1ad74 100644 --- a/lib/trace-ir/stream.c +++ b/lib/trace-ir/stream.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -140,7 +140,7 @@ struct bt_stream *create_stream_with_id(struct bt_stream_class *stream_class, goto end; error: - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); end: return stream; diff --git a/lib/trace-ir/trace.c b/lib/trace-ir/trace.c index 9d705482..02c18cc6 100644 --- a/lib/trace-ir/trace.c +++ b/lib/trace-ir/trace.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include @@ -119,7 +119,7 @@ void destroy_trace(struct bt_object *obj) } BT_LOGD_STR("Putting packet header field classe."); - bt_put(trace->packet_header_fc); + bt_object_put_ref(trace->packet_header_fc); g_free(trace); } @@ -198,7 +198,7 @@ struct bt_trace *bt_trace_create(void) goto end; error: - BT_PUT(trace); + BT_OBJECT_PUT_REF_AND_RESET(trace); end: return trace; @@ -298,7 +298,7 @@ int bt_trace_set_environment_entry_string(struct bt_trace *trace, ret = set_environment_entry(trace, name, value_obj); end: - bt_put(value_obj); + bt_object_put_ref(value_obj); return ret; } @@ -321,7 +321,7 @@ int bt_trace_set_environment_entry_integer( ret = set_environment_entry(trace, name, value_obj); end: - bt_put(value_obj); + bt_object_put_ref(value_obj); return ret; } @@ -464,8 +464,8 @@ int bt_trace_set_packet_header_field_class(struct bt_trace *trace, } bt_field_class_make_part_of_trace(field_class); - bt_put(trace->packet_header_fc); - trace->packet_header_fc = bt_get(field_class); + bt_object_put_ref(trace->packet_header_fc); + trace->packet_header_fc = bt_object_get_ref(field_class); bt_field_class_freeze(field_class); BT_LIB_LOGV("Set trace's packet header field classe: %!+t", trace); diff --git a/lib/trace-ir/utils.c b/lib/trace-ir/utils.c index 57fe1ec2..d59ae21b 100644 --- a/lib/trace-ir/utils.c +++ b/lib/trace-ir/utils.c @@ -33,5 +33,5 @@ #include #include #include -#include +#include #include diff --git a/lib/values.c b/lib/values.c index 8836f01d..a4393841 100644 --- a/lib/values.c +++ b/lib/values.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -226,16 +226,16 @@ struct bt_value *bt_value_array_copy(const struct bt_value *array_obj) BT_LOGE("Cannot copy array value's element: " "array-addr=%p, index=%d", array_obj, i); - BT_PUT(copy_obj); + BT_OBJECT_PUT_REF_AND_RESET(copy_obj); goto end; } ret = bt_value_array_append_element(copy_obj, element_obj_copy); - BT_PUT(element_obj_copy); + BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy); if (ret) { BT_LOGE("Cannot append to array value: addr=%p", array_obj); - BT_PUT(copy_obj); + BT_OBJECT_PUT_REF_AND_RESET(copy_obj); goto end; } } @@ -277,16 +277,16 @@ struct bt_value *bt_value_map_copy(const struct bt_value *map_obj) BT_LOGE("Cannot copy map value's element: " "map-addr=%p, key=\"%s\"", map_obj, key_str); - BT_PUT(copy_obj); + BT_OBJECT_PUT_REF_AND_RESET(copy_obj); goto end; } ret = bt_value_map_insert_entry(copy_obj, key_str, element_obj_copy); - BT_PUT(element_obj_copy); + BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy); if (ret) { BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"", map_obj, key_str); - BT_PUT(copy_obj); + BT_OBJECT_PUT_REF_AND_RESET(copy_obj); goto end; } } @@ -708,7 +708,7 @@ struct bt_value *bt_value_array_create(void) array_obj->base = bt_value_create_base(BT_VALUE_TYPE_ARRAY); array_obj->garray = bt_g_ptr_array_new_full(0, - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); if (!array_obj->garray) { BT_LOGE_STR("Failed to allocate a GPtrArray."); g_free(array_obj); @@ -736,7 +736,7 @@ struct bt_value *bt_value_map_create(void) map_obj->base = bt_value_create_base(BT_VALUE_TYPE_MAP); map_obj->ght = g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, (GDestroyNotify) bt_put); + NULL, (GDestroyNotify) bt_object_put_ref); if (!map_obj->ght) { BT_LOGE_STR("Failed to allocate a GHashTable."); g_free(map_obj); @@ -875,7 +875,7 @@ enum bt_value_status bt_value_array_append_element(struct bt_value *array_obj, BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY); BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object"); g_ptr_array_add(typed_array_obj->garray, element_obj); - bt_get(element_obj); + bt_object_get_ref(element_obj); BT_LOGV("Appended element to array value: array-value-addr=%p, " "element-value-addr=%p, new-size=%u", array_obj, element_obj, typed_array_obj->garray->len); @@ -890,7 +890,7 @@ enum bt_value_status bt_value_array_append_bool_element(struct bt_value *array_o bool_obj = bt_value_bool_create_init(val); ret = bt_value_array_append_element(array_obj, bool_obj); - bt_put(bool_obj); + bt_object_put_ref(bool_obj); return ret; } @@ -902,7 +902,7 @@ enum bt_value_status bt_value_array_append_integer_element( integer_obj = bt_value_integer_create_init(val); ret = bt_value_array_append_element(array_obj, integer_obj); - bt_put(integer_obj); + bt_object_put_ref(integer_obj); return ret; } @@ -914,7 +914,7 @@ enum bt_value_status bt_value_array_append_real_element(struct bt_value *array_o real_obj = bt_value_real_create_init(val); ret = bt_value_array_append_element(array_obj, real_obj); - bt_put(real_obj); + bt_object_put_ref(real_obj); return ret; } @@ -926,7 +926,7 @@ enum bt_value_status bt_value_array_append_string_element(struct bt_value *array string_obj = bt_value_string_create_init(val); ret = bt_value_array_append_element(array_obj, string_obj); - bt_put(string_obj); + bt_object_put_ref(string_obj); return ret; } @@ -938,7 +938,7 @@ enum bt_value_status bt_value_array_append_empty_array_element( empty_array_obj = bt_value_array_create(); ret = bt_value_array_append_element(array_obj, empty_array_obj); - bt_put(empty_array_obj); + bt_object_put_ref(empty_array_obj); return ret; } @@ -949,7 +949,7 @@ enum bt_value_status bt_value_array_append_empty_map_element(struct bt_value *ar map_obj = bt_value_map_create(); ret = bt_value_array_append_element(array_obj, map_obj); - bt_put(map_obj); + bt_object_put_ref(map_obj); return ret; } @@ -965,9 +965,9 @@ enum bt_value_status bt_value_array_set_element_by_index(struct bt_value *array_ BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object"); BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index, typed_array_obj->garray->len); - bt_put(g_ptr_array_index(typed_array_obj->garray, index)); + bt_object_put_ref(g_ptr_array_index(typed_array_obj->garray, index)); g_ptr_array_index(typed_array_obj->garray, index) = element_obj; - bt_get(element_obj); + bt_object_get_ref(element_obj); BT_LOGV("Set array value's element: array-value-addr=%p, " "index=%" PRIu64 ", element-value-addr=%p", array_obj, index, element_obj); @@ -1015,7 +1015,7 @@ enum bt_value_status bt_value_map_insert_entry(struct bt_value *map_obj, BT_ASSERT_PRE_VALUE_HOT(map_obj, "Map value object"); g_hash_table_insert(BT_VALUE_TO_MAP(map_obj)->ght, GUINT_TO_POINTER(g_quark_from_string(key)), element_obj); - bt_get(element_obj); + bt_object_get_ref(element_obj); BT_LOGV("Inserted value into map value: map-value-addr=%p, " "key=\"%s\", element-value-addr=%p", map_obj, key, element_obj); @@ -1030,7 +1030,7 @@ enum bt_value_status bt_value_map_insert_bool_entry(struct bt_value *map_obj, bool_obj = bt_value_bool_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, bool_obj); - bt_put(bool_obj); + bt_object_put_ref(bool_obj); return ret; } @@ -1042,7 +1042,7 @@ enum bt_value_status bt_value_map_insert_integer_entry(struct bt_value *map_obj, integer_obj = bt_value_integer_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, integer_obj); - bt_put(integer_obj); + bt_object_put_ref(integer_obj); return ret; } @@ -1054,7 +1054,7 @@ enum bt_value_status bt_value_map_insert_real_entry(struct bt_value *map_obj, real_obj = bt_value_real_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, real_obj); - bt_put(real_obj); + bt_object_put_ref(real_obj); return ret; } @@ -1066,7 +1066,7 @@ enum bt_value_status bt_value_map_insert_string_entry(struct bt_value *map_obj, string_obj = bt_value_string_create_init(val); ret = bt_value_map_insert_entry(map_obj, key, string_obj); - bt_put(string_obj); + bt_object_put_ref(string_obj); return ret; } @@ -1078,7 +1078,7 @@ enum bt_value_status bt_value_map_insert_empty_array_entry(struct bt_value *map_ array_obj = bt_value_array_create(); ret = bt_value_map_insert_entry(map_obj, key, array_obj); - bt_put(array_obj); + bt_object_put_ref(array_obj); return ret; } @@ -1090,7 +1090,7 @@ enum bt_value_status bt_value_map_insert_empty_map_entry(struct bt_value *map_ob empty_map_obj = bt_value_map_create(); ret = bt_value_map_insert_entry(map_obj, key, empty_map_obj); - bt_put(empty_map_obj); + bt_object_put_ref(empty_map_obj); return ret; } @@ -1156,7 +1156,7 @@ error: extend_data->got_error = BT_TRUE; end: - BT_PUT(extension_obj_elem_copy); + BT_OBJECT_PUT_REF_AND_RESET(extension_obj_elem_copy); return ret; } @@ -1205,7 +1205,7 @@ struct bt_value *bt_value_map_extend(struct bt_value *base_map_obj, goto end; error: - BT_PUT(extended_obj); + BT_OBJECT_PUT_REF_AND_RESET(extended_obj); end: return extended_obj; diff --git a/plugins/ctf/common/bfcr/bfcr.c b/plugins/ctf/common/bfcr/bfcr.c index 1a800bbd..40d5b2a1 100644 --- a/plugins/ctf/common/bfcr/bfcr.c +++ b/plugins/ctf/common/bfcr/bfcr.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include diff --git a/plugins/ctf/common/metadata/ctf-meta-translate.c b/plugins/ctf/common/metadata/ctf-meta-translate.c index 1b662771..08b7499e 100644 --- a/plugins/ctf/common/metadata/ctf-meta-translate.c +++ b/plugins/ctf/common/metadata/ctf-meta-translate.c @@ -152,7 +152,7 @@ struct bt_field_class *ctf_field_class_struct_to_ir( ret = bt_field_class_structure_append_member(ir_fc, named_fc->name->str, member_ir_fc); BT_ASSERT(ret == 0); - bt_put(member_ir_fc); + bt_object_put_ref(member_ir_fc); } return ir_fc; @@ -205,7 +205,7 @@ struct bt_field_class *ctf_field_class_variant_to_ir( ret = bt_field_class_variant_append_option(ir_fc, named_fc->name->str, option_ir_fc); BT_ASSERT(ret == 0); - bt_put(option_ir_fc); + bt_object_put_ref(option_ir_fc); } return ir_fc; @@ -231,7 +231,7 @@ struct bt_field_class *ctf_field_class_array_to_ir( BT_ASSERT(elem_ir_fc); ir_fc = bt_field_class_static_array_create(elem_ir_fc, fc->length); BT_ASSERT(ir_fc); - bt_put(elem_ir_fc); + bt_object_put_ref(elem_ir_fc); end: return ir_fc; @@ -258,7 +258,7 @@ struct bt_field_class *ctf_field_class_sequence_to_ir( BT_ASSERT(elem_ir_fc); ir_fc = bt_field_class_dynamic_array_create(elem_ir_fc); BT_ASSERT(ir_fc); - bt_put(elem_ir_fc); + bt_object_put_ref(elem_ir_fc); BT_ASSERT(ir_fc); ret = bt_field_class_dynamic_array_set_length_field_class(ir_fc, borrow_ir_ft_from_field_path(&fc->length_path, tc, sc, ec)); @@ -405,7 +405,7 @@ struct bt_event_class *ctf_event_class_to_ir(struct ctf_event_class *ec, ir_ec = bt_event_class_create_with_id(ir_sc, ec->id); BT_ASSERT(ir_ec); - bt_put(ir_ec); + bt_object_put_ref(ir_ec); if (ec->spec_context_fc) { struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir( @@ -415,7 +415,7 @@ struct bt_event_class *ctf_event_class_to_ir(struct ctf_event_class *ec, ret = bt_event_class_set_specific_context_field_class( ir_ec, ir_fc); BT_ASSERT(ret == 0); - bt_put(ir_fc); + bt_object_put_ref(ir_fc); } } @@ -427,7 +427,7 @@ struct bt_event_class *ctf_event_class_to_ir(struct ctf_event_class *ec, ret = bt_event_class_set_payload_field_class(ir_ec, ir_fc); BT_ASSERT(ret == 0); - bt_put(ir_fc); + bt_object_put_ref(ir_fc); } } @@ -470,7 +470,7 @@ struct bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc, ir_sc = bt_stream_class_create_with_id(ir_trace, sc->id); BT_ASSERT(ir_sc); - bt_put(ir_sc); + bt_object_put_ref(ir_sc); if (sc->packet_context_fc) { struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir( @@ -480,7 +480,7 @@ struct bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc, ret = bt_stream_class_set_packet_context_field_class( ir_sc, ir_fc); BT_ASSERT(ret == 0); - bt_put(ir_fc); + bt_object_put_ref(ir_fc); } } @@ -492,7 +492,7 @@ struct bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc, ret = bt_stream_class_set_event_header_field_class(ir_sc, ir_fc); BT_ASSERT(ret == 0); - bt_put(ir_fc); + bt_object_put_ref(ir_fc); } } @@ -504,7 +504,7 @@ struct bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc, ret = bt_stream_class_set_event_common_context_field_class( ir_sc, ir_fc); BT_ASSERT(ret == 0); - bt_put(ir_fc); + bt_object_put_ref(ir_fc); } } @@ -586,7 +586,7 @@ int ctf_trace_class_to_ir(struct bt_trace *ir_trace, ret = bt_trace_set_packet_header_field_class(ir_trace, ir_fc); BT_ASSERT(ret == 0); - bt_put(ir_fc); + bt_object_put_ref(ir_fc); } } diff --git a/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c b/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c index d5039f79..2bd10f1d 100644 --- a/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c +++ b/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c @@ -159,7 +159,7 @@ int update_stream_class_default_clock_class( } if (!stream_class->default_clock_class) { - stream_class->default_clock_class = bt_get(clock_class); + stream_class->default_clock_class = bt_object_get_ref(clock_class); } end: diff --git a/plugins/ctf/common/metadata/ctf-meta.h b/plugins/ctf/common/metadata/ctf-meta.h index 60b9e0c6..557ba7e9 100644 --- a/plugins/ctf/common/metadata/ctf-meta.h +++ b/plugins/ctf/common/metadata/ctf-meta.h @@ -472,7 +472,7 @@ static inline void _ctf_field_class_int_destroy(struct ctf_field_class_int *fc) { BT_ASSERT(fc); - bt_put(fc->mapped_clock_class); + bt_object_put_ref(fc->mapped_clock_class); g_free(fc); } @@ -480,7 +480,7 @@ static inline void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc) { BT_ASSERT(fc); - bt_put(fc->base.mapped_clock_class); + bt_object_put_ref(fc->base.mapped_clock_class); if (fc->mappings) { uint64_t i; @@ -1108,7 +1108,7 @@ void ctf_field_class_int_copy_content( dst_fc->is_signed = src_fc->is_signed; dst_fc->disp_base = src_fc->disp_base; dst_fc->encoding = src_fc->encoding; - dst_fc->mapped_clock_class = bt_get(src_fc->mapped_clock_class); + dst_fc->mapped_clock_class = bt_object_get_ref(src_fc->mapped_clock_class); dst_fc->storing_index = src_fc->storing_index; } @@ -1397,7 +1397,7 @@ void ctf_stream_class_destroy(struct ctf_stream_class *sc) ctf_field_class_destroy(sc->packet_context_fc); ctf_field_class_destroy(sc->event_header_fc); ctf_field_class_destroy(sc->event_common_context_fc); - bt_put(sc->default_clock_class); + bt_object_put_ref(sc->default_clock_class); g_free(sc); } @@ -1453,7 +1453,7 @@ struct ctf_trace_class *ctf_trace_class_create(void) tc->default_byte_order = -1; BT_ASSERT(tc->name); tc->clock_classes = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_put); + (GDestroyNotify) bt_object_put_ref); BT_ASSERT(tc->clock_classes); tc->stream_classes = g_ptr_array_new_with_free_func( (GDestroyNotify) ctf_stream_class_destroy); diff --git a/plugins/ctf/common/metadata/visitor-generate-ir.c b/plugins/ctf/common/metadata/visitor-generate-ir.c index b1519ff5..8f817cc6 100644 --- a/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -554,7 +554,7 @@ void ctx_destroy(struct ctx *ctx) scope = parent_scope; } - bt_put(ctx->trace); + bt_object_put_ref(ctx->trace); if (ctx->ctf_tc) { ctf_trace_class_destroy(ctx->ctf_tc); @@ -2719,7 +2719,7 @@ int visit_integer_decl(struct ctx *ctx, (*integer_decl)->is_signed = (signedness > 0); (*integer_decl)->disp_base = base; (*integer_decl)->encoding = encoding; - (*integer_decl)->mapped_clock_class = bt_get(mapped_clock_class); + (*integer_decl)->mapped_clock_class = bt_object_get_ref(mapped_clock_class); return 0; error: @@ -3613,7 +3613,7 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx, "default"); BT_ASSERT(ret == 0); g_ptr_array_add(ctx->ctf_tc->clock_classes, - bt_get(clock_class_to_map_to)); + bt_object_get_ref(clock_class_to_map_to)); break; case 1: /* @@ -3621,7 +3621,7 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx, * this one. */ clock_class_to_map_to = - bt_get(ctx->ctf_tc->clock_classes->pdata[0]); + bt_object_get_ref(ctx->ctf_tc->clock_classes->pdata[0]); break; default: /* @@ -3635,10 +3635,10 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx, } BT_ASSERT(clock_class_to_map_to); - int_fc->mapped_clock_class = bt_get(clock_class_to_map_to); + int_fc->mapped_clock_class = bt_object_get_ref(clock_class_to_map_to); end: - bt_put(clock_class_to_map_to); + bt_object_put_ref(clock_class_to_map_to); return ret; } @@ -4776,10 +4776,10 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) ret = bt_clock_class_set_offset(clock, offset_seconds, offset_cycles); BT_ASSERT(ret == 0); apply_clock_class_offset(ctx, clock); - g_ptr_array_add(ctx->ctf_tc->clock_classes, bt_get(clock)); + g_ptr_array_add(ctx->ctf_tc->clock_classes, bt_object_get_ref(clock)); end: - BT_PUT(clock); + BT_OBJECT_PUT_REF_AND_RESET(clock); return ret; } @@ -4934,7 +4934,7 @@ struct bt_trace *ctf_visitor_generate_ir_get_ir_trace( BT_ASSERT(ctx); BT_ASSERT(ctx->trace); - return bt_get(ctx->trace); + return bt_object_get_ref(ctx->trace); } BT_HIDDEN diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index e7f2e079..8fa8877b 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -803,7 +803,7 @@ enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) "stream-class-addr=%p, stream-class-id=%" PRId64, notit, notit->meta.sc, notit->meta.sc->id); - stream = bt_get(notit->medium.medops.borrow_stream( + stream = bt_object_get_ref(notit->medium.medops.borrow_stream( notit->meta.sc->ir_sc, notit->cur_data_stream_id, notit->medium.data)); BT_LOGV("User function returned: stream-addr=%p", stream); @@ -821,10 +821,10 @@ enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) goto end; } - BT_MOVE(notit->stream, stream); + BT_OBJECT_MOVE_REF(notit->stream, stream); end: - bt_put(stream); + bt_object_put_ref(stream); return status; } @@ -859,11 +859,11 @@ enum bt_notif_iter_status set_current_packet(struct bt_notif_iter *notit) goto end; error: - BT_PUT(packet); + BT_OBJECT_PUT_REF_AND_RESET(packet); status = BT_NOTIF_ITER_STATUS_ERROR; end: - BT_MOVE(notit->packet, packet); + BT_OBJECT_MOVE_REF(notit->packet, packet); return status; } @@ -1217,11 +1217,11 @@ enum bt_notif_iter_status set_current_event_notification( goto end; error: - BT_PUT(notif); + BT_OBJECT_PUT_REF_AND_RESET(notif); status = BT_NOTIF_ITER_STATUS_ERROR; end: - BT_MOVE(notit->event_notif, notif); + BT_OBJECT_MOVE_REF(notit->event_notif, notif); return status; } @@ -1569,9 +1569,9 @@ void bt_notif_iter_reset(struct bt_notif_iter *notit) stack_clear(notit->stack); notit->meta.sc = NULL; notit->meta.ec = NULL; - BT_PUT(notit->packet); - BT_PUT(notit->stream); - BT_PUT(notit->event_notif); + BT_OBJECT_PUT_REF_AND_RESET(notit->packet); + BT_OBJECT_PUT_REF_AND_RESET(notit->stream); + BT_OBJECT_PUT_REF_AND_RESET(notit->event_notif); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -1626,8 +1626,8 @@ int bt_notif_iter_switch_packet(struct bt_notif_iter *notit) notit->cur_packet_offset); stack_clear(notit->stack); notit->meta.ec = NULL; - BT_PUT(notit->packet); - BT_PUT(notit->event_notif); + BT_OBJECT_PUT_REF_AND_RESET(notit->packet); + BT_OBJECT_PUT_REF_AND_RESET(notit->event_notif); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -2258,7 +2258,7 @@ void notify_new_stream(struct bt_notif_iter *notit, status = set_current_stream(notit); if (status != BT_NOTIF_ITER_STATUS_OK) { - BT_PUT(ret); + BT_OBJECT_PUT_REF_AND_RESET(ret); goto end; } @@ -2425,7 +2425,7 @@ void notify_end_of_packet(struct bt_notif_iter *notit, } - BT_PUT(notit->packet); + BT_OBJECT_PUT_REF_AND_RESET(notit->packet); *notification = notif; } @@ -2501,8 +2501,8 @@ error: void bt_notif_iter_destroy(struct bt_notif_iter *notit) { - BT_PUT(notit->packet); - BT_PUT(notit->stream); + BT_OBJECT_PUT_REF_AND_RESET(notit->packet); + BT_OBJECT_PUT_REF_AND_RESET(notit->stream); release_all_dscopes(notit); BT_LOGD("Destroying CTF plugin notification iterator: addr=%p", notit); diff --git a/plugins/ctf/fs-sink/write.c b/plugins/ctf/fs-sink/write.c index c3f837bf..64aed260 100644 --- a/plugins/ctf/fs-sink/write.c +++ b/plugins/ctf/fs-sink/write.c @@ -40,13 +40,13 @@ static void unref_stream_class(struct bt_stream_class *writer_stream_class) { - bt_put(writer_stream_class); + bt_object_put_ref(writer_stream_class); } static void unref_stream(struct bt_stream_class *writer_stream) { - bt_put(writer_stream); + bt_object_put_ref(writer_stream); } static @@ -145,10 +145,10 @@ struct bt_stream_class *insert_new_stream_class( goto end; error: - BT_PUT(writer_stream_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); end: - bt_put(writer_trace); - bt_put(trace); + bt_object_put_ref(writer_trace); + bt_object_put_ref(trace); return writer_stream_class; } @@ -315,7 +315,7 @@ struct fs_writer *insert_new_writer( ret = ctf_copy_trace(writer_component->err, trace, writer_trace); if (ret != BT_COMPONENT_STATUS_OK) { BT_LOGE_STR("Failed to copy trace."); - BT_PUT(ctf_writer); + BT_OBJECT_PUT_REF_AND_RESET(ctf_writer); goto error; } @@ -328,7 +328,7 @@ struct fs_writer *insert_new_writer( fs_writer->trace = trace; fs_writer->writer_trace = writer_trace; fs_writer->writer_component = writer_component; - BT_PUT(writer_trace); + BT_OBJECT_PUT_REF_AND_RESET(writer_trace); fs_writer->stream_class_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) unref_stream_class); fs_writer->stream_map = g_hash_table_new_full(g_direct_hash, @@ -343,7 +343,7 @@ struct fs_writer *insert_new_writer( BT_ASSERT(stream); insert_new_stream_state(writer_component, fs_writer, stream); - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); } /* Check if the trace is already static or register a listener. */ @@ -366,9 +366,9 @@ struct fs_writer *insert_new_writer( error: g_free(fs_writer); fs_writer = NULL; - bt_put(writer_trace); - bt_put(stream); - BT_PUT(ctf_writer); + bt_object_put_ref(writer_trace); + bt_object_put_ref(stream); + BT_OBJECT_PUT_REF_AND_RESET(ctf_writer); end: return fs_writer; } @@ -388,7 +388,7 @@ struct fs_writer *get_fs_writer(struct writer_component *writer_component, if (!fs_writer) { fs_writer = insert_new_writer(writer_component, trace); } - BT_PUT(trace); + BT_OBJECT_PUT_REF_AND_RESET(trace); return fs_writer; } @@ -406,7 +406,7 @@ struct fs_writer *get_fs_writer_from_stream( fs_writer = get_fs_writer(writer_component, stream_class); - bt_put(stream_class); + bt_object_put_ref(stream_class); return fs_writer; } @@ -442,7 +442,7 @@ struct bt_stream *insert_new_stream( { struct bt_stream *writer_stream = NULL; struct bt_stream_class *writer_stream_class = NULL; - struct bt_ctf_writer *ctf_writer = bt_get(fs_writer->writer); + struct bt_ctf_writer *ctf_writer = bt_object_get_ref(fs_writer->writer); writer_stream_class = lookup_stream_class(writer_component, stream_class); @@ -454,7 +454,7 @@ struct bt_stream *insert_new_stream( goto error; } } - bt_get(writer_stream_class); + bt_object_get_ref(writer_stream_class); writer_stream = bt_stream_create(writer_stream_class, bt_stream_get_name(stream)); @@ -466,10 +466,10 @@ struct bt_stream *insert_new_stream( goto end; error: - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); end: - bt_put(ctf_writer); - bt_put(writer_stream_class); + bt_object_put_ref(ctf_writer); + bt_object_put_ref(writer_stream_class); return writer_stream; } @@ -494,12 +494,12 @@ struct bt_stream *get_writer_stream( BT_LOGE_STR("Failed to find existing stream."); goto error; } - bt_get(writer_stream); + bt_object_get_ref(writer_stream); goto end; error: - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); end: return writer_stream; } @@ -577,7 +577,7 @@ enum bt_component_status writer_stream_begin( error: ret = BT_COMPONENT_STATUS_ERROR; end: - bt_put(stream_class); + bt_object_put_ref(stream_class); return ret; } @@ -627,8 +627,8 @@ enum bt_component_status writer_stream_end( error: ret = BT_COMPONENT_STATUS_ERROR; end: - BT_PUT(trace); - BT_PUT(stream_class); + BT_OBJECT_PUT_REF_AND_RESET(trace); + BT_OBJECT_PUT_REF_AND_RESET(stream_class); return ret; } @@ -649,7 +649,7 @@ enum bt_component_status writer_new_packet( BT_LOGE_STR("Failed to get writer_stream."); goto error; } - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); int_ret = ctf_stream_copy_packet_context( writer_component->err, packet, writer_stream); @@ -670,8 +670,8 @@ enum bt_component_status writer_new_packet( error: ret = BT_COMPONENT_STATUS_ERROR; end: - bt_put(writer_stream); - bt_put(stream); + bt_object_put_ref(writer_stream); + bt_object_put_ref(stream); return ret; } @@ -691,9 +691,9 @@ enum bt_component_status writer_close_packet( BT_LOGE_STR("Failed to find existing stream."); goto error; } - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); - bt_get(writer_stream); + bt_object_get_ref(writer_stream); ret = bt_stream_flush(writer_stream); if (ret) { @@ -701,7 +701,7 @@ enum bt_component_status writer_close_packet( goto error; } - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); ret = BT_COMPONENT_STATUS_OK; goto end; @@ -709,8 +709,8 @@ enum bt_component_status writer_close_packet( error: ret = BT_COMPONENT_STATUS_ERROR; end: - bt_put(writer_stream); - bt_put(stream); + bt_object_put_ref(writer_stream); + bt_object_put_ref(stream); return ret; } @@ -734,7 +734,7 @@ enum bt_component_status writer_output_event( BT_ASSERT(stream); writer_stream = lookup_stream(writer_component, stream); - if (!writer_stream || !bt_get(writer_stream)) { + if (!writer_stream || !bt_object_get_ref(writer_stream)) { BT_LOGE_STR("Failed for find existing stream."); goto error; } @@ -743,7 +743,7 @@ enum bt_component_status writer_output_event( BT_ASSERT(stream_class); writer_stream_class = lookup_stream_class(writer_component, stream_class); - if (!writer_stream_class || !bt_get(writer_stream_class)) { + if (!writer_stream_class || !bt_object_get_ref(writer_stream_class)) { BT_LOGE_STR("Failed to find existing stream_class."); goto error; } @@ -790,13 +790,13 @@ enum bt_component_status writer_output_event( error: ret = BT_COMPONENT_STATUS_ERROR; end: - bt_put(writer_trace); - bt_put(writer_event); - bt_put(writer_event_class); - bt_put(writer_stream_class); - bt_put(stream_class); - bt_put(writer_stream); - bt_put(stream); - bt_put(event_class); + bt_object_put_ref(writer_trace); + bt_object_put_ref(writer_event); + bt_object_put_ref(writer_event_class); + bt_object_put_ref(writer_stream_class); + bt_object_put_ref(stream_class); + bt_object_put_ref(writer_stream); + bt_object_put_ref(stream); + bt_object_put_ref(event_class); return ret; } diff --git a/plugins/ctf/fs-sink/writer.c b/plugins/ctf/fs-sink/writer.c index ccfa6f26..b8e21137 100644 --- a/plugins/ctf/fs-sink/writer.c +++ b/plugins/ctf/fs-sink/writer.c @@ -52,7 +52,7 @@ gboolean empty_trace_map(gpointer key, gpointer value, gpointer user_data) static void destroy_writer_component_data(struct writer_component *writer_component) { - bt_put(writer_component->input_iterator); + bt_object_put_ref(writer_component->input_iterator); g_hash_table_foreach_remove(writer_component->trace_map, empty_trace_map, writer_component); @@ -75,7 +75,7 @@ void writer_component_finalize(struct bt_private_component *component) static void free_fs_writer(struct fs_writer *fs_writer) { - bt_put(fs_writer->writer); + bt_object_put_ref(fs_writer->writer); g_free(fs_writer); } @@ -132,7 +132,7 @@ enum bt_component_status handle_notification( } ret = writer_new_packet(writer_component, packet); - bt_put(packet); + bt_object_put_ref(packet); break; } case BT_NOTIFICATION_TYPE_PACKET_END: @@ -145,7 +145,7 @@ enum bt_component_status handle_notification( goto end; } ret = writer_close_packet(writer_component, packet); - bt_put(packet); + bt_object_put_ref(packet); break; } case BT_NOTIFICATION_TYPE_EVENT: @@ -158,7 +158,7 @@ enum bt_component_status handle_notification( goto end; } ret = writer_output_event(writer_component, event); - bt_put(event); + bt_object_put_ref(event); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } @@ -174,7 +174,7 @@ enum bt_component_status handle_notification( goto end; } ret = writer_stream_begin(writer_component, stream); - bt_put(stream); + bt_object_put_ref(stream); break; } case BT_NOTIFICATION_TYPE_STREAM_END: @@ -187,7 +187,7 @@ enum bt_component_status handle_notification( goto end; } ret = writer_stream_end(writer_component, stream); - bt_put(stream); + bt_object_put_ref(stream); break; } default: @@ -218,7 +218,7 @@ void writer_component_port_connected( writer->error = true; } - bt_put(connection); + bt_object_put_ref(connection); } BT_HIDDEN @@ -243,7 +243,7 @@ enum bt_component_status writer_run(struct bt_private_component *component) switch (it_ret) { case BT_NOTIFICATION_ITERATOR_STATUS_END: ret = BT_COMPONENT_STATUS_END; - BT_PUT(writer_component->input_iterator); + BT_OBJECT_PUT_REF_AND_RESET(writer_component->input_iterator); goto end; case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: ret = BT_COMPONENT_STATUS_AGAIN; @@ -259,7 +259,7 @@ enum bt_component_status writer_run(struct bt_private_component *component) BT_ASSERT(notification); ret = handle_notification(writer_component, notification); end: - bt_put(notification); + bt_object_put_ref(notification); return ret; } @@ -289,7 +289,7 @@ enum bt_component_status apply_one_bool(const char *key, *found = true; } end: - bt_put(value); + bt_object_put_ref(value); return ret; } @@ -327,7 +327,7 @@ enum bt_component_status writer_component_init( ret = BT_COMPONENT_STATUS_INVALID; goto error; } - bt_put(value); + bt_object_put_ref(value); writer_component->base_path = g_string_new(path); if (!writer_component->base_path) { diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index 36571990..9f7b7972 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -639,7 +639,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( goto error; } - ds_file->stream = bt_get(stream); + ds_file->stream = bt_object_get_ref(stream); ds_file->metadata = ctf_fs_trace->metadata; g_string_assign(ds_file->file->path, path); ret = ctf_fs_file_open(ds_file->file, "rb"); @@ -691,8 +691,8 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file) return; } - bt_put(ds_file->cc_prio_map); - bt_put(ds_file->stream); + bt_object_put_ref(ds_file->cc_prio_map); + bt_object_put_ref(ds_file->stream); (void) ds_file_munmap(ds_file); if (ds_file->file) { diff --git a/plugins/ctf/fs-src/fs.c b/plugins/ctf/fs-src/fs.c index f48d5087..f5a4b57d 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -107,7 +107,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_next_one( * BT_NOTIFICATION_TYPE_STREAM_BEGIN * notification: skip this one, get a new one. */ - BT_PUT(*notif); + BT_OBJECT_PUT_REF_AND_RESET(*notif); status = ctf_fs_ds_file_next(notif_iter_data->ds_file, notif); BT_ASSERT(status != BT_NOTIFICATION_ITERATOR_STATUS_END); @@ -141,7 +141,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_next_one( goto end; } - BT_PUT(*notif); + BT_OBJECT_PUT_REF_AND_RESET(*notif); bt_notif_iter_reset(notif_iter_data->notif_iter); /* @@ -177,7 +177,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_next_one( if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { BT_ASSERT(bt_notification_get_type(*notif) == BT_NOTIFICATION_TYPE_STREAM_BEGIN); - BT_PUT(*notif); + BT_OBJECT_PUT_REF_AND_RESET(*notif); status = ctf_fs_ds_file_next(notif_iter_data->ds_file, notif); BT_ASSERT(status != BT_NOTIFICATION_ITERATOR_STATUS_END); @@ -508,8 +508,8 @@ void ctf_fs_ds_file_group_destroy(struct ctf_fs_ds_file_group *ds_file_group) g_ptr_array_free(ds_file_group->ds_file_infos, TRUE); } - bt_put(ds_file_group->stream); - bt_put(ds_file_group->stream_class); + bt_object_put_ref(ds_file_group->stream); + bt_object_put_ref(ds_file_group->stream_class); g_free(ds_file_group); } @@ -534,7 +534,7 @@ struct ctf_fs_ds_file_group *ctf_fs_ds_file_group_create( ds_file_group->stream_id = stream_instance_id; BT_ASSERT(stream_class); - ds_file_group->stream_class = bt_get(stream_class); + ds_file_group->stream_class = bt_object_get_ref(stream_class); ds_file_group->ctf_fs_trace = ctf_fs_trace; goto end; diff --git a/plugins/ctf/fs-src/metadata.c b/plugins/ctf/fs-src/metadata.c index e949374d..35482944 100644 --- a/plugins/ctf/fs-src/metadata.c +++ b/plugins/ctf/fs-src/metadata.c @@ -145,7 +145,7 @@ void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata) } if (metadata->trace) { - BT_PUT(metadata->trace); + BT_OBJECT_PUT_REF_AND_RESET(metadata->trace); } if (metadata->decoder) { diff --git a/plugins/ctf/fs-src/query.c b/plugins/ctf/fs-src/query.c index b2830a76..775b071c 100644 --- a/plugins/ctf/fs-src/query.c +++ b/plugins/ctf/fs-src/query.c @@ -165,7 +165,7 @@ struct bt_component_class_query_method_return metadata_info_query( goto end; error: - BT_PUT(query_ret.result); + BT_OBJECT_PUT_REF_AND_RESET(query_ret.result); if (query_ret.status >= 0) { query_ret.status = BT_QUERY_STATUS_ERROR; @@ -224,7 +224,7 @@ int add_range(struct bt_value *info, struct range *range, goto end; } end: - bt_put(range_map); + bt_object_put_ref(range_map); return ret; } @@ -339,7 +339,7 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group, goto end; } end: - bt_put(file_paths); + bt_object_put_ref(file_paths); return ret; } @@ -411,7 +411,7 @@ int populate_trace_info(const char *trace_path, const char *trace_name, ret = populate_stream_info(group, group_info, &group_range); if (ret) { - bt_put(group_info); + bt_object_put_ref(group_info); goto end; } @@ -428,7 +428,7 @@ int populate_trace_info(const char *trace_path, const char *trace_name, group_range.end_ns); trace_intersection.set = true; status = bt_value_array_append_element(file_groups, group_info); - bt_put(group_info); + bt_object_put_ref(group_info); if (status != BT_VALUE_STATUS_OK) { goto end; } @@ -449,14 +449,14 @@ int populate_trace_info(const char *trace_path, const char *trace_name, } status = bt_value_map_insert_entry(trace_info, "streams", file_groups); - BT_PUT(file_groups); + BT_OBJECT_PUT_REF_AND_RESET(file_groups); if (status != BT_VALUE_STATUS_OK) { ret = -1; goto end; } end: - bt_put(file_groups); + bt_object_put_ref(file_groups); ctf_fs_trace_destroy(trace); return ret; } @@ -539,12 +539,12 @@ struct bt_component_class_query_method_return trace_info_query( ret = populate_trace_info(trace_path->str, trace_name->str, trace_info); if (ret) { - bt_put(trace_info); + bt_object_put_ref(trace_info); goto error; } status = bt_value_array_append_element(query_ret.result, trace_info); - bt_put(trace_info); + bt_object_put_ref(trace_info); if (status != BT_VALUE_STATUS_OK) { goto error; } @@ -553,7 +553,7 @@ struct bt_component_class_query_method_return trace_info_query( goto end; error: - BT_PUT(query_ret.result); + BT_OBJECT_PUT_REF_AND_RESET(query_ret.result); if (query_ret.status >= 0) { query_ret.status = BT_QUERY_STATUS_ERROR; diff --git a/plugins/ctf/lttng-live/data-stream.c b/plugins/ctf/lttng-live/data-stream.c index b18dda14..944adf7c 100644 --- a/plugins/ctf/lttng-live/data-stream.c +++ b/plugins/ctf/lttng-live/data-stream.c @@ -209,14 +209,14 @@ void lttng_live_stream_iterator_destroy(struct lttng_live_stream_iterator *strea BT_ASSERT(!ret); if (stream->stream) { - BT_PUT(stream->stream); + BT_OBJECT_PUT_REF_AND_RESET(stream->stream); } if (stream->notif_iter) { bt_notif_iter_destroy(stream->notif_iter); } g_free(stream->buf); - BT_PUT(stream->packet_end_notif_queue); + BT_OBJECT_PUT_REF_AND_RESET(stream->packet_end_notif_queue); bt_list_del(&stream->node); /* * Ensure we poke the trace metadata in the future, which is diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index 107c4a26..27c2cf5a 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -76,7 +76,7 @@ void print_stream_state(struct lttng_live_stream_iterator *stream) print_state(stream), stream->last_returned_inactivity_timestamp, stream->current_inactivity_timestamp); - bt_put(port); + bt_object_put_ref(port); } BT_HIDDEN @@ -93,8 +93,8 @@ bt_bool lttng_live_is_canceled(struct lttng_live_component *lttng_live) component = bt_component_from_private(lttng_live->private_component); graph = bt_component_get_graph(component); ret = bt_graph_is_canceled(graph); - bt_put(graph); - bt_put(component); + bt_object_put_ref(graph); + bt_object_put_ref(component); return ret; } @@ -124,13 +124,13 @@ int lttng_live_add_port(struct lttng_live_component *lttng_live, default: return -1; } - bt_put(private_port); /* weak */ + bt_object_put_ref(private_port); /* weak */ BT_LOGI("Added port %s", name); if (lttng_live->no_stream_port) { - bt_get(lttng_live->no_stream_port); + bt_object_get_ref(lttng_live->no_stream_port); ret = bt_private_port_remove_from_component(lttng_live->no_stream_port); - bt_put(lttng_live->no_stream_port); + bt_object_put_ref(lttng_live->no_stream_port); if (ret) { return -1; } @@ -154,7 +154,7 @@ int lttng_live_remove_port(struct lttng_live_component *lttng_live, if (nr_ports < 0) { return -1; } - BT_PUT(component); + BT_OBJECT_PUT_REF_AND_RESET(component); if (nr_ports == 1) { enum bt_component_status status; @@ -174,12 +174,12 @@ int lttng_live_remove_port(struct lttng_live_component *lttng_live, default: return -1; } - bt_put(lttng_live->no_stream_port); /* weak */ + bt_object_put_ref(lttng_live->no_stream_port); /* weak */ lttng_live->no_stream_iter->port = lttng_live->no_stream_port; } - bt_get(port); + bt_object_get_ref(port); ret = bt_private_port_remove_from_component(port); - bt_put(port); + bt_object_put_ref(port); if (ret) { return -1; } @@ -214,10 +214,10 @@ void lttng_live_destroy_trace(struct bt_object *obj) retval = bt_trace_set_is_static(trace->trace); BT_ASSERT(!retval); - BT_PUT(trace->trace); + BT_OBJECT_PUT_REF_AND_RESET(trace->trace); } lttng_live_metadata_fini(trace); - BT_PUT(trace->cc_prio_map); + BT_OBJECT_PUT_REF_AND_RESET(trace->cc_prio_map); g_free(trace); } @@ -254,7 +254,7 @@ struct lttng_live_trace *lttng_live_ref_trace(struct lttng_live_session *session trace = lttng_live_find_trace(session, trace_id); if (trace) { - bt_get(trace); + bt_object_get_ref(trace); return trace; } return lttng_live_create_trace(session, trace_id); @@ -263,7 +263,7 @@ struct lttng_live_trace *lttng_live_ref_trace(struct lttng_live_session *session BT_HIDDEN void lttng_live_unref_trace(struct lttng_live_trace *trace) { - bt_put(trace); + bt_object_put_ref(trace); } static @@ -589,13 +589,13 @@ enum bt_lttng_live_iterator_status emit_inactivity_notification( } *notification = notif; end: - bt_put(clock_value); - bt_put(clock_class); + bt_object_put_ref(clock_value); + bt_object_put_ref(clock_class); return ret; error: ret = BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR; - bt_put(notif); + bt_object_put_ref(notif); goto end; } @@ -627,8 +627,8 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent lttng_live_stream->last_returned_inactivity_timestamp = lttng_live_stream->current_inactivity_timestamp; end: - bt_put(clock_value); - bt_put(clock_class); + bt_object_put_ref(clock_value); + bt_object_put_ref(clock_class); return ret; } @@ -989,7 +989,7 @@ struct bt_component_class_query_method_return lttng_live_query_list_sessions( goto end; error: - BT_PUT(query_ret.result); + BT_OBJECT_PUT_REF_AND_RESET(query_ret.result); if (query_ret.status >= 0) { query_ret.status = BT_QUERY_STATUS_ERROR; @@ -999,7 +999,7 @@ end: if (viewer_connection) { bt_live_viewer_connection_destroy(viewer_connection); } - BT_PUT(url_value); + BT_OBJECT_PUT_REF_AND_RESET(url_value); return query_ret; } @@ -1032,14 +1032,14 @@ void lttng_live_component_destroy_data(struct lttng_live_component *lttng_live) bt_list_for_each_entry_safe(session, s, <tng_live->sessions, node) { lttng_live_destroy_session(session); } - BT_PUT(lttng_live->viewer_connection); + BT_OBJECT_PUT_REF_AND_RESET(lttng_live->viewer_connection); if (lttng_live->url) { g_string_free(lttng_live->url, TRUE); } if (lttng_live->no_stream_port) { - bt_get(lttng_live->no_stream_port); + bt_object_get_ref(lttng_live->no_stream_port); ret = bt_private_port_remove_from_component(lttng_live->no_stream_port); - bt_put(lttng_live->no_stream_port); + bt_object_put_ref(lttng_live->no_stream_port); BT_ASSERT(!ret); } if (lttng_live->no_stream_iter) { @@ -1089,7 +1089,7 @@ struct lttng_live_component *lttng_live_component_create(struct bt_value *params if (!lttng_live->url) { goto error; } - BT_PUT(value); + BT_OBJECT_PUT_REF_AND_RESET(value); lttng_live->viewer_connection = bt_live_viewer_connection_create(lttng_live->url->str, lttng_live); if (!lttng_live->viewer_connection) { @@ -1139,7 +1139,7 @@ enum bt_component_status lttng_live_component_init( if (ret != BT_COMPONENT_STATUS_OK) { goto end; } - bt_put(lttng_live->no_stream_port); /* weak */ + bt_object_put_ref(lttng_live->no_stream_port); /* weak */ lttng_live->no_stream_iter->port = lttng_live->no_stream_port; ret = bt_private_component_set_user_data(private_component, lttng_live); @@ -1168,7 +1168,7 @@ enum bt_component_status lttng_live_accept_port_connection( struct bt_port *self_port = bt_port_from_private(self_private_port); other_component = bt_port_get_component(other_port); - bt_put(other_component); /* weak */ + bt_object_put_ref(other_component); /* weak */ if (!lttng_live->downstream_component) { lttng_live->downstream_component = other_component; @@ -1188,6 +1188,6 @@ enum bt_component_status lttng_live_accept_port_connection( goto end; } end: - bt_put(self_port); + bt_object_put_ref(self_port); return status; } diff --git a/plugins/ctf/lttng-live/metadata.c b/plugins/ctf/lttng-live/metadata.c index 0aae051c..93b8adda 100644 --- a/plugins/ctf/lttng-live/metadata.c +++ b/plugins/ctf/lttng-live/metadata.c @@ -62,7 +62,7 @@ enum bt_lttng_live_iterator_status lttng_live_update_clock_map( size_t i; int count, ret; - BT_PUT(trace->cc_prio_map); + BT_OBJECT_PUT_REF_AND_RESET(trace->cc_prio_map); trace->cc_prio_map = bt_clock_class_priority_map_create(); if (!trace->cc_prio_map) { goto error; @@ -78,7 +78,7 @@ enum bt_lttng_live_iterator_status lttng_live_update_clock_map( BT_ASSERT(clock_class); ret = bt_clock_class_priority_map_add_clock_class( trace->cc_prio_map, clock_class, 0); - BT_PUT(clock_class); + BT_OBJECT_PUT_REF_AND_RESET(clock_class); if (ret) { goto error; @@ -195,7 +195,7 @@ enum bt_lttng_live_iterator_status lttng_live_metadata_update( decoder_status = ctf_metadata_decoder_decode(metadata->decoder, fp); switch (decoder_status) { case CTF_METADATA_DECODER_STATUS_OK: - BT_PUT(trace->trace); + BT_OBJECT_PUT_REF_AND_RESET(trace->trace); trace->trace = ctf_metadata_decoder_get_trace(metadata->decoder); trace->new_metadata_needed = false; status = lttng_live_update_clock_map(trace); diff --git a/plugins/ctf/lttng-live/viewer-connection.c b/plugins/ctf/lttng-live/viewer-connection.c index 067ed269..bea4c2ca 100644 --- a/plugins/ctf/lttng-live/viewer-connection.c +++ b/plugins/ctf/lttng-live/viewer-connection.c @@ -360,7 +360,7 @@ enum bt_value_status list_update_session(struct bt_value *results, if (ret != BT_VALUE_STATUS_OK) { goto end; } - BT_PUT(btval); + BT_OBJECT_PUT_REF_AND_RESET(btval); btval = bt_value_map_get(map, "client-count"); if (!btval) { @@ -377,22 +377,22 @@ enum bt_value_status list_update_session(struct bt_value *results, if (ret != BT_VALUE_STATUS_OK) { goto end; } - BT_PUT(btval); + BT_OBJECT_PUT_REF_AND_RESET(btval); } - BT_PUT(hostname); - BT_PUT(session_name); - BT_PUT(map); + BT_OBJECT_PUT_REF_AND_RESET(hostname); + BT_OBJECT_PUT_REF_AND_RESET(session_name); + BT_OBJECT_PUT_REF_AND_RESET(map); if (found) { break; } } end: - BT_PUT(btval); - BT_PUT(hostname); - BT_PUT(session_name); - BT_PUT(map); + BT_OBJECT_PUT_REF_AND_RESET(btval); + BT_OBJECT_PUT_REF_AND_RESET(hostname); + BT_OBJECT_PUT_REF_AND_RESET(session_name); + BT_OBJECT_PUT_REF_AND_RESET(map); *_found = found; return ret; } @@ -509,7 +509,7 @@ end: if (url) { g_string_free(url, TRUE); } - BT_PUT(map); + BT_OBJECT_PUT_REF_AND_RESET(map); return ret; } @@ -615,7 +615,7 @@ struct bt_value *bt_live_viewer_connection_list_sessions(struct bt_live_viewer_c } goto end; error: - BT_PUT(results); + BT_OBJECT_PUT_REF_AND_RESET(results); end: return results; } diff --git a/plugins/libctfcopytrace/clock-fields.c b/plugins/libctfcopytrace/clock-fields.c index 05a2b0c5..0096527e 100644 --- a/plugins/libctfcopytrace/clock-fields.c +++ b/plugins/libctfcopytrace/clock-fields.c @@ -91,7 +91,7 @@ int update_header_clock_int_field_type(FILE *err, struct bt_field_type *type, if (!clock) { return 0; } - BT_PUT(clock); + BT_OBJECT_PUT_REF_AND_RESET(clock); ret = bt_field_type_integer_set_size(type, 64); if (ret) { @@ -169,7 +169,7 @@ int find_update_variant_clock_fields(FILE *err, struct bt_field_type *type, BT_LOGE_STR("Failed to find clock fields."); goto error; } - BT_PUT(entry_type); + BT_OBJECT_PUT_REF_AND_RESET(entry_type); } ret = 0; @@ -178,7 +178,7 @@ int find_update_variant_clock_fields(FILE *err, struct bt_field_type *type, error: ret = -1; end: - bt_put(entry_type); + bt_object_put_ref(entry_type); return ret; } @@ -206,14 +206,14 @@ int find_update_struct_clock_fields(FILE *err, struct bt_field_type *type, BT_LOGE_STR("Failed to find clock fields."); goto error; } - BT_PUT(entry_type); + BT_OBJECT_PUT_REF_AND_RESET(entry_type); } ret = 0; goto end; error: - bt_put(entry_type); + bt_object_put_ref(entry_type); end: return ret; } @@ -229,7 +229,7 @@ int find_update_sequence_clock_fields(FILE *err, struct bt_field_type *type, BT_ASSERT(entry_type); ret = find_update_clock_fields(err, entry_type, writer_clock_class); - BT_PUT(entry_type); + BT_OBJECT_PUT_REF_AND_RESET(entry_type); if (ret) { BT_LOGE_STR("Failed to find clock fields."); goto error; @@ -255,7 +255,7 @@ int find_update_array_clock_fields(FILE *err, struct bt_field_type *type, BT_ASSERT(entry_type); ret = find_update_clock_fields(err, entry_type, writer_clock_class); - BT_PUT(entry_type); + BT_OBJECT_PUT_REF_AND_RESET(entry_type); if (ret) { BT_LOGE_STR("Failed to find clock fields."); ret = -1; @@ -277,7 +277,7 @@ int find_update_enum_clock_fields(FILE *err, struct bt_field_type *type, BT_ASSERT(entry_type); ret = find_update_clock_fields(err, entry_type, writer_clock_class); - BT_PUT(entry_type); + BT_OBJECT_PUT_REF_AND_RESET(entry_type); if (ret) { BT_LOGE_STR("Failed to find clock fields."); goto error; @@ -322,13 +322,13 @@ struct bt_field_type *override_header_type(FILE *err, BT_LOGE_STR("Failed to find clock fields in struct."); goto error; } - BT_PUT(writer_clock_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class); goto end; error: - bt_put(writer_clock_class); - BT_PUT(new_type); + bt_object_put_ref(writer_clock_class); + BT_OBJECT_PUT_REF_AND_RESET(new_type); end: return new_type; } @@ -441,7 +441,7 @@ int copy_override_field(FILE *err, struct bt_event *event, break; } - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); return ret; } @@ -474,8 +474,8 @@ int copy_find_clock_enum_field(FILE *err, struct bt_event *event, error: ret = -1; end: - bt_put(copy_container); - bt_put(container); + bt_object_put_ref(copy_container); + bt_object_put_ref(container); return ret; } @@ -513,9 +513,9 @@ int copy_find_clock_variant_field(FILE *err, struct bt_event *event, error: ret = -1; end: - bt_put(copy_variant_field); - bt_put(variant_field); - bt_put(tag); + bt_object_put_ref(copy_variant_field); + bt_object_put_ref(variant_field); + bt_object_put_ref(tag); return ret; } @@ -544,7 +544,7 @@ int copy_find_clock_sequence_field(FILE *err, BT_LOGE_STR("Failed to set sequence length."); goto error; } - BT_PUT(length_field); + BT_OBJECT_PUT_REF_AND_RESET(length_field); for (i = 0; i < count; i++) { entry_field = bt_field_sequence_get_field(field, i); @@ -562,17 +562,17 @@ int copy_find_clock_sequence_field(FILE *err, BT_LOGE_STR("Faield to override field in sequence."); goto error; } - BT_PUT(entry_field); - BT_PUT(entry_copy); + BT_OBJECT_PUT_REF_AND_RESET(entry_field); + BT_OBJECT_PUT_REF_AND_RESET(entry_copy); } ret = 0; goto end; error: - bt_put(length_field); - bt_put(entry_field); - bt_put(entry_copy); + bt_object_put_ref(length_field); + bt_object_put_ref(entry_field); + bt_object_put_ref(entry_copy); ret = -1; end: return ret; @@ -606,16 +606,16 @@ int copy_find_clock_array_field(FILE *err, BT_LOGE_STR("Failed to override field in array."); goto error; } - BT_PUT(entry_field); - BT_PUT(entry_copy); + BT_OBJECT_PUT_REF_AND_RESET(entry_field); + BT_OBJECT_PUT_REF_AND_RESET(entry_copy); } ret = 0; goto end; error: - bt_put(entry_field); - bt_put(entry_copy); + bt_object_put_ref(entry_field); + bt_object_put_ref(entry_copy); end: return ret; @@ -657,18 +657,18 @@ int copy_find_clock_struct_field(FILE *err, BT_LOGE_STR("Failed to override field in struct."); goto error; } - BT_PUT(entry_copy); - BT_PUT(entry_field); - BT_PUT(entry_type); + BT_OBJECT_PUT_REF_AND_RESET(entry_copy); + BT_OBJECT_PUT_REF_AND_RESET(entry_field); + BT_OBJECT_PUT_REF_AND_RESET(entry_type); } ret = 0; goto end; error: - bt_put(entry_type); - bt_put(entry_field); - bt_put(entry_copy); + bt_object_put_ref(entry_type); + bt_object_put_ref(entry_field); + bt_object_put_ref(entry_copy); ret = -1; end: return ret; @@ -732,7 +732,7 @@ 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_put(trace); + bt_object_put_ref(trace); return clock_class; } @@ -747,11 +747,11 @@ struct bt_clock_class *event_get_clock_class(FILE *err, struct bt_event *event) BT_ASSERT(event_class); stream_class = bt_event_class_get_stream_class(event_class); - BT_PUT(event_class); + BT_OBJECT_PUT_REF_AND_RESET(event_class); BT_ASSERT(stream_class); clock_class = stream_class_get_clock_class(err, stream_class); - bt_put(stream_class); + bt_object_put_ref(stream_class); return clock_class; } @@ -773,11 +773,11 @@ int copy_find_clock_int_field(FILE *err, } clock_value = bt_event_get_clock_value(event, clock_class); - BT_PUT(clock_class); + BT_OBJECT_PUT_REF_AND_RESET(clock_class); BT_ASSERT(clock_value); ret = bt_clock_value_get_value(clock_value, &value); - BT_PUT(clock_value); + BT_OBJECT_PUT_REF_AND_RESET(clock_value); if (ret) { BT_LOGE("Failed to get clock value."); goto error; @@ -793,14 +793,14 @@ int copy_find_clock_int_field(FILE *err, BT_ASSERT(writer_clock_class); writer_clock_value = bt_clock_value_create(writer_clock_class, value); - BT_PUT(writer_clock_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class); if (!writer_clock_value) { BT_LOGE_STR("Failed to create clock value."); goto error; } ret = bt_event_set_clock_value(writer_event, writer_clock_value); - BT_PUT(writer_clock_value); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_value); if (ret) { BT_LOGE_STR("Failed to set clock value."); goto error; diff --git a/plugins/libctfcopytrace/ctfcopytrace.c b/plugins/libctfcopytrace/ctfcopytrace.c index 9e8e16cd..145770f5 100644 --- a/plugins/libctfcopytrace/ctfcopytrace.c +++ b/plugins/libctfcopytrace/ctfcopytrace.c @@ -112,7 +112,7 @@ enum bt_component_status ctf_copy_clock_classes(FILE *err, BT_ASSERT(clock_class); writer_clock_class = ctf_copy_clock_class(err, clock_class); - bt_put(clock_class); + bt_object_put_ref(clock_class); if (!writer_clock_class) { BT_LOGE_STR("Failed to copy clock class."); ret = BT_COMPONENT_STATUS_ERROR; @@ -121,7 +121,7 @@ enum bt_component_status ctf_copy_clock_classes(FILE *err, int_ret = bt_trace_add_clock_class(writer_trace, writer_clock_class); if (int_ret != 0) { - BT_PUT(writer_clock_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class); BT_LOGE_STR("Failed to add clock class."); ret = BT_COMPONENT_STATUS_ERROR; goto end; @@ -130,7 +130,7 @@ enum bt_component_status ctf_copy_clock_classes(FILE *err, /* * Ownership transferred to the trace. */ - bt_put(writer_clock_class); + bt_object_put_ref(writer_clock_class); } ret = BT_COMPONENT_STATUS_OK; @@ -168,8 +168,8 @@ void replace_clock_classes(struct bt_trace *trace_copy, ret = bt_field_type_integer_set_mapped_clock_class( field_type, clock_class_copy); BT_ASSERT(ret == 0); - bt_put(mapped_clock_class); - bt_put(clock_class_copy); + bt_object_put_ref(mapped_clock_class); + bt_object_put_ref(clock_class_copy); break; } case BT_FIELD_TYPE_ID_ENUM: @@ -199,7 +199,7 @@ void replace_clock_classes(struct bt_trace *trace_copy, BT_ASSERT(subtype); replace_clock_classes(trace_copy, subtype); - bt_put(subtype); + bt_object_put_ref(subtype); break; } case BT_FIELD_TYPE_ID_STRUCT: @@ -216,7 +216,7 @@ void replace_clock_classes(struct bt_trace *trace_copy, field_type, &name, &member_type, i); BT_ASSERT(ret == 0); replace_clock_classes(trace_copy, member_type); - bt_put(member_type); + bt_object_put_ref(member_type); } break; @@ -235,7 +235,7 @@ void replace_clock_classes(struct bt_trace *trace_copy, field_type, &name, &member_type, i); BT_ASSERT(ret == 0); replace_clock_classes(trace_copy, member_type); - bt_put(member_type); + bt_object_put_ref(member_type); } break; @@ -306,7 +306,7 @@ struct bt_event_class *ctf_copy_event_class(FILE *err, replace_clock_classes(trace_copy, ft_copy); ret = bt_event_class_set_payload_type(writer_event_class, ft_copy); - bt_put(ft_copy); + bt_object_put_ref(ft_copy); if (ret < 0) { BT_LOGE_STR("Failed to set payload type."); goto error; @@ -324,7 +324,7 @@ struct bt_event_class *ctf_copy_event_class(FILE *err, ret = bt_event_class_set_context_type( writer_event_class, ft_copy); - bt_put(ft_copy); + bt_object_put_ref(ft_copy); if (ret < 0) { BT_LOGE_STR("Failed to set context type."); goto error; @@ -334,10 +334,10 @@ struct bt_event_class *ctf_copy_event_class(FILE *err, goto end; error: - BT_PUT(writer_event_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_event_class); end: - BT_PUT(context); - BT_PUT(payload_type); + BT_OBJECT_PUT_REF_AND_RESET(context); + BT_OBJECT_PUT_REF_AND_RESET(payload_type); return writer_event_class; } @@ -373,8 +373,8 @@ enum bt_component_status ctf_copy_event_classes(FILE *err, * event_classes after a trace has become * static. */ - BT_PUT(writer_event_class); - BT_PUT(event_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_event_class); + BT_OBJECT_PUT_REF_AND_RESET(event_class); continue; } } @@ -394,17 +394,17 @@ enum bt_component_status ctf_copy_event_classes(FILE *err, ret = BT_COMPONENT_STATUS_ERROR; goto error; } - BT_PUT(writer_event_class); - BT_PUT(event_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_event_class); + BT_OBJECT_PUT_REF_AND_RESET(event_class); } goto end; error: - bt_put(event_class); - bt_put(writer_event_class); + bt_object_put_ref(event_class); + bt_object_put_ref(writer_event_class); end: - bt_put(writer_trace); + bt_object_put_ref(writer_trace); return ret; } @@ -433,12 +433,12 @@ struct bt_stream_class *ctf_copy_stream_class(FILE *err, replace_clock_classes(writer_trace, type_copy); ret_int = bt_stream_class_set_packet_context_type( writer_stream_class, type_copy); - BT_PUT(type_copy); + BT_OBJECT_PUT_REF_AND_RESET(type_copy); if (ret_int < 0) { BT_LOGE_STR("Failed to set packet_context type."); goto error; } - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); } type = bt_stream_class_get_event_header_type(stream_class); @@ -462,8 +462,8 @@ struct bt_stream_class *ctf_copy_stream_class(FILE *err, replace_clock_classes(writer_trace, type_copy); ret_int = bt_stream_class_set_event_header_type( writer_stream_class, new_event_header_type); - BT_PUT(type_copy); - BT_PUT(new_event_header_type); + BT_OBJECT_PUT_REF_AND_RESET(type_copy); + BT_OBJECT_PUT_REF_AND_RESET(new_event_header_type); if (ret_int < 0) { BT_LOGE_STR("Failed to set event_header type."); goto error; @@ -472,13 +472,13 @@ struct bt_stream_class *ctf_copy_stream_class(FILE *err, replace_clock_classes(writer_trace, type_copy); ret_int = bt_stream_class_set_event_header_type( writer_stream_class, type_copy); - BT_PUT(type_copy); + BT_OBJECT_PUT_REF_AND_RESET(type_copy); if (ret_int < 0) { BT_LOGE_STR("Failed to set event_header type."); goto error; } } - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); } type = bt_stream_class_get_event_context_type(stream_class); @@ -491,21 +491,21 @@ struct bt_stream_class *ctf_copy_stream_class(FILE *err, replace_clock_classes(writer_trace, type_copy); ret_int = bt_stream_class_set_event_context_type( writer_stream_class, type_copy); - BT_PUT(type_copy); + BT_OBJECT_PUT_REF_AND_RESET(type_copy); if (ret_int < 0) { BT_LOGE_STR("Failed to set event_contexttype."); goto error; } } - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); goto end; error: - BT_PUT(writer_stream_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); end: - bt_put(type); - bt_put(type_copy); + bt_object_put_ref(type); + bt_object_put_ref(type_copy); return writer_stream_class; } @@ -539,8 +539,8 @@ int ctf_stream_copy_packet_header(FILE *err, struct bt_packet *packet, error: ret = -1; end: - bt_put(writer_packet_header); - bt_put(packet_header); + bt_object_put_ref(writer_packet_header); + bt_object_put_ref(packet_header); return ret; } @@ -573,8 +573,8 @@ int ctf_packet_copy_header(FILE *err, struct bt_packet *packet, error: ret = -1; end: - bt_put(packet_header); - bt_put(writer_packet_header); + bt_object_put_ref(packet_header); + bt_object_put_ref(writer_packet_header); return ret; } @@ -608,8 +608,8 @@ int ctf_stream_copy_packet_context(FILE *err, struct bt_packet *packet, error: ret = -1; end: - bt_put(packet_context); - bt_put(writer_packet_context); + bt_object_put_ref(packet_context); + bt_object_put_ref(writer_packet_context); return ret; } @@ -643,8 +643,8 @@ int ctf_packet_copy_context(FILE *err, struct bt_packet *packet, error: ret = -1; end: - bt_put(writer_packet_context); - bt_put(packet_context); + bt_object_put_ref(writer_packet_context); + bt_object_put_ref(packet_context); return ret; } @@ -668,11 +668,11 @@ int ctf_copy_event_header(FILE *err, struct bt_event *event, } clock_value = bt_event_get_clock_value(event, clock_class); - BT_PUT(clock_class); + BT_OBJECT_PUT_REF_AND_RESET(clock_class); BT_ASSERT(clock_value); ret = bt_clock_value_get_value(clock_value, &value); - BT_PUT(clock_value); + BT_OBJECT_PUT_REF_AND_RESET(clock_value); if (ret) { BT_LOGE_STR("Failed to get clock value."); goto error; @@ -685,14 +685,14 @@ int ctf_copy_event_header(FILE *err, struct bt_event *event, } writer_clock_value = bt_clock_value_create(writer_clock_class, value); - BT_PUT(writer_clock_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class); if (!writer_clock_value) { BT_LOGE_STR("Failed to create clock value."); goto error; } ret = bt_event_set_clock_value(writer_event, writer_clock_value); - BT_PUT(writer_clock_value); + BT_OBJECT_PUT_REF_AND_RESET(writer_clock_value); if (ret) { BT_LOGE_STR("Failed to set clock value."); goto error; @@ -705,7 +705,7 @@ int ctf_copy_event_header(FILE *err, struct bt_event *event, } ret = bt_event_set_header(writer_event, writer_event_header); - BT_PUT(writer_event_header); + BT_OBJECT_PUT_REF_AND_RESET(writer_event_header); if (ret < 0) { BT_LOGE_STR("Failed to set event_header."); goto error; @@ -734,7 +734,7 @@ struct bt_trace *event_class_get_trace(FILE *err, trace = bt_stream_class_get_trace(stream_class); BT_ASSERT(trace); - bt_put(stream_class); + bt_object_put_ref(stream_class); return trace; } @@ -780,7 +780,7 @@ struct bt_event *ctf_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to copy and override field."); goto error; } - BT_PUT(copy_field); + BT_OBJECT_PUT_REF_AND_RESET(copy_field); } else { ret = ctf_copy_event_header(err, event, writer_event_class, writer_event, field); @@ -789,7 +789,7 @@ struct bt_event *ctf_copy_event(FILE *err, struct bt_event *event, goto error; } } - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); } /* Optional field, so it can fail silently. */ @@ -806,8 +806,8 @@ struct bt_event *ctf_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to set stream_event_context."); goto error; } - BT_PUT(field); - BT_PUT(copy_field); + BT_OBJECT_PUT_REF_AND_RESET(field); + BT_OBJECT_PUT_REF_AND_RESET(copy_field); } /* Optional field, so it can fail silently. */ @@ -823,8 +823,8 @@ struct bt_event *ctf_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to set event_context."); goto error; } - BT_PUT(field); - BT_PUT(copy_field); + BT_OBJECT_PUT_REF_AND_RESET(field); + BT_OBJECT_PUT_REF_AND_RESET(copy_field); } field = bt_event_get_event_payload(event); @@ -839,18 +839,18 @@ struct bt_event *ctf_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to set event_payload."); goto error; } - BT_PUT(field); - BT_PUT(copy_field); + BT_OBJECT_PUT_REF_AND_RESET(field); + BT_OBJECT_PUT_REF_AND_RESET(copy_field); } goto end; error: - BT_PUT(writer_event); + BT_OBJECT_PUT_REF_AND_RESET(writer_event); end: - bt_put(field); - bt_put(copy_field); - bt_put(writer_trace); + bt_object_put_ref(field); + bt_object_put_ref(copy_field); + bt_object_put_ref(writer_trace); return writer_event; } @@ -881,7 +881,7 @@ enum bt_component_status ctf_copy_trace(FILE *err, struct bt_trace *trace, ret_int = bt_trace_set_environment_field(writer_trace, name, value); - BT_PUT(value); + BT_OBJECT_PUT_REF_AND_RESET(value); if (ret_int < 0) { BT_LOGE("Failed to set environment: field-name=\"%s\"", name); @@ -911,7 +911,7 @@ enum bt_component_status ctf_copy_trace(FILE *err, struct bt_trace *trace, header_type = bt_trace_get_packet_header_type(trace); if (header_type) { int_ret = bt_trace_set_packet_header_type(writer_trace, header_type); - BT_PUT(header_type); + BT_OBJECT_PUT_REF_AND_RESET(header_type); if (int_ret < 0) { BT_LOGE_STR("Failed to set packet header type."); ret = BT_COMPONENT_STATUS_ERROR; diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index 0d855075..80179700 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -45,19 +45,19 @@ struct bt_stream *insert_new_stream( static void unref_stream(struct bt_stream *stream) { - bt_put(stream); + bt_object_put_ref(stream); } static void unref_packet(struct bt_packet *packet) { - bt_put(packet); + bt_object_put_ref(packet); } static void unref_stream_class(struct bt_stream_class *stream_class) { - bt_put(stream_class); + bt_object_put_ref(stream_class); } static @@ -94,8 +94,8 @@ struct bt_field *get_payload_field(FILE *err, field = bt_field_structure_get_field_by_name(payload, field_name); end: - bt_put(payload_class); - bt_put(payload); + bt_object_put_ref(payload_class); + bt_object_put_ref(payload); return field; } @@ -123,8 +123,8 @@ struct bt_field *get_stream_event_context_field(FILE *err, field = bt_field_structure_get_field_by_name(sec, field_name); end: - bt_put(sec_class); - bt_put(sec); + bt_object_put_ref(sec_class); + bt_object_put_ref(sec); return field; } @@ -168,8 +168,8 @@ int get_stream_event_context_unsigned_int_field_value(FILE *err, error: ret = -1; end: - bt_put(field_class); - bt_put(field); + bt_object_put_ref(field_class); + bt_object_put_ref(field); return ret; } @@ -206,8 +206,8 @@ int get_stream_event_context_int_field_value(FILE *err, struct bt_event *event, error: ret = -1; end: - bt_put(field_class); - bt_put(field); + bt_object_put_ref(field_class); + bt_object_put_ref(field); return ret; } @@ -252,8 +252,8 @@ int get_payload_unsigned_int_field_value(FILE *err, error: ret = -1; end: - bt_put(field_class); - bt_put(field); + bt_object_put_ref(field_class); + bt_object_put_ref(field); return ret; } @@ -296,8 +296,8 @@ int get_payload_int_field_value(FILE *err, struct bt_event *event, error: ret = -1; end: - bt_put(field_class); - bt_put(field); + bt_object_put_ref(field_class); + bt_object_put_ref(field); return ret; } @@ -340,8 +340,8 @@ int get_payload_string_field_value(FILE *err, error: ret = -1; end: - bt_put(field_class); - bt_put(field); + bt_object_put_ref(field_class); + bt_object_put_ref(field); return 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_PUT(field_class); + BT_OBJECT_PUT_REF_AND_RESET(field_class); seq_len = bt_field_sequence_get_length(field); BT_ASSERT(seq_len); @@ -382,7 +382,7 @@ int get_payload_build_id_field_value(FILE *err, field_name); goto error; } - BT_PUT(seq_len); + BT_OBJECT_PUT_REF_AND_RESET(seq_len); *build_id = g_new0(uint8_t, *build_id_len); if (!*build_id) { @@ -407,7 +407,7 @@ int get_payload_build_id_field_value(FILE *err, goto error; } - BT_PUT(seq_field); + BT_OBJECT_PUT_REF_AND_RESET(seq_field); (*build_id)[i] = (uint8_t) tmp; } ret = 0; @@ -417,8 +417,8 @@ error: g_free(*build_id); ret = -1; end: - bt_put(field_class); - bt_put(field); + bt_object_put_ref(field_class); + bt_object_put_ref(field); return ret; } @@ -455,7 +455,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it, if (strcmp(str_value, "ust") != 0) { goto end; } - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); /* No tracer_name, no debug info */ field = bt_trace_get_environment_field_value_by_name(writer_trace, @@ -471,7 +471,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it, if (strcmp(str_value, "lttng-ust") != 0) { goto end; } - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); debug_info = debug_info_create(debug_it->debug_info_component); if (!debug_info) { @@ -483,7 +483,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it, debug_info); end: - bt_put(field); + bt_object_put_ref(field); return debug_info; } @@ -615,8 +615,8 @@ int sync_event_classes(struct debug_info_iterator *debug_it, error: int_ret = -1; end: - bt_put(stream_class); - bt_put(writer_stream_class); + bt_object_put_ref(stream_class); + bt_object_put_ref(writer_stream_class); return int_ret; } @@ -646,8 +646,8 @@ void trace_is_static_listener(struct bt_trace *trace, void *data) BT_LOGE_STR("Failed to synchronize the event classes."); goto error; } - BT_PUT(stream); - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); } bt_trace_set_is_static(di_trace->writer_trace); @@ -662,8 +662,8 @@ void trace_is_static_listener(struct bt_trace *trace, void *data) } error: - bt_put(writer_stream); - bt_put(stream); + bt_object_put_ref(writer_stream); + bt_object_put_ref(stream); } static @@ -728,14 +728,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_get(writer_stream); + bt_object_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_PUT(writer_stream); - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); } /* Check if the trace is already static or register a listener. */ @@ -754,14 +754,14 @@ struct debug_info_trace *insert_new_trace(struct debug_info_iterator *debug_it, goto end; error: - BT_PUT(writer_trace); + BT_OBJECT_PUT_REF_AND_RESET(writer_trace); g_free(di_trace); di_trace = NULL; end: - bt_put(stream); - bt_put(writer_stream); - bt_put(stream_class); - bt_put(trace); + bt_object_put_ref(stream); + bt_object_put_ref(writer_stream); + bt_object_put_ref(stream_class); + bt_object_put_ref(trace); return di_trace; } @@ -801,7 +801,7 @@ struct bt_packet *insert_new_packet(struct debug_info_iterator *debug_it, goto end; error: - BT_PUT(writer_packet); + BT_OBJECT_PUT_REF_AND_RESET(writer_packet); end: return writer_packet; } @@ -822,7 +822,7 @@ int add_debug_info_fields(FILE *err, if (!ip_field) { goto end; } - BT_PUT(ip_field); + BT_OBJECT_PUT_REF_AND_RESET(ip_field); debug_field_class = bt_field_class_structure_get_field_class_by_name( writer_event_context_class, @@ -888,13 +888,13 @@ int add_debug_info_fields(FILE *err, goto end; error: - BT_PUT(debug_field_class); + BT_OBJECT_PUT_REF_AND_RESET(debug_field_class); ret = -1; end: - bt_put(src_field_class); - bt_put(func_field_class); - bt_put(bin_field_class); - bt_put(debug_field_class); + 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); return ret; } @@ -920,7 +920,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_PUT(field_class); + BT_OBJECT_PUT_REF_AND_RESET(field_class); if (ret) { BT_LOGE("Failed to add a field to the event-context: field-name=\"%s\"", field_name); @@ -964,7 +964,7 @@ struct bt_stream_class *copy_stream_class_debug_info(FILE *err, BT_LOGE_STR("Failed to set packet_context type."); goto error; } - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); } type = bt_stream_class_get_event_header_type(stream_class); @@ -975,7 +975,7 @@ struct bt_stream_class *copy_stream_class_debug_info(FILE *err, BT_LOGE_STR("Failed to set event_header type."); goto error; } - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); } type = bt_stream_class_get_event_context_class(stream_class); @@ -991,7 +991,7 @@ struct bt_stream_class *copy_stream_class_debug_info(FILE *err, BT_LOGE_STR("Failed to create debug_info event_context type."); goto error; } - BT_PUT(type); + BT_OBJECT_PUT_REF_AND_RESET(type); ret_int = bt_stream_class_set_event_context_class( writer_stream_class, writer_event_context_class); @@ -999,16 +999,16 @@ struct bt_stream_class *copy_stream_class_debug_info(FILE *err, BT_LOGE_STR("Failed to set event_context type."); goto error; } - BT_PUT(writer_event_context_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_event_context_class); } goto end; error: - BT_PUT(writer_stream_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); end: - bt_put(writer_event_context_class); - bt_put(type); + bt_object_put_ref(writer_event_context_class); + bt_object_put_ref(type); return writer_stream_class; } @@ -1035,14 +1035,14 @@ int add_clock_classes(FILE *err, struct bt_trace *writer_trace, existing_clock_class = bt_trace_get_clock_class_by_name( writer_trace, bt_clock_class_get_name(clock_class)); - bt_put(existing_clock_class); + bt_object_put_ref(existing_clock_class); if (existing_clock_class) { - bt_put(clock_class); + bt_object_put_ref(clock_class); continue; } ret = bt_trace_add_clock_class(writer_trace, clock_class); - BT_PUT(clock_class); + BT_OBJECT_PUT_REF_AND_RESET(clock_class); if (ret != 0) { BT_LOGE_STR("Failed to add clock_class."); goto error; @@ -1080,7 +1080,7 @@ struct bt_stream_class *insert_new_stream_class( goto error; } writer_trace = di_trace->writer_trace; - bt_get(writer_trace); + bt_object_get_ref(writer_trace); writer_stream_class = copy_stream_class_debug_info(debug_it->err, stream_class, writer_trace, debug_it->debug_info_component); @@ -1108,10 +1108,10 @@ struct bt_stream_class *insert_new_stream_class( goto end; error: - BT_PUT(writer_stream_class); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); end: - bt_put(trace); - bt_put(writer_trace); + bt_object_put_ref(trace); + bt_object_put_ref(writer_trace); return writer_stream_class; } @@ -1141,7 +1141,7 @@ struct bt_stream *insert_new_stream( goto error; } } - bt_get(writer_stream_class); + bt_object_get_ref(writer_stream_class); id = bt_stream_get_id(stream); if (id < 0) { @@ -1164,10 +1164,10 @@ struct bt_stream *insert_new_stream( goto end; error: - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); end: - bt_put(stream_class); - bt_put(writer_stream_class); + bt_object_put_ref(stream_class); + bt_object_put_ref(writer_stream_class); return writer_stream; } @@ -1207,8 +1207,8 @@ 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_PUT(stream_class); - BT_PUT(trace); + BT_OBJECT_PUT_REF_AND_RESET(stream_class); + BT_OBJECT_PUT_REF_AND_RESET(trace); return di_trace; } @@ -1235,14 +1235,14 @@ struct bt_stream *get_writer_stream( BT_LOGE_STR("Failed to find existing stream."); goto error; } - bt_get(writer_stream); + bt_object_get_ref(writer_stream); goto end; error: - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); end: - bt_put(stream_class); + bt_object_put_ref(stream_class); return writer_stream; } @@ -1279,7 +1279,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_PUT(writer_packet); + BT_OBJECT_PUT_REF_AND_RESET(writer_packet); } writer_packet = insert_new_packet(debug_it, packet, writer_stream, @@ -1297,18 +1297,18 @@ struct bt_packet *debug_info_new_packet( BT_LOGE_STR("Failed to copy packet context."); goto error; } - BT_PUT(packet_context); + BT_OBJECT_PUT_REF_AND_RESET(packet_context); } - bt_get(writer_packet); + bt_object_get_ref(writer_packet); goto end; error: end: - bt_put(packet_context); - bt_put(writer_stream); - bt_put(stream); + bt_object_put_ref(packet_context); + bt_object_put_ref(writer_stream); + bt_object_put_ref(stream); return writer_packet; } @@ -1335,11 +1335,11 @@ struct bt_packet *debug_info_close_packet( BT_LOGE_STR("Failed to find existing packet."); goto end; } - bt_get(writer_packet); + bt_object_get_ref(writer_packet); g_hash_table_remove(di_trace->packet_map, packet); end: - bt_put(stream); + bt_object_put_ref(stream); return writer_packet; } @@ -1385,12 +1385,12 @@ struct bt_stream *debug_info_stream_begin( if (!writer_stream) { writer_stream = insert_new_stream(debug_it, stream, di_trace); } - bt_get(writer_stream); + bt_object_get_ref(writer_stream); goto end; error: - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); end: return writer_stream; } @@ -1418,7 +1418,7 @@ struct bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_it, * Take the ref on the stream and keep it until the notification * is created. */ - bt_get(writer_stream); + bt_object_get_ref(writer_stream); state = g_hash_table_lookup(di_trace->stream_states, stream); if (*state != DEBUG_INFO_ACTIVE_STREAM) { @@ -1444,7 +1444,7 @@ struct bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_it, goto end; error: - BT_PUT(writer_stream); + BT_OBJECT_PUT_REF_AND_RESET(writer_stream); end: return writer_stream; @@ -1502,7 +1502,7 @@ int set_debug_info_field(FILE *err, struct bt_field *debug_field, field_name); goto error; } - BT_PUT(field_class); + BT_OBJECT_PUT_REF_AND_RESET(field_class); field = bt_field_structure_get_field_by_index(debug_field, i); if (!strcmp(field_name, "bin")) { @@ -1549,7 +1549,7 @@ int set_debug_info_field(FILE *err, struct bt_field *debug_field, ret = bt_field_string_set_value(field, ""); } } - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); if (ret) { BT_LOGE("Failed to set value in debug-info struct: field-name=\"%s\"", field_name); @@ -1562,9 +1562,9 @@ int set_debug_info_field(FILE *err, struct bt_field *debug_field, error: ret = -1; end: - bt_put(field_class); - bt_put(field); - bt_put(debug_field_class); + bt_object_put_ref(field_class); + bt_object_put_ref(field); + bt_object_put_ref(debug_field_class); return ret; } @@ -1637,7 +1637,7 @@ int copy_set_debug_info_stream_event_context(FILE *err, BT_LOGE_STR("Failed to set debug_info field."); goto error; } - BT_PUT(debug_field); + BT_OBJECT_PUT_REF_AND_RESET(debug_field); } else { copy_field = bt_field_copy(field); if (!copy_field) { @@ -1654,10 +1654,10 @@ int copy_set_debug_info_stream_event_context(FILE *err, field_name); goto error; } - BT_PUT(copy_field); + BT_OBJECT_PUT_REF_AND_RESET(copy_field); } - BT_PUT(field_class); - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field_class); + BT_OBJECT_PUT_REF_AND_RESET(field); } ret = 0; @@ -1666,13 +1666,13 @@ int copy_set_debug_info_stream_event_context(FILE *err, error: ret = -1; end: - bt_put(event_context_class); - bt_put(writer_event_context_class); - bt_put(writer_event_context); - bt_put(field); - bt_put(copy_field); - bt_put(debug_field); - bt_put(field_class); + bt_object_put_ref(event_context_class); + bt_object_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); return ret; } @@ -1694,7 +1694,7 @@ 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_put(trace); + bt_object_put_ref(trace); end: return clock_class; @@ -1717,8 +1717,8 @@ struct bt_clock_class *event_get_clock_class(FILE *err, struct bt_event *event) goto end; end: - bt_put(stream_class); - bt_put(event_class); + bt_object_put_ref(stream_class); + bt_object_put_ref(event_class); return clock_class; } @@ -1758,8 +1758,8 @@ int set_event_clock_value(FILE *err, struct bt_event *event, error: ret = -1; end: - bt_put(clock_class); - bt_put(clock_value); + bt_object_put_ref(clock_class); + bt_object_put_ref(clock_value); return ret; } @@ -1794,7 +1794,7 @@ struct bt_event *debug_info_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to copy event header."); goto error; } - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); } /* Optional field, so it can fail silently. */ @@ -1807,7 +1807,7 @@ struct bt_event *debug_info_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to debug_info stream event context."); goto error; } - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); } /* Optional field, so it can fail silently. */ @@ -1823,8 +1823,8 @@ struct bt_event *debug_info_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to set event_context."); goto error; } - BT_PUT(copy_field); - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(copy_field); + BT_OBJECT_PUT_REF_AND_RESET(field); } field = bt_event_get_event_payload(event); @@ -1837,17 +1837,17 @@ struct bt_event *debug_info_copy_event(FILE *err, struct bt_event *event, BT_LOGE_STR("Failed to set event payload."); goto error; } - BT_PUT(copy_field); + BT_OBJECT_PUT_REF_AND_RESET(copy_field); } - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); goto end; error: - BT_PUT(writer_event); + BT_OBJECT_PUT_REF_AND_RESET(writer_event); end: - bt_put(copy_field); - bt_put(field); + bt_object_put_ref(copy_field); + bt_object_put_ref(field); return writer_event; } @@ -1888,7 +1888,7 @@ struct bt_event *debug_info_output_event( BT_LOGE_STR("Failed to find existing stream_class."); goto error; } - bt_get(writer_stream_class); + bt_object_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, @@ -1930,7 +1930,7 @@ struct bt_event *debug_info_output_event( BT_LOGE_STR("Failed to find existing packet."); goto error; } - bt_get(writer_packet); + bt_object_get_ref(writer_packet); int_ret = bt_event_set_packet(writer_event, writer_packet); if (int_ret < 0) { @@ -1943,16 +1943,16 @@ struct bt_event *debug_info_output_event( goto end; error: - BT_PUT(writer_event); + BT_OBJECT_PUT_REF_AND_RESET(writer_event); end: - bt_put(stream); - bt_put(writer_trace); - bt_put(writer_packet); - bt_put(packet); - bt_put(writer_event_class); - bt_put(writer_stream_class); - bt_put(stream_class); - bt_put(event_class); + 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); return writer_event; } diff --git a/plugins/lttng-utils/debug-info.c b/plugins/lttng-utils/debug-info.c index ffe22816..a455e47c 100644 --- a/plugins/lttng-utils/debug-info.c +++ b/plugins/lttng-utils/debug-info.c @@ -741,7 +741,7 @@ void debug_info_handle_event(FILE *err, struct bt_event *event, } end_put_class: - bt_put(event_class); + bt_object_put_ref(event_class); end: return; } diff --git a/plugins/lttng-utils/plugin.c b/plugins/lttng-utils/plugin.c index 0646f49a..fbbdc664 100644 --- a/plugins/lttng-utils/plugin.c +++ b/plugins/lttng-utils/plugin.c @@ -78,7 +78,7 @@ end: static void unref_trace(struct debug_info_trace *di_trace) { - bt_put(di_trace->writer_trace); + bt_object_put_ref(di_trace->writer_trace); g_free(di_trace); } @@ -98,8 +98,8 @@ void debug_info_iterator_destroy(struct bt_private_connection_private_notificati empty_trace_map, it_data); g_hash_table_destroy(it_data->trace_map); - bt_put(it_data->current_notification); - bt_put(it_data->input_iterator); + bt_object_put_ref(it_data->current_notification); + bt_object_put_ref(it_data->input_iterator); g_free(it_data); } @@ -127,8 +127,8 @@ struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_packet_begin_create( writer_packet); BT_ASSERT(new_notification); - bt_put(packet); - bt_put(writer_packet); + bt_object_put_ref(packet); + bt_object_put_ref(writer_packet); break; } case BT_NOTIFICATION_TYPE_PACKET_END: @@ -146,8 +146,8 @@ struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_packet_end_create( writer_packet); BT_ASSERT(new_notification); - bt_put(packet); - bt_put(writer_packet); + bt_object_put_ref(packet); + bt_object_put_ref(writer_packet); break; } case BT_NOTIFICATION_TYPE_EVENT: @@ -166,10 +166,10 @@ struct bt_notification *handle_notification(FILE *err, BT_ASSERT(writer_event); new_notification = bt_notification_event_create(writer_event, cc_prio_map); - bt_put(cc_prio_map); + bt_object_put_ref(cc_prio_map); BT_ASSERT(new_notification); - bt_put(event); - bt_put(writer_event); + bt_object_put_ref(event); + bt_object_put_ref(writer_event); break; } case BT_NOTIFICATION_TYPE_STREAM_BEGIN: @@ -187,8 +187,8 @@ struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_stream_begin_create( writer_stream); BT_ASSERT(new_notification); - bt_put(stream); - bt_put(writer_stream); + bt_object_put_ref(stream); + bt_object_put_ref(writer_stream); break; } case BT_NOTIFICATION_TYPE_STREAM_END: @@ -206,12 +206,12 @@ struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_stream_end_create( writer_stream); BT_ASSERT(new_notification); - bt_put(stream); - bt_put(writer_stream); + bt_object_put_ref(stream); + bt_object_put_ref(writer_stream); break; } default: - new_notification = bt_get(notification); + new_notification = bt_object_get_ref(notification); break; } @@ -258,10 +258,10 @@ struct bt_notification_iterator_next_method_return debug_info_iterator_next( ret.notification = handle_notification(debug_info->err, debug_it, notification); BT_ASSERT(ret.notification); - bt_put(notification); + bt_object_put_ref(notification); end: - bt_put(component); + bt_object_put_ref(component); return ret; } @@ -293,7 +293,7 @@ enum bt_notification_iterator_status debug_info_iterator_init( } connection = bt_private_port_get_private_connection(input_port); - bt_put(input_port); + bt_object_put_ref(input_port); if (!connection) { ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; goto end; @@ -318,8 +318,8 @@ enum bt_notification_iterator_status debug_info_iterator_init( } end: - bt_put(connection); - bt_put(component); + bt_object_put_ref(connection); + bt_object_put_ref(component); return ret; } @@ -345,7 +345,7 @@ enum bt_component_status init_from_params( "Expecting a string."); } strcpy(debug_info_component->arg_debug_info_field_name, tmp); - bt_put(value); + bt_object_put_ref(value); } else { debug_info_component->arg_debug_info_field_name = malloc(strlen("debug_info") + 1); @@ -373,7 +373,7 @@ enum bt_component_status init_from_params( "Expecting a string."); } } - bt_put(value); + bt_object_put_ref(value); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } @@ -390,7 +390,7 @@ enum bt_component_status init_from_params( "Expecting a string."); } } - bt_put(value); + bt_object_put_ref(value); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } @@ -410,7 +410,7 @@ enum bt_component_status init_from_params( debug_info_component->arg_full_path = bool_val; } - bt_put(value); + bt_object_put_ref(value); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } diff --git a/plugins/text/dmesg/dmesg.c b/plugins/text/dmesg/dmesg.c index 90527c9d..b34c2922 100644 --- a/plugins/text/dmesg/dmesg.c +++ b/plugins/text/dmesg/dmesg.c @@ -105,10 +105,10 @@ struct bt_field_class *create_event_payload_fc(void) goto end; error: - BT_PUT(root_fc); + BT_OBJECT_PUT_REF_AND_RESET(root_fc); end: - bt_put(fc); + bt_object_put_ref(fc); return root_fc; } @@ -198,7 +198,7 @@ error: ret = -1; end: - bt_put(fc); + bt_object_put_ref(fc); if (basename) { g_free(basename); @@ -339,13 +339,13 @@ void destroy_dmesg_component(struct dmesg_component *dmesg_comp) g_string_free(dmesg_comp->params.path, TRUE); } - bt_put(dmesg_comp->packet); - bt_put(dmesg_comp->trace); - bt_put(dmesg_comp->stream_class); - bt_put(dmesg_comp->event_class); - bt_put(dmesg_comp->stream); - bt_put(dmesg_comp->clock_class); - bt_put(dmesg_comp->cc_prio_map); + bt_object_put_ref(dmesg_comp->packet); + bt_object_put_ref(dmesg_comp->trace); + bt_object_put_ref(dmesg_comp->stream_class); + bt_object_put_ref(dmesg_comp->event_class); + bt_object_put_ref(dmesg_comp->stream); + bt_object_put_ref(dmesg_comp->clock_class); + bt_object_put_ref(dmesg_comp->cc_prio_map); g_free(dmesg_comp); } @@ -512,7 +512,7 @@ skip_ts: goto end; error: - BT_PUT(notif); + BT_OBJECT_PUT_REF_AND_RESET(notif); end: return notif; @@ -591,7 +591,7 @@ struct bt_notification *create_notif_from_line( goto end; error: - BT_PUT(notif); + BT_OBJECT_PUT_REF_AND_RESET(notif); end: return notif; @@ -610,7 +610,7 @@ void destroy_dmesg_notif_iter(struct dmesg_notif_iter *dmesg_notif_iter) } } - bt_put(dmesg_notif_iter->tmp_event_notif); + bt_object_put_ref(dmesg_notif_iter->tmp_event_notif); free(dmesg_notif_iter->linebuf); g_free(dmesg_notif_iter); } @@ -664,7 +664,7 @@ error: } end: - bt_put(priv_comp); + bt_object_put_ref(priv_comp); return status; } diff --git a/plugins/text/pretty/pretty.c b/plugins/text/pretty/pretty.c index 51480fbe..eb68093c 100644 --- a/plugins/text/pretty/pretty.c +++ b/plugins/text/pretty/pretty.c @@ -70,7 +70,7 @@ const char *plugin_options[] = { static void destroy_pretty_data(struct pretty_component *pretty) { - bt_put(pretty->input_iterator); + bt_object_put_ref(pretty->input_iterator); if (pretty->string) { (void) g_string_free(pretty->string, TRUE); @@ -172,7 +172,7 @@ enum bt_component_status pretty_port_connected( status = BT_COMPONENT_STATUS_ERROR; } - bt_put(connection); + bt_object_put_ref(connection); return status; } @@ -195,7 +195,7 @@ enum bt_component_status pretty_consume(struct bt_private_component *component) switch (it_ret) { case BT_NOTIFICATION_ITERATOR_STATUS_END: ret = BT_COMPONENT_STATUS_END; - BT_PUT(pretty->input_iterator); + BT_OBJECT_PUT_REF_AND_RESET(pretty->input_iterator); goto end; case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: ret = BT_COMPONENT_STATUS_AGAIN; @@ -215,12 +215,12 @@ enum bt_component_status pretty_consume(struct bt_private_component *component) goto end; } - bt_put(notifs[i]); + bt_object_put_ref(notifs[i]); } end: for (; i < count; i++) { - bt_put(notifs[i]); + bt_object_put_ref(notifs[i]); } return ret; @@ -675,7 +675,7 @@ enum bt_component_status apply_params(struct pretty_component *pretty, } end: - bt_put(pretty->plugin_opt_map); + bt_object_put_ref(pretty->plugin_opt_map); pretty->plugin_opt_map = NULL; g_free(str); return ret; diff --git a/plugins/utils/counter/counter.c b/plugins/utils/counter/counter.c index 353c0f60..be831ef9 100644 --- a/plugins/utils/counter/counter.c +++ b/plugins/utils/counter/counter.c @@ -103,7 +103,7 @@ void try_print_last(struct counter *counter) void destroy_private_counter_data(struct counter *counter) { - bt_put(counter->notif_iter); + bt_object_put_ref(counter->notif_iter); g_free(counter); } @@ -115,7 +115,7 @@ void counter_finalize(struct bt_private_component *component) counter = bt_private_component_get_user_data(component); BT_ASSERT(counter); try_print_last(counter); - bt_put(counter->notif_iter); + bt_object_put_ref(counter->notif_iter); g_free(counter); } @@ -195,10 +195,10 @@ enum bt_component_status counter_port_connected( goto end; } - BT_MOVE(counter->notif_iter, iterator); + BT_OBJECT_MOVE_REF(counter->notif_iter, iterator); end: - bt_put(connection); + bt_object_put_ref(connection); return status; } @@ -266,7 +266,7 @@ enum bt_component_status counter_consume(struct bt_private_component *component) counter->count.other++; } - bt_put(notif); + bt_object_put_ref(notif); } } default: diff --git a/plugins/utils/dummy/dummy.c b/plugins/utils/dummy/dummy.c index af6e3cfb..3e98d5ce 100644 --- a/plugins/utils/dummy/dummy.c +++ b/plugins/utils/dummy/dummy.c @@ -28,7 +28,7 @@ void destroy_private_dummy_data(struct dummy *dummy) { - bt_put(dummy->notif_iter); + bt_object_put_ref(dummy->notif_iter); g_free(dummy); } @@ -95,10 +95,10 @@ enum bt_component_status dummy_port_connected( goto end; } - BT_MOVE(dummy->notif_iter, iterator); + BT_OBJECT_MOVE_REF(dummy->notif_iter, iterator); end: - bt_put(connection); + bt_object_put_ref(connection); return status; } @@ -127,7 +127,7 @@ enum bt_component_status dummy_consume(struct bt_private_component *component) ret = BT_COMPONENT_STATUS_OK; for (i = 0; i < count; i++) { - bt_put(notifs[i]); + bt_object_put_ref(notifs[i]); } break; diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index f629e6d5..956e84f5 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -120,14 +120,14 @@ void destroy_muxer_upstream_notif_iter( muxer_upstream_notif_iter, muxer_upstream_notif_iter->notif_iter, muxer_upstream_notif_iter->notifs->length); - bt_put(muxer_upstream_notif_iter->notif_iter); + bt_object_put_ref(muxer_upstream_notif_iter->notif_iter); if (muxer_upstream_notif_iter->notifs) { struct bt_notification *notif; while ((notif = g_queue_pop_head( muxer_upstream_notif_iter->notifs))) { - bt_put(notif); + bt_object_put_ref(notif); } g_queue_free(muxer_upstream_notif_iter->notifs); @@ -150,7 +150,7 @@ struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter( goto end; } - muxer_upstream_notif_iter->notif_iter = bt_get(notif_iter); + muxer_upstream_notif_iter->notif_iter = bt_object_get_ref(notif_iter); muxer_upstream_notif_iter->notifs = g_queue_new(); if (!muxer_upstream_notif_iter->notifs) { BT_LOGE_STR("Failed to allocate a GQueue."); @@ -264,7 +264,7 @@ struct bt_value *get_default_params(void) goto end; error: - BT_PUT(params); + BT_OBJECT_PUT_REF_AND_RESET(params); end: return params; @@ -319,8 +319,8 @@ error: ret = -1; end: - bt_put(default_params); - bt_put(real_params); + bt_object_put_ref(default_params); + bt_object_put_ref(real_params); return ret; } @@ -443,7 +443,7 @@ struct bt_notification_iterator *create_notif_iter_on_input_port( port, bt_port_get_name(port), priv_conn, notif_iter); end: - bt_put(priv_conn); + bt_object_put_ref(priv_conn); return notif_iter; } @@ -499,7 +499,7 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next( * won't be considered again to find the youngest * notification. */ - BT_PUT(muxer_upstream_notif_iter->notif_iter); + BT_OBJECT_PUT_REF_AND_RESET(muxer_upstream_notif_iter->notif_iter); status = BT_NOTIFICATION_ITERATOR_STATUS_OK; break; default: @@ -567,7 +567,7 @@ int muxer_notif_iter_handle_newly_connected_ports( muxer_notif_iter_add_upstream_notif_iter( muxer_notif_iter, upstream_notif_iter, priv_port); - BT_PUT(upstream_notif_iter); + BT_OBJECT_PUT_REF_AND_RESET(upstream_notif_iter); if (!muxer_upstream_notif_iter) { /* * muxer_notif_iter_add_upstream_notif_iter() @@ -577,7 +577,7 @@ int muxer_notif_iter_handle_newly_connected_ports( } remove_node: - bt_put(upstream_notif_iter); + bt_object_put_ref(upstream_notif_iter); muxer_notif_iter->newly_connected_priv_ports = g_list_delete_link( muxer_notif_iter->newly_connected_priv_ports, @@ -1197,11 +1197,11 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp, BT_LOGD("Skipping input port: not connected: " "muxer-comp-addr=%p, port-addr=%p, port-name\"%s\"", muxer_comp, port, bt_port_get_name(port)); - bt_put(priv_port); + bt_object_put_ref(priv_port); continue; } - bt_put(priv_port); + bt_object_put_ref(priv_port); muxer_notif_iter->newly_connected_priv_ports = g_list_append( muxer_notif_iter->newly_connected_priv_ports, @@ -1318,7 +1318,7 @@ error: end: muxer_comp->initializing_muxer_notif_iter = false; - bt_put(priv_comp); + bt_object_put_ref(priv_comp); return status; } @@ -1346,7 +1346,7 @@ void muxer_notif_iter_finalize( destroy_muxer_notif_iter(muxer_notif_iter); } - bt_put(priv_comp); + bt_object_put_ref(priv_comp); } BT_HIDDEN @@ -1386,7 +1386,7 @@ enum bt_notification_iterator_status muxer_notif_iter_next( bt_notification_iterator_status_string(status)); } - bt_put(priv_comp); + bt_object_put_ref(priv_comp); return status; } diff --git a/plugins/utils/trimmer/copy.c b/plugins/utils/trimmer/copy.c index 061e9a84..0607beb5 100644 --- a/plugins/utils/trimmer/copy.c +++ b/plugins/utils/trimmer/copy.c @@ -70,7 +70,7 @@ struct bt_packet *insert_new_packet(struct trimmer_iterator *trim_it, goto end; error: - BT_PUT(writer_packet); + BT_OBJECT_PUT_REF_AND_RESET(writer_packet); end: return writer_packet; } @@ -114,8 +114,8 @@ enum bt_component_status update_packet_context_field(FILE *err, goto error; } if (strcmp(field_name, name)) { - BT_PUT(field_class); - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field_class); + BT_OBJECT_PUT_REF_AND_RESET(field); continue; } if (bt_field_class_id(field_class) != @@ -132,22 +132,22 @@ enum bt_component_status update_packet_context_field(FILE *err, int_ret = bt_field_unsigned_integer_set_value(writer_field, value); BT_ASSERT(int_ret == 0); - BT_PUT(writer_field); - BT_PUT(field_class); - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(writer_field); + BT_OBJECT_PUT_REF_AND_RESET(field_class); + BT_OBJECT_PUT_REF_AND_RESET(field); } ret = BT_COMPONENT_STATUS_OK; goto end; error: - bt_put(writer_field); - bt_put(field_class); - bt_put(field); + bt_object_put_ref(writer_field); + bt_object_put_ref(field_class); + bt_object_put_ref(field); ret = BT_COMPONENT_STATUS_ERROR; end: - bt_put(struct_class); - bt_put(packet_context); + bt_object_put_ref(struct_class); + bt_object_put_ref(packet_context); return ret; } @@ -170,7 +170,7 @@ struct bt_packet *trimmer_new_packet( writer_packet = lookup_packet(trim_it, packet); if (writer_packet) { g_hash_table_remove(trim_it->packet_map, packet); - BT_PUT(writer_packet); + BT_OBJECT_PUT_REF_AND_RESET(writer_packet); } writer_packet = insert_new_packet(trim_it, packet, stream); @@ -178,7 +178,7 @@ struct bt_packet *trimmer_new_packet( BT_LOGE_STR("Failed to insert new packet."); goto error; } - bt_get(writer_packet); + bt_object_get_ref(writer_packet); int_ret = ctf_packet_copy_context(trim_it->err, packet, stream, writer_packet); @@ -190,9 +190,9 @@ struct bt_packet *trimmer_new_packet( goto end; error: - BT_PUT(writer_packet); + BT_OBJECT_PUT_REF_AND_RESET(writer_packet); end: - bt_put(stream); + bt_object_put_ref(stream); return writer_packet; } @@ -247,7 +247,7 @@ struct bt_event *trimmer_output_event( BT_LOGE_STR("Failed to find existing packet."); goto error; } - bt_get(writer_packet); + bt_object_get_ref(writer_packet); int_ret = bt_event_set_packet(writer_event, writer_packet); if (int_ret < 0) { @@ -261,10 +261,10 @@ struct bt_event *trimmer_output_event( goto end; error: - BT_PUT(writer_event); + BT_OBJECT_PUT_REF_AND_RESET(writer_event); end: - bt_put(writer_packet); - bt_put(packet); - bt_put(event_class); + bt_object_put_ref(writer_packet); + bt_object_put_ref(packet); + bt_object_put_ref(event_class); return writer_event; } diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index 335bcfd1..e23daa64 100644 --- a/plugins/utils/trimmer/iterator.c +++ b/plugins/utils/trimmer/iterator.c @@ -44,7 +44,7 @@ gboolean close_packets(gpointer key, gpointer value, gpointer user_data) { struct bt_packet *writer_packet = value; - bt_put(writer_packet); + bt_object_put_ref(writer_packet); return TRUE; } @@ -56,7 +56,7 @@ void trimmer_iterator_finalize(struct bt_private_connection_private_notification trim_it = bt_private_connection_private_notification_iterator_get_user_data(it); BT_ASSERT(trim_it); - bt_put(trim_it->input_iterator); + bt_object_put_ref(trim_it->input_iterator); g_hash_table_foreach_remove(trim_it->packet_map, close_packets, NULL); g_hash_table_destroy(trim_it->packet_map); @@ -107,9 +107,9 @@ enum bt_notification_iterator_status trimmer_iterator_init( goto end; } end: - bt_put(component); - bt_put(connection); - bt_put(input_port); + bt_object_put_ref(component); + bt_object_put_ref(connection); + bt_object_put_ref(input_port); return ret; } @@ -202,7 +202,7 @@ struct bt_notification *evaluate_event_notification( BT_ASSERT(writer_event); new_notification = bt_notification_event_create(writer_event, cc_prio_map); BT_ASSERT(new_notification); - bt_put(cc_prio_map); + bt_object_put_ref(cc_prio_map); stream = bt_event_get_stream(event); BT_ASSERT(stream); @@ -254,15 +254,15 @@ struct bt_notification *evaluate_event_notification( goto end; error: - BT_PUT(new_notification); + BT_OBJECT_PUT_REF_AND_RESET(new_notification); end: - bt_put(event); - bt_put(writer_event); - bt_put(clock_class); - bt_put(trace); - bt_put(stream); - bt_put(stream_class); - bt_put(clock_value); + bt_object_put_ref(event); + bt_object_put_ref(writer_event); + bt_object_put_ref(clock_class); + bt_object_put_ref(trace); + bt_object_put_ref(stream); + bt_object_put_ref(stream_class); + bt_object_put_ref(clock_value); *_event_in_range = in_range; return new_notification; } @@ -306,9 +306,9 @@ int ns_from_integer_field(struct bt_field *integer, int64_t *ns) ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ns); end: - bt_put(integer_class); - bt_put(clock_class); - bt_put(clock_value); + bt_object_put_ref(integer_class); + bt_object_put_ref(clock_class); + bt_object_put_ref(clock_value); return ret; } @@ -366,10 +366,10 @@ int64_t get_raw_timestamp(struct bt_packet *writer_packet, ns += ns_from_value(freq, cycles_offset); - bt_put(writer_clock_class); - bt_put(writer_trace); - bt_put(writer_stream_class); - bt_put(writer_stream); + bt_object_put_ref(writer_clock_class); + bt_object_put_ref(writer_trace); + bt_object_put_ref(writer_stream_class); + bt_object_put_ref(writer_stream); return timestamp - ns; } @@ -492,11 +492,11 @@ end: } end_no_notif: *_packet_in_range = in_range; - bt_put(packet); - bt_put(writer_packet); - bt_put(packet_context); - bt_put(timestamp_begin); - bt_put(timestamp_end); + bt_object_put_ref(packet); + bt_object_put_ref(writer_packet); + bt_object_put_ref(packet_context); + bt_object_put_ref(timestamp_begin); + bt_object_put_ref(timestamp_end); return new_notification; } @@ -545,7 +545,7 @@ enum bt_notification_iterator_status evaluate_notification( default: break; } - BT_PUT(*notification); + BT_OBJECT_PUT_REF_AND_RESET(*notification); *notification = new_notification; if (finished) { @@ -598,7 +598,7 @@ struct bt_notification_iterator_next_method_return trimmer_iterator_next( &trimmer->begin, &trimmer->end, ¬ification_in_range); if (!notification_in_range) { - BT_PUT(ret.notification); + BT_OBJECT_PUT_REF_AND_RESET(ret.notification); } if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { @@ -606,6 +606,6 @@ struct bt_notification_iterator_next_method_return trimmer_iterator_next( } } end: - bt_put(component); + bt_object_put_ref(component); return ret; } diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index 4806dc6f..bcb175df 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -314,7 +314,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, goto end; } - BT_PUT(value); + BT_OBJECT_PUT_REF_AND_RESET(value); value = bt_value_map_get(params, "begin"); if (value) { if (timestamp_from_param("begin", value, @@ -325,7 +325,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, } } - BT_PUT(value); + BT_OBJECT_PUT_REF_AND_RESET(value); value = bt_value_map_get(params, "end"); if (value) { if (timestamp_from_param("end", value, @@ -337,7 +337,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, } end: - bt_put(value); + bt_object_put_ref(value); if (trimmer->begin.set && trimmer->end.set) { if (trimmer->begin.value > trimmer->end.value) { diff --git a/python-plugin-provider/python-plugin-provider.c b/python-plugin-provider/python-plugin-provider.c index de677c85..0ad6a4c3 100644 --- a/python-plugin-provider/python-plugin-provider.c +++ b/python-plugin-provider/python-plugin-provider.c @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -375,7 +375,7 @@ struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info) error: print_python_traceback_warn(); pyerr_clear(); - BT_PUT(plugin); + BT_OBJECT_PUT_REF_AND_RESET(plugin); end: Py_XDECREF(py_name); @@ -492,10 +492,10 @@ struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path) goto end; error: - BT_PUT(plugin_set); + BT_OBJECT_PUT_REF_AND_RESET(plugin_set); end: - bt_put(plugin); + bt_object_put_ref(plugin); Py_XDECREF(py_plugin_info); g_free(basename); return plugin_set; diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index d8794832..3c9fbe2d 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include diff --git a/tests/lib/test_bt_notification_iterator.c b/tests/lib/test_bt_notification_iterator.c index 1cc45537..609bb4e3 100644 --- a/tests/lib/test_bt_notification_iterator.c +++ b/tests/lib/test_bt_notification_iterator.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include "tap/tap.h" @@ -308,7 +308,7 @@ void init_static_data(void) fprintf(stderr, ":: stream 2, packet 2: %p\n", src_stream2_packet2); } - bt_put(trace); + bt_object_put_ref(trace); } static @@ -318,14 +318,14 @@ void fini_static_data(void) g_array_free(test_events, TRUE); /* Metadata */ - bt_put(src_stream_class); - bt_put(src_event_class); - bt_put(src_stream1); - bt_put(src_stream2); - bt_put(src_stream1_packet1); - bt_put(src_stream1_packet2); - bt_put(src_stream2_packet1); - bt_put(src_stream2_packet2); + bt_object_put_ref(src_stream_class); + bt_object_put_ref(src_event_class); + bt_object_put_ref(src_stream1); + bt_object_put_ref(src_stream2); + bt_object_put_ref(src_stream1_packet1); + bt_object_put_ref(src_stream1_packet2); + bt_object_put_ref(src_stream2_packet1); + bt_object_put_ref(src_stream2_packet2); } static @@ -603,7 +603,7 @@ enum bt_notification_iterator_status common_consume( for (i = 0; i < count; i++) { append_test_events_from_notification(notifications[i]); - bt_put(notifications[i]); + bt_object_put_ref(notifications[i]); } end: @@ -630,7 +630,7 @@ enum bt_component_status sink_consume( switch (it_ret) { case BT_NOTIFICATION_ITERATOR_STATUS_END: ret = BT_COMPONENT_STATUS_END; - BT_PUT(user_data->notif_iter); + BT_OBJECT_PUT_REF_AND_RESET(user_data->notif_iter); goto end; case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: abort(); @@ -659,7 +659,7 @@ enum bt_component_status sink_port_connected( conn_status = bt_private_connection_create_notification_iterator( priv_conn, &user_data->notif_iter); BT_ASSERT(conn_status == 0); - bt_put(priv_conn); + bt_object_put_ref(priv_conn); return BT_COMPONENT_STATUS_OK; } @@ -688,7 +688,7 @@ void sink_finalize(struct bt_private_component *private_component) private_component); if (user_data) { - bt_put(user_data->notif_iter); + bt_object_put_ref(user_data->notif_iter); g_free(user_data); } } @@ -721,7 +721,7 @@ void create_source_sink(struct bt_graph *graph, struct bt_component **source, ret = bt_graph_add_component(graph, src_comp_class, "source", NULL, source); BT_ASSERT(ret == 0); - bt_put(src_comp_class); + bt_object_put_ref(src_comp_class); } /* Create sink component */ @@ -740,7 +740,7 @@ void create_source_sink(struct bt_graph *graph, struct bt_component **source, ret = bt_graph_add_component(graph, sink_comp_class, "sink", NULL, sink); BT_ASSERT(ret == 0); - bt_put(sink_comp_class); + bt_object_put_ref(sink_comp_class); } } @@ -769,8 +769,8 @@ void do_std_test(enum test test, const char *name, BT_ASSERT(downstream_port); graph_status = bt_graph_connect_ports(graph, upstream_port, downstream_port, NULL); - bt_put(upstream_port); - bt_put(downstream_port); + bt_object_put_ref(upstream_port); + bt_object_put_ref(downstream_port); /* Run the graph until the end */ while (graph_status == BT_GRAPH_STATUS_OK || @@ -786,9 +786,9 @@ void do_std_test(enum test test, const char *name, "the produced sequence of test events is the expected one"); } - bt_put(src_comp); - bt_put(sink_comp); - BT_PUT(graph); + bt_object_put_ref(src_comp); + bt_object_put_ref(sink_comp); + BT_OBJECT_PUT_REF_AND_RESET(graph); } static @@ -861,7 +861,7 @@ void test_output_port_notification_iterator(void) notif_iter = bt_output_port_notification_iterator_create(upstream_port, NULL); ok(notif_iter, "bt_output_port_notification_iterator_create() succeeds"); - bt_put(upstream_port); + bt_object_put_ref(upstream_port); /* Consume the notification iterator */ while (iter_status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { @@ -875,9 +875,9 @@ void test_output_port_notification_iterator(void) ok(compare_test_events(expected_test_events), "the produced sequence of test events is the expected one"); - bt_put(src_comp); - BT_PUT(graph); - bt_put(notif_iter); + bt_object_put_ref(src_comp); + BT_OBJECT_PUT_REF_AND_RESET(graph); + bt_object_put_ref(notif_iter); } #define DEBUG_ENV_VAR "TEST_BT_NOTIFICATION_ITERATOR_DEBUG" diff --git a/tests/lib/test_bt_values.c b/tests/lib/test_bt_values.c index 8d8f323c..e001a7be 100644 --- a/tests/lib/test_bt_values.c +++ b/tests/lib/test_bt_values.c @@ -20,7 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include #include #include #include @@ -34,9 +34,9 @@ void test_null(void) ok(bt_value_null, "bt_value_null is not NULL"); ok(bt_value_is_null(bt_value_null), "bt_value_null is a null value object"); - bt_get(bt_value_null); + bt_object_get_ref(bt_value_null); pass("getting bt_value_null does not cause a crash"); - bt_put(bt_value_null); + bt_object_put_ref(bt_value_null); pass("putting bt_value_null does not cause a crash"); } @@ -61,7 +61,7 @@ void test_bool(void) ret = bt_value_bool_get(obj, &value); ok(!ret && value, "bt_value_bool_set() works"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); pass("putting an existing boolean value object does not cause a crash") value = BT_FALSE; @@ -72,7 +72,7 @@ void test_bool(void) ok(!ret && value, "bt_value_bool_create_init() sets the appropriate initial value"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); } static @@ -95,7 +95,7 @@ void test_integer(void) ret = bt_value_integer_get(obj, &value); ok(!ret && value == -98765, "bt_value_integer_set() works"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); pass("putting an existing integer value object does not cause a crash") obj = bt_value_integer_create_init(321456987); @@ -105,7 +105,7 @@ void test_integer(void) ok(!ret && value == 321456987, "bt_value_integer_create_init() sets the appropriate initial value"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); } static @@ -129,7 +129,7 @@ void test_real(void) ret = bt_value_real_get(obj, &value); ok(!ret && value == -3.1416, "bt_value_real_set() works"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); pass("putting an existing real number value object does not cause a crash") obj = bt_value_real_create_init(33.1649758); @@ -139,7 +139,7 @@ void test_real(void) ok(!ret && value == 33.1649758, "bt_value_real_create_init() sets the appropriate initial value"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); } static @@ -163,7 +163,7 @@ void test_string(void) ok(!ret && value && !strcmp(value, "hello worldz"), "bt_value_string_get() works"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); pass("putting an existing string value object does not cause a crash") obj = bt_value_string_create_init("initial value"); @@ -173,7 +173,7 @@ void test_string(void) ok(!ret && value && !strcmp(value, "initial value"), "bt_value_string_create_init() sets the appropriate initial value"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); } static @@ -195,13 +195,13 @@ void test_array(void) obj = bt_value_integer_create_init(345); ret = bt_value_array_append_element(array_obj, obj); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); obj = bt_value_real_create_init(-17.45); ret |= bt_value_array_append_element(array_obj, obj); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); obj = bt_value_bool_create_init(BT_TRUE); ret |= bt_value_array_append_element(array_obj, obj); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); ret |= bt_value_array_append_element(array_obj, bt_value_null); ok(!ret, "bt_value_array_append_element() succeeds"); ok(bt_value_array_get_size(array_obj) == 4, @@ -233,7 +233,7 @@ void test_array(void) BT_ASSERT(obj); ok(!bt_value_array_set_element_by_index(array_obj, 2, obj), "bt_value_array_set_element_by_index() succeeds"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); obj = bt_value_array_borrow_element_by_index(array_obj, 2); ok(obj && bt_value_is_integer(obj), "bt_value_array_set_element_by_index() inserts an value object with the appropriate type"); @@ -295,7 +295,7 @@ void test_array(void) ok(bt_value_map_is_empty(obj), "bt_value_array_append_empty_map_element() an empty map value object"); - BT_PUT(array_obj); + BT_OBJECT_PUT_REF_AND_RESET(array_obj); pass("putting an existing array value object does not cause a crash") } @@ -498,13 +498,13 @@ void test_map(void) obj = bt_value_integer_create_init(19457); ret = bt_value_map_insert_entry(map_obj, "int", obj); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); obj = bt_value_real_create_init(5.444); ret |= bt_value_map_insert_entry(map_obj, "real", obj); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); obj = bt_value_bool_create(); ret |= bt_value_map_insert_entry(map_obj, "bt_bool", obj); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); ret |= bt_value_map_insert_entry(map_obj, "null", bt_value_null); ok(!ret, "bt_value_map_insert_entry() succeeds"); ok(bt_value_map_get_size(map_obj) == 4, @@ -512,7 +512,7 @@ void test_map(void) obj = bt_value_bool_create_init(BT_TRUE); ret = bt_value_map_insert_entry(map_obj, "bt_bool", obj); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); ok(!ret, "bt_value_map_insert_entry() accepts an existing key"); obj = bt_value_map_borrow_entry_value(map_obj, "life"); @@ -593,7 +593,7 @@ void test_map(void) checklist.array2 && checklist.map2, "bt_value_map_foreach_entry() iterates over all the map value object's elements"); - BT_PUT(map_obj); + BT_OBJECT_PUT_REF_AND_RESET(map_obj); pass("putting an existing map value object does not cause a crash") } @@ -631,9 +631,9 @@ void test_compare_bool(void) ok(bt_value_compare(bool1, bool3), "boolean value objects are equivalent (BT_FALSE and BT_FALSE)"); - BT_PUT(bool1); - BT_PUT(bool2); - BT_PUT(bool3); + BT_OBJECT_PUT_REF_AND_RESET(bool1); + BT_OBJECT_PUT_REF_AND_RESET(bool2); + BT_OBJECT_PUT_REF_AND_RESET(bool3); } static @@ -651,9 +651,9 @@ void test_compare_integer(void) ok(bt_value_compare(int1, int3), "integer value objects are equivalent (10 and 10)"); - BT_PUT(int1); - BT_PUT(int2); - BT_PUT(int3); + BT_OBJECT_PUT_REF_AND_RESET(int1); + BT_OBJECT_PUT_REF_AND_RESET(int2); + BT_OBJECT_PUT_REF_AND_RESET(int3); } static @@ -672,9 +672,9 @@ void test_compare_real(void) ok(bt_value_compare(real1, real3), "real number value objects are equivalent (17.38 and 17.38)"); - BT_PUT(real1); - BT_PUT(real2); - BT_PUT(real3); + BT_OBJECT_PUT_REF_AND_RESET(real1); + BT_OBJECT_PUT_REF_AND_RESET(real2); + BT_OBJECT_PUT_REF_AND_RESET(real3); } static @@ -693,9 +693,9 @@ void test_compare_string(void) ok(bt_value_compare(string1, string3), "string value objects are equivalent (\"hello\" and \"hello\")"); - BT_PUT(string1); - BT_PUT(string2); - BT_PUT(string3); + BT_OBJECT_PUT_REF_AND_RESET(string1); + BT_OBJECT_PUT_REF_AND_RESET(string2); + BT_OBJECT_PUT_REF_AND_RESET(string3); } static @@ -730,9 +730,9 @@ void test_compare_array(void) ok(bt_value_compare(array1, array3), "array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])"); - BT_PUT(array1); - BT_PUT(array2); - BT_PUT(array3); + BT_OBJECT_PUT_REF_AND_RESET(array1); + BT_OBJECT_PUT_REF_AND_RESET(array2); + BT_OBJECT_PUT_REF_AND_RESET(array3); } static @@ -767,9 +767,9 @@ void test_compare_map(void) ok(bt_value_compare(map1, map3), "map value objects are equivalent"); - BT_PUT(map1); - BT_PUT(map2); - BT_PUT(map3); + BT_OBJECT_PUT_REF_AND_RESET(map1); + BT_OBJECT_PUT_REF_AND_RESET(map2); + BT_OBJECT_PUT_REF_AND_RESET(map3); } static @@ -848,13 +848,13 @@ void test_copy(void) ok(bt_value_compare(map_obj, map_copy_obj), "source and destination value objects have the same content"); - BT_PUT(map_copy_obj); - BT_PUT(bool_obj); - BT_PUT(integer_obj); - BT_PUT(real_obj); - BT_PUT(string_obj); - BT_PUT(array_obj); - BT_PUT(map_obj); + BT_OBJECT_PUT_REF_AND_RESET(map_copy_obj); + BT_OBJECT_PUT_REF_AND_RESET(bool_obj); + BT_OBJECT_PUT_REF_AND_RESET(integer_obj); + BT_OBJECT_PUT_REF_AND_RESET(real_obj); + BT_OBJECT_PUT_REF_AND_RESET(string_obj); + BT_OBJECT_PUT_REF_AND_RESET(array_obj); + BT_OBJECT_PUT_REF_AND_RESET(map_obj); } static @@ -912,10 +912,10 @@ void test_extend(void) ok(compare_map_elements(extension_map, extended_map, "project"), "bt_value_map_extend() picks the appropriate element (project)"); - BT_PUT(array); - BT_PUT(base_map); - BT_PUT(extension_map); - BT_PUT(extended_map); + BT_OBJECT_PUT_REF_AND_RESET(array); + BT_OBJECT_PUT_REF_AND_RESET(base_map); + BT_OBJECT_PUT_REF_AND_RESET(extension_map); + BT_OBJECT_PUT_REF_AND_RESET(extended_map); } int main(void) diff --git a/tests/lib/test_ctf_writer.c b/tests/lib/test_ctf_writer.c index 97c11cd3..39cc888e 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -193,7 +193,7 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, ok(returned_type == int_64_type, "bt_ctf_field_type_enumeration_get_container_field_type returns the right type"); ok(!bt_ctf_field_type_enumeration_create(enum_type), "bt_ctf_field_enumeration_type_create rejects non-integer container field types"); - bt_put(returned_type); + bt_object_put_ref(returned_type); bt_ctf_field_type_set_alignment(float_type, 32); ok(bt_ctf_field_type_get_alignment(float_type) == 32, @@ -316,7 +316,7 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, returned_type = bt_ctf_event_class_get_context_field_type(simple_event_class); ok(returned_type == event_context_type, "bt_ctf_event_class_get_context_field_type returns the appropriate type"); - bt_put(returned_type); + bt_object_put_ref(returned_type); ok(!bt_ctf_stream_class_add_event_class(stream_class, simple_event_class), "Adding simple event class to stream class"); @@ -326,8 +326,8 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, * of simple_event_class, so we retrieve the new ones to create * the appropriate fields. */ - BT_PUT(event_context_type); - BT_PUT(event_payload_type); + BT_OBJECT_PUT_REF_AND_RESET(event_context_type); + BT_OBJECT_PUT_REF_AND_RESET(event_payload_type); event_payload_type = bt_ctf_event_class_get_payload_field_type( simple_event_class); BT_ASSERT(event_payload_type); @@ -352,14 +352,14 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, ret_event_class = bt_ctf_stream_class_get_event_class_by_index(stream_class, 0); ok(ret_event_class == simple_event_class, "bt_ctf_stream_class_get_event_class returns the correct event class"); - bt_put(ret_event_class); + bt_object_put_ref(ret_event_class); ok(!bt_ctf_stream_class_get_event_class_by_id(stream_class, 2), "bt_ctf_stream_class_get_event_class_by_id returns NULL when the requested ID doesn't exist"); ret_event_class = bt_ctf_stream_class_get_event_class_by_id(stream_class, 13); ok(ret_event_class == simple_event_class, "bt_ctf_stream_class_get_event_class_by_id returns a correct event class"); - bt_put(ret_event_class); + bt_object_put_ref(ret_event_class); simple_event = bt_ctf_event_create(simple_event_class); ok(simple_event, @@ -386,7 +386,7 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, "Set signed enumeration container value"); ret = bt_ctf_event_set_payload(simple_event, "enum_field", enum_field); BT_ASSERT(!ret); - BT_PUT(iter); + BT_OBJECT_PUT_REF_AND_RESET(iter); enum_field_unsigned = bt_ctf_field_create(ep_enum_field_unsigned_type); BT_ASSERT(enum_field_unsigned); @@ -434,7 +434,7 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, "packet_size"); ok(packet_context_field, "Packet context contains the default packet_size field."); - bt_put(packet_context_field); + bt_object_put_ref(packet_context_field); packet_context_field = bt_ctf_field_structure_get_field_by_name(packet_context, "custom_packet_context_field"); ok(bt_ctf_field_integer_unsigned_set_value(packet_context_field, 8) == 0, @@ -446,32 +446,32 @@ void append_simple_event(struct bt_ctf_stream_class *stream_class, ok(bt_ctf_stream_flush(stream) == 0, "Flush trace stream with one event"); - bt_put(simple_event_class); - bt_put(simple_event); - bt_put(uint_12_type); - bt_put(int_64_type); - bt_put(float_type); - bt_put(enum_type); - bt_put(enum_type_unsigned); - bt_put(returned_type); - bt_put(event_context_type); - bt_put(integer_field); - bt_put(float_field); - bt_put(enum_field); - bt_put(enum_field_unsigned); - bt_put(enum_container_field); - bt_put(enum_container_field_unsigned); - bt_put(packet_context); - bt_put(packet_context_field); - bt_put(stream_event_context); - bt_put(stream_event_context_field); - bt_put(event_context); - bt_put(event_context_field); - bt_put(event_payload_type); - bt_put(ep_integer_field_type); - bt_put(ep_enum_field_type); - bt_put(ep_enum_field_unsigned_type); - bt_put(iter); + bt_object_put_ref(simple_event_class); + bt_object_put_ref(simple_event); + bt_object_put_ref(uint_12_type); + bt_object_put_ref(int_64_type); + bt_object_put_ref(float_type); + bt_object_put_ref(enum_type); + bt_object_put_ref(enum_type_unsigned); + bt_object_put_ref(returned_type); + bt_object_put_ref(event_context_type); + bt_object_put_ref(integer_field); + bt_object_put_ref(float_field); + bt_object_put_ref(enum_field); + bt_object_put_ref(enum_field_unsigned); + bt_object_put_ref(enum_container_field); + bt_object_put_ref(enum_container_field_unsigned); + bt_object_put_ref(packet_context); + bt_object_put_ref(packet_context_field); + bt_object_put_ref(stream_event_context); + bt_object_put_ref(stream_event_context_field); + bt_object_put_ref(event_context); + bt_object_put_ref(event_context_field); + bt_object_put_ref(event_payload_type); + bt_object_put_ref(ep_integer_field_type); + bt_object_put_ref(ep_enum_field_type); + bt_object_put_ref(ep_enum_field_unsigned_type); + bt_object_put_ref(iter); } static @@ -544,7 +544,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, array_type); ok(ret_field_type == int_16_type, "bt_ctf_field_type_array_get_element_field_type returns the correct type"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); ok(bt_ctf_field_type_array_get_length(array_type) == ARRAY_TEST_LENGTH, "bt_ctf_field_type_array_get_length returns the correct length"); @@ -577,7 +577,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, ret_field_type = bt_ctf_field_type_variant_get_tag_field_type(variant_type); ok(ret_field_type == enum_variant_type, "bt_ctf_field_type_variant_get_tag_field_type returns a correct tag type"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); ret_string = bt_ctf_field_type_variant_get_tag_name(variant_type); ok(ret_string ? !strcmp(ret_string, "variant_selector") : 0, @@ -586,14 +586,14 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, variant_type, "INT16_TYPE"); ok(ret_field_type == int_16_type, "bt_ctf_field_type_variant_get_field_type_by_name returns a correct field type"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); ok(bt_ctf_field_type_variant_get_field_count(variant_type) == 3, "bt_ctf_field_type_variant_get_field_count returns the correct count"); ok(bt_ctf_field_type_variant_get_field_by_index(variant_type, NULL, &ret_field_type, 0) == 0, "bt_ctf_field_type_variant_get_field handles a NULL field name correctly"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); ok(bt_ctf_field_type_variant_get_field_by_index(variant_type, &ret_string, NULL, 0) == 0, "bt_ctf_field_type_variant_get_field handles a NULL field type correctly"); ok(bt_ctf_field_type_variant_get_field_by_index(variant_type, &ret_string, &ret_field_type, 1) == 0, @@ -602,7 +602,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, "bt_ctf_field_type_variant_get_field returns a correct field name"); ok(ret_field_type == int_16_type, "bt_ctf_field_type_variant_get_field returns a correct field type"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); ok(!bt_ctf_field_type_structure_add_field(complex_structure_type, enum_variant_type, "variant_selector"), @@ -679,13 +679,13 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, ret_stream_class = bt_ctf_event_class_get_stream_class(event_class); ok(ret_stream_class == stream_class, "bt_ctf_event_class_get_stream_class returns the correct stream class"); - bt_put(ret_stream_class); + bt_object_put_ref(ret_stream_class); ok(bt_ctf_event_class_get_field_by_name(event_class, "truie") == NULL, "bt_ctf_event_class_get_field_by_name handles an invalid field name correctly"); ret_field_type = bt_ctf_event_class_get_field_by_name(event_class, "complex_structure"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); event = bt_ctf_event_create(event_class); ok(event, "Instanciate a complex event"); @@ -693,7 +693,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, ret_event_class = bt_ctf_event_get_class(event); ok(ret_event_class == event_class, "bt_ctf_event_get_class returns the correct event class"); - bt_put(ret_event_class); + bt_object_put_ref(ret_event_class); uint_35_field = bt_ctf_event_get_payload(event, "uint_35"); ok(uint_35_field, "Use bt_ctf_event_get_payload to get a field instance "); @@ -703,7 +703,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, "bt_ctf_field_integer_unsigned_get_value succeeds after setting a value"); ok(ret_unsigned_int == 0x0DDF00D, "bt_ctf_field_integer_unsigned_get_value returns the correct value"); - bt_put(uint_35_field); + bt_object_put_ref(uint_35_field); int_16_field = bt_ctf_event_get_payload(event, "int_16"); bt_ctf_field_integer_signed_set_value(int_16_field, -12345); @@ -712,7 +712,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, "bt_ctf_field_integer_signed_get_value succeeds after setting a value"); ok(ret_signed_int == -12345, "bt_ctf_field_integer_signed_get_value returns the correct value"); - bt_put(int_16_field); + bt_object_put_ref(int_16_field); complex_structure_field = bt_ctf_event_get_payload(event, "complex_structure"); @@ -720,8 +720,8 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, inner_structure_field = bt_ctf_field_structure_get_field_by_index( complex_structure_field, 3); ret_field_type = bt_ctf_field_get_type(inner_structure_field); - bt_put(inner_structure_field); - bt_put(ret_field_type); + bt_object_put_ref(inner_structure_field); + bt_object_put_ref(ret_field_type); inner_structure_field = bt_ctf_field_structure_get_field_by_name( complex_structure_field, "inner_structure"); @@ -744,7 +744,7 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, int_16_field = bt_ctf_field_variant_get_field(variant_field, enum_variant_field); bt_ctf_field_integer_signed_set_value(int_16_field, -200); - bt_put(int_16_field); + bt_object_put_ref(int_16_field); bt_ctf_field_string_set_value(a_string_field, test_string_1); ok(!bt_ctf_field_string_append(a_string_field, test_string_2), @@ -775,23 +775,23 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, int_16_field = bt_ctf_field_sequence_get_field( a_sequence_field, i); bt_ctf_field_integer_signed_set_value(int_16_field, 4 - i); - bt_put(int_16_field); + bt_object_put_ref(int_16_field); } for (i = 0; i < ARRAY_TEST_LENGTH; i++) { int_16_field = bt_ctf_field_array_get_field( an_array_field, i); bt_ctf_field_integer_signed_set_value(int_16_field, i); - bt_put(int_16_field); + bt_object_put_ref(int_16_field); } stream_event_ctx_field = bt_ctf_event_get_stream_event_context(event); BT_ASSERT(stream_event_ctx_field); stream_event_ctx_int_field = bt_ctf_field_structure_get_field_by_name( stream_event_ctx_field, "common_event_context"); - BT_PUT(stream_event_ctx_field); + BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_field); bt_ctf_field_integer_unsigned_set_value(stream_event_ctx_int_field, 17); - BT_PUT(stream_event_ctx_int_field); + BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_int_field); bt_ctf_clock_set_time(clock, ++current_time); ok(bt_ctf_stream_append_event(stream, event) == 0, @@ -809,30 +809,30 @@ void append_complex_event(struct bt_ctf_stream_class *stream_class, ok(bt_ctf_stream_flush(stream) == 0, "Flush a stream containing a complex event"); - bt_put(uint_35_field); - bt_put(a_string_field); - bt_put(inner_structure_field); - bt_put(complex_structure_field); - bt_put(a_sequence_field); - bt_put(an_array_field); - bt_put(enum_variant_field); - bt_put(enum_container_field); - bt_put(variant_field); - bt_put(packet_context_field); - bt_put(packet_context); - bt_put(uint_35_type); - bt_put(int_16_type); - bt_put(string_type); - bt_put(sequence_type); - bt_put(array_type); - bt_put(inner_structure_type); - bt_put(complex_structure_type); - bt_put(uint_3_type); - bt_put(enum_variant_type); - bt_put(variant_type); - bt_put(ret_field_type); - bt_put(event_class); - bt_put(event); + bt_object_put_ref(uint_35_field); + bt_object_put_ref(a_string_field); + bt_object_put_ref(inner_structure_field); + bt_object_put_ref(complex_structure_field); + bt_object_put_ref(a_sequence_field); + bt_object_put_ref(an_array_field); + bt_object_put_ref(enum_variant_field); + bt_object_put_ref(enum_container_field); + bt_object_put_ref(variant_field); + bt_object_put_ref(packet_context_field); + bt_object_put_ref(packet_context); + bt_object_put_ref(uint_35_type); + bt_object_put_ref(int_16_type); + bt_object_put_ref(string_type); + bt_object_put_ref(sequence_type); + bt_object_put_ref(array_type); + bt_object_put_ref(inner_structure_type); + bt_object_put_ref(complex_structure_type); + bt_object_put_ref(uint_3_type); + bt_object_put_ref(enum_variant_type); + bt_object_put_ref(variant_type); + bt_object_put_ref(ret_field_type); + bt_object_put_ref(event_class); + bt_object_put_ref(event); } static @@ -939,7 +939,7 @@ void type_field_tests() sequence_type); ok(returned_type == int_16_type, "bt_ctf_field_type_sequence_get_element_field_type returns the correct type"); - bt_put(returned_type); + bt_object_put_ref(returned_type); string_type = bt_ctf_field_type_string_create(); ok(string_type, "Create a string type"); @@ -975,7 +975,7 @@ void type_field_tests() ok(bt_ctf_field_type_structure_get_field(structure_seq_type, NULL, &returned_type, 1) == 0, "bt_ctf_field_type_structure_get_field handles a NULL name correctly"); - bt_put(returned_type); + bt_object_put_ref(returned_type); ok(bt_ctf_field_type_structure_get_field(structure_seq_type, &ret_string, NULL, 1) == 0, "bt_ctf_field_type_structure_get_field handles a NULL return type correctly"); @@ -986,13 +986,13 @@ void type_field_tests() "bt_ctf_field_type_structure_get_field returns a correct field name"); ok(returned_type == sequence_type, "bt_ctf_field_type_structure_get_field returns a correct field type"); - bt_put(returned_type); + bt_object_put_ref(returned_type); returned_type = bt_ctf_field_type_structure_get_field_type_by_name( structure_seq_type, "a_sequence"); ok(returned_type == sequence_type, "bt_ctf_field_type_structure_get_field_type_by_name returns the correct field type"); - bt_put(returned_type); + bt_object_put_ref(returned_type); composite_structure_type = bt_ctf_field_type_structure_create(); ok(bt_ctf_field_type_structure_add_field(composite_structure_type, @@ -1006,7 +1006,7 @@ void type_field_tests() structure_seq_type, "a_sequence"); ok(returned_type == sequence_type, "bt_ctf_field_type_structure_get_field_type_by_name returns a correct type"); - bt_put(returned_type); + bt_object_put_ref(returned_type); int_16 = bt_ctf_field_create(int_16_type); ok(int_16, "Instanciate a signed 16-bit integer"); @@ -1045,18 +1045,18 @@ void type_field_tests() ok(enumeration_type, "Create an enumeration type with an unsigned 12-bit integer as container"); - bt_put(string); - bt_put(uint_12); - bt_put(int_16); - bt_put(composite_structure_type); - bt_put(structure_seq_type); - bt_put(string_type); - bt_put(sequence_type); - bt_put(uint_8_type); - bt_put(int_16_type); - bt_put(uint_12_type); - bt_put(enumeration_type); - bt_put(returned_type); + bt_object_put_ref(string); + bt_object_put_ref(uint_12); + bt_object_put_ref(int_16); + bt_object_put_ref(composite_structure_type); + bt_object_put_ref(structure_seq_type); + bt_object_put_ref(string_type); + bt_object_put_ref(sequence_type); + bt_object_put_ref(uint_8_type); + bt_object_put_ref(int_16_type); + bt_object_put_ref(uint_12_type); + bt_object_put_ref(enumeration_type); + bt_object_put_ref(returned_type); } static @@ -1114,9 +1114,9 @@ void packet_resize_test(struct bt_ctf_stream_class *stream_class, event = bt_ctf_event_create(event_class); ret_field = bt_ctf_event_get_payload(event, 0); ret_field_type = bt_ctf_field_get_type(ret_field); - bt_put(ret_field_type); - bt_put(ret_field); - bt_put(event); + bt_object_put_ref(ret_field_type); + bt_object_put_ref(ret_field); + bt_object_put_ref(event); for (i = 0; i < packet_resize_test_length; i++) { event = bt_ctf_event_create(event_class); @@ -1129,24 +1129,24 @@ void packet_resize_test(struct bt_ctf_stream_class *stream_class, ret |= bt_ctf_field_integer_unsigned_set_value(integer, i); ret |= bt_ctf_event_set_payload(event, "field_1", integer); - bt_put(integer); + bt_object_put_ref(integer); ret |= bt_ctf_field_string_set_value(string, "This is a test"); ret |= bt_ctf_event_set_payload(event, "a_string", string); - bt_put(string); + bt_object_put_ref(string); /* Populate stream event context */ stream_event_context = bt_ctf_event_get_stream_event_context(event); integer = bt_ctf_field_structure_get_field_by_name(stream_event_context, "common_event_context"); - BT_PUT(stream_event_context); + BT_OBJECT_PUT_REF_AND_RESET(stream_event_context); ret |= bt_ctf_field_integer_unsigned_set_value(integer, i % 42); - bt_put(integer); + bt_object_put_ref(integer); ret |= bt_ctf_stream_append_event(stream, event); - bt_put(event); + bt_object_put_ref(event); if (ret) { break; @@ -1179,15 +1179,15 @@ end: ret = bt_ctf_stream_get_discarded_events_count(stream, &ret_uint64); ok(ret == 0 && ret_uint64 == 1000, "bt_ctf_stream_get_discarded_events_count returns a correct number of discarded events after a flush"); - bt_put(integer_type); - bt_put(string_type); - bt_put(packet_context); - bt_put(packet_context_field); - bt_put(stream_event_context); - bt_put(event_class); - bt_put(ep_field_1_type); - bt_put(ep_a_string_type); - bt_put(ep_type); + bt_object_put_ref(integer_type); + bt_object_put_ref(string_type); + bt_object_put_ref(packet_context); + bt_object_put_ref(packet_context_field); + bt_object_put_ref(stream_event_context); + bt_object_put_ref(event_class); + bt_object_put_ref(ep_field_1_type); + bt_object_put_ref(ep_a_string_type); + bt_object_put_ref(ep_type); } static @@ -1233,10 +1233,10 @@ void test_empty_stream(struct bt_ctf_writer *writer) end: ok(ret == 0, "Created a stream class with default attributes and an empty stream"); - bt_put(trace); - bt_put(ret_trace); - bt_put(stream); - bt_put(stream_class); + bt_object_put_ref(trace); + bt_object_put_ref(ret_trace); + bt_object_put_ref(stream); + bt_object_put_ref(stream_class); } static @@ -1348,7 +1348,7 @@ void test_custom_event_header_stream(struct bt_ctf_writer *writer, fail("Failed to set custom_trace_packet_header_field value"); goto end; } - bt_put(integer); + bt_object_put_ref(integer); event = bt_ctf_event_create(event_class); if (!event) { @@ -1387,7 +1387,7 @@ void test_custom_event_header_stream(struct bt_ctf_writer *writer, fail("Failed to set sequence length"); goto end; } - bt_put(integer); + bt_object_put_ref(integer); for (i = 0; i < 2; i++) { integer = bt_ctf_field_sequence_get_field(sequence, i); @@ -1402,7 +1402,7 @@ void test_custom_event_header_stream(struct bt_ctf_writer *writer, goto end; } - bt_put(integer); + bt_object_put_ref(integer); integer = NULL; } @@ -1417,17 +1417,17 @@ void test_custom_event_header_stream(struct bt_ctf_writer *writer, fail("Failed to flush custom_event_header stream"); } end: - bt_put(stream); - bt_put(stream_class); - bt_put(event_class); - bt_put(event); - bt_put(integer); - bt_put(sequence); - bt_put(event_header); - bt_put(packet_header); - bt_put(sequence_type); - bt_put(integer_type); - bt_put(event_header_type); + bt_object_put_ref(stream); + bt_object_put_ref(stream_class); + bt_object_put_ref(event_class); + bt_object_put_ref(event); + bt_object_put_ref(integer); + bt_object_put_ref(sequence); + bt_object_put_ref(event_header); + bt_object_put_ref(packet_header); + bt_object_put_ref(sequence_type); + bt_object_put_ref(integer_type); + bt_object_put_ref(event_header_type); } static @@ -1524,14 +1524,14 @@ void test_instanciate_event_before_stream(struct bt_ctf_writer *writer, end: ok(ret == 0, "Create an event before instanciating its associated stream"); - bt_put(stream); - bt_put(ret_stream); - bt_put(stream_class); - bt_put(event_class); - bt_put(event); - bt_put(integer_type); - bt_put(integer); - bt_put(payload_field); + bt_object_put_ref(stream); + bt_object_put_ref(ret_stream); + bt_object_put_ref(stream_class); + bt_object_put_ref(event_class); + bt_object_put_ref(event); + bt_object_put_ref(integer_type); + bt_object_put_ref(integer); + bt_object_put_ref(payload_field); } static @@ -1544,7 +1544,7 @@ void append_existing_event_class(struct bt_ctf_stream_class *stream_class) BT_ASSERT(event_class); ok(bt_ctf_stream_class_add_event_class(stream_class, event_class) == 0, "two event classes with the same name may cohabit within the same stream class"); - bt_put(event_class); + bt_object_put_ref(event_class); event_class = bt_ctf_event_class_create("different name, ok"); BT_ASSERT(event_class); @@ -1552,7 +1552,7 @@ void append_existing_event_class(struct bt_ctf_stream_class *stream_class) BT_ASSERT(ret == 0); ok(bt_ctf_stream_class_add_event_class(stream_class, event_class), "two event classes with the same ID cannot cohabit within the same stream class"); - bt_put(event_class); + bt_object_put_ref(event_class); } static @@ -1572,7 +1572,7 @@ void test_clock_utils(void) ret = bt_ctf_clock_set_frequency(clock, 1534); BT_ASSERT(!ret); - BT_PUT(clock); + BT_OBJECT_PUT_REF_AND_RESET(clock); } int main(int argc, char **argv) @@ -1678,14 +1678,14 @@ int main(int argc, char **argv) "bt_ctf_trace_set_environment_field handles a NULL value correctly"); ok(!bt_ctf_trace_set_environment_field(trace, "test_env_int_obj", obj), "bt_ctf_trace_set_environment_field succeeds in adding an integer object"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); /* Test bt_ctf_trace_set_environment_field with a string object */ obj = bt_value_string_create_init("the value"); BT_ASSERT(obj); ok(!bt_ctf_trace_set_environment_field(trace, "test_env_str_obj", obj), "bt_ctf_trace_set_environment_field succeeds in adding a string object"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); /* Test bt_ctf_trace_set_environment_field_integer */ ok(bt_ctf_trace_set_environment_field_integer(NULL, "test_env_int", @@ -1736,12 +1736,12 @@ int main(int argc, char **argv) ret = bt_value_integer_get(obj, &ret_int64_t); ok(!ret && ret_int64_t == 23, "bt_ctf_trace_get_environment_field_value succeeds in getting an integer value"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 2); ret = bt_value_string_get(obj, &ret_string); ok(!ret && ret_string && !strcmp(ret_string, "the value"), "bt_ctf_trace_get_environment_field_value succeeds in getting a string value"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); /* Test bt_ctf_trace_get_environment_field_value_by_name */ ok(!bt_ctf_trace_get_environment_field_value_by_name(trace, "oh oh"), @@ -1751,7 +1751,7 @@ int main(int argc, char **argv) ret = bt_value_string_get(obj, &ret_string); ok(!ret && ret_string && !strcmp(ret_string, "oh yeah"), "bt_ctf_trace_get_environment_field_value_by_name succeeds in getting an existing field"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); /* Test environment field replacement */ ok(!bt_ctf_trace_set_environment_field_integer(trace, "test_env_int", @@ -1763,7 +1763,7 @@ int main(int argc, char **argv) ret = bt_value_integer_get(obj, &ret_int64_t); ok(!ret && ret_int64_t == 654321, "bt_ctf_trace_get_environment_field_value successfully replaces an existing field"); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); ok(bt_ctf_writer_add_environment_field(writer, "sysname", name.sysname) == 0, "Add sysname (%s) environment field to writer instance", @@ -1881,7 +1881,7 @@ int main(int argc, char **argv) ret_clock = bt_ctf_stream_class_get_clock(stream_class); ok(ret_clock == clock, "bt_ctf_stream_class_get_clock returns a correct clock"); - bt_put(ret_clock); + bt_object_put_ref(ret_clock); /* Test the event fields and event types APIs */ type_field_tests(); @@ -1910,7 +1910,7 @@ int main(int argc, char **argv) ok(bt_ctf_field_type_get_type_id( event_header_field_type) == BT_CTF_FIELD_TYPE_ID_INTEGER, "Default event header \"id\" field is an integer"); - bt_put(event_header_field_type); + bt_object_put_ref(event_header_field_type); event_header_field_type = bt_ctf_field_type_structure_get_field_type_by_name( ret_field_type, "timestamp"); @@ -1919,8 +1919,8 @@ int main(int argc, char **argv) ok(bt_ctf_field_type_get_type_id( event_header_field_type) == BT_CTF_FIELD_TYPE_ID_INTEGER, "Default event header \"timestamp\" field is an integer"); - bt_put(event_header_field_type); - bt_put(ret_field_type); + bt_object_put_ref(event_header_field_type); + bt_object_put_ref(ret_field_type); /* Add a custom trace packet header field */ packet_header_type = bt_ctf_trace_get_packet_header_field_type(trace); @@ -1931,15 +1931,15 @@ int main(int argc, char **argv) ret_field_type = bt_ctf_field_type_structure_get_field_type_by_name( packet_header_type, "magic"); ok(ret_field_type, "Default packet header type contains a \"magic\" field"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); ret_field_type = bt_ctf_field_type_structure_get_field_type_by_name( packet_header_type, "uuid"); ok(ret_field_type, "Default packet header type contains a \"uuid\" field"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); ret_field_type = bt_ctf_field_type_structure_get_field_type_by_name( packet_header_type, "stream_id"); ok(ret_field_type, "Default packet header type contains a \"stream_id\" field"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); packet_header_field_type = bt_ctf_field_type_integer_create(22); ok(!bt_ctf_field_type_structure_add_field(packet_header_type, @@ -1994,7 +1994,7 @@ int main(int argc, char **argv) stream_class); ok(ret_field_type == stream_event_context_type, "bt_ctf_stream_class_get_event_context_type returns the correct field type."); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); /* Instantiate a stream and append events */ @@ -2010,7 +2010,7 @@ int main(int argc, char **argv) stream = bt_ctf_trace_get_stream_by_index(trace, 0); ok(stream == stream1, "bt_ctf_trace_get_stream_by_index() succeeds and returns the correct value"); - BT_PUT(stream); + BT_OBJECT_PUT_REF_AND_RESET(stream); /* * Creating a stream through a writer adds the given stream @@ -2029,9 +2029,9 @@ int main(int argc, char **argv) * event context types were copied for the resolving * process */ - BT_PUT(packet_header_type); - BT_PUT(packet_context_type); - BT_PUT(stream_event_context_type); + BT_OBJECT_PUT_REF_AND_RESET(packet_header_type); + BT_OBJECT_PUT_REF_AND_RESET(packet_context_type); + BT_OBJECT_PUT_REF_AND_RESET(stream_event_context_type); packet_header_type = bt_ctf_trace_get_packet_header_field_type(trace); BT_ASSERT(packet_header_type); packet_context_type = @@ -2081,7 +2081,7 @@ int main(int argc, char **argv) ret_field_type = bt_ctf_field_get_type(packet_header); ok(ret_field_type == packet_header_type, "Stream returns a packet header of the appropriate type"); - bt_put(ret_field_type); + bt_object_put_ref(ret_field_type); packet_header_field = bt_ctf_field_structure_get_field_by_name(packet_header, "custom_trace_packet_header_field"); ok(packet_header_field, @@ -2122,22 +2122,22 @@ int main(int argc, char **argv) bt_ctf_writer_flush_metadata(writer); - bt_put(clock); - bt_put(ret_stream_class); - bt_put(writer); - bt_put(stream1); - bt_put(packet_context_type); - bt_put(packet_context_field_type); - bt_put(integer_type); - bt_put(stream_event_context_type); - bt_put(ret_field_type); - bt_put(packet_header_type); - bt_put(packet_header_field_type); - bt_put(packet_header); - bt_put(packet_header_field); - bt_put(trace); + bt_object_put_ref(clock); + bt_object_put_ref(ret_stream_class); + bt_object_put_ref(writer); + bt_object_put_ref(stream1); + bt_object_put_ref(packet_context_type); + bt_object_put_ref(packet_context_field_type); + bt_object_put_ref(integer_type); + bt_object_put_ref(stream_event_context_type); + bt_object_put_ref(ret_field_type); + bt_object_put_ref(packet_header_type); + bt_object_put_ref(packet_header_field_type); + bt_object_put_ref(packet_header); + bt_object_put_ref(packet_header_field); + bt_object_put_ref(trace); free(metadata_string); - bt_put(stream_class); + bt_object_put_ref(stream_class); validate_trace(argv[1], trace_path); diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index c34821a6..c3b50e09 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include #include #include #include @@ -399,7 +399,7 @@ enum bt_component_status sink_consume( BT_ASSERT(def_port); ret = bt_private_port_remove_from_component(def_port); BT_ASSERT(ret == 0); - bt_put(def_port); + bt_object_put_ref(def_port); break; default: break; @@ -466,7 +466,7 @@ void graph_port_added(struct bt_port *port, struct bt_component *comp = bt_port_get_component(port); BT_ASSERT(comp); - bt_put(comp); + bt_object_put_ref(comp); struct event event = { .type = GRAPH_PORT_ADDED, @@ -507,9 +507,9 @@ void graph_ports_connected(struct bt_port *upstream_port, BT_ASSERT(upstream_comp); BT_ASSERT(downstream_comp); BT_ASSERT(conn); - bt_put(upstream_comp); - bt_put(downstream_comp); - bt_put(conn); + bt_object_put_ref(upstream_comp); + bt_object_put_ref(downstream_comp); + bt_object_put_ref(conn); struct event event = { .type = GRAPH_PORTS_CONNECTED, @@ -585,8 +585,8 @@ void init_test(void) static void fini_test(void) { - bt_put(src_comp_class); - bt_put(sink_comp_class); + bt_object_put_ref(src_comp_class); + bt_object_put_ref(sink_comp_class); g_array_free(events, TRUE); } @@ -814,12 +814,12 @@ void test_sink_removes_port_in_port_connected_then_src_removes_disconnected_port ok(graph_port_removed_src_pos < graph_port_removed_sink_pos, "event order is good (13)"); - bt_put(graph); - bt_put(sink); - bt_put(src); - bt_put(conn); - bt_put(src_def_port); - bt_put(sink_def_port); + bt_object_put_ref(graph); + bt_object_put_ref(sink); + bt_object_put_ref(src); + bt_object_put_ref(conn); + bt_object_put_ref(src_def_port); + bt_object_put_ref(sink_def_port); } static @@ -975,12 +975,12 @@ void test_sink_removes_port_in_port_connected(void) ok(graph_ports_disconnected_pos < graph_port_removed_sink_pos, "event order is good (11)"); - bt_put(graph); - bt_put(sink); - bt_put(src); - bt_put(conn); - bt_put(src_def_port); - bt_put(sink_def_port); + bt_object_put_ref(graph); + bt_object_put_ref(sink); + bt_object_put_ref(src); + bt_object_put_ref(conn); + bt_object_put_ref(src_def_port); + bt_object_put_ref(sink_def_port); } static @@ -1097,13 +1097,13 @@ void test_src_adds_port_in_port_connected(void) ok(graph_port_added_src_pos < graph_ports_connected_pos, "event order is good (6)"); - bt_put(graph); - bt_put(sink); - bt_put(src); - bt_put(conn); - bt_put(src_def_port); - bt_put(sink_def_port); - bt_put(src_hello_port); + bt_object_put_ref(graph); + bt_object_put_ref(sink); + bt_object_put_ref(src); + bt_object_put_ref(conn); + bt_object_put_ref(src_def_port); + bt_object_put_ref(sink_def_port); + bt_object_put_ref(src_hello_port); } static @@ -1203,12 +1203,12 @@ void test_simple(void) ok(sink_accept_port_connection_pos < sink_port_connected_pos, "event order is good (4)"); - bt_put(graph); - bt_put(sink); - bt_put(src); - bt_put(conn); - bt_put(src_def_port); - bt_put(sink_def_port); + bt_object_put_ref(graph); + bt_object_put_ref(sink); + bt_object_put_ref(src); + bt_object_put_ref(conn); + bt_object_put_ref(src_def_port); + bt_object_put_ref(sink_def_port); } static @@ -1282,12 +1282,12 @@ void test_src_port_connected_error(void) ok(src_accept_port_connection_pos < src_port_connected_pos, "event order is good (1)"); - bt_put(graph); - bt_put(sink); - bt_put(src); - bt_put(conn); - bt_put(src_def_port); - bt_put(sink_def_port); + bt_object_put_ref(graph); + bt_object_put_ref(sink); + bt_object_put_ref(src); + bt_object_put_ref(conn); + bt_object_put_ref(src_def_port); + bt_object_put_ref(sink_def_port); } static @@ -1384,12 +1384,12 @@ void test_sink_port_connected_error(void) ok(sink_port_connected_pos < src_port_disconnected_pos, "event order is good (3)"); - bt_put(graph); - bt_put(sink); - bt_put(src); - bt_put(conn); - bt_put(src_def_port); - bt_put(sink_def_port); + bt_object_put_ref(graph); + bt_object_put_ref(sink); + bt_object_put_ref(src); + bt_object_put_ref(conn); + bt_object_put_ref(src_def_port); + bt_object_put_ref(sink_def_port); } static @@ -1400,7 +1400,7 @@ void test_empty_graph(void) prepare_test(TEST_EMPTY_GRAPH, "empty graph"); graph = create_graph(); ok(events->len == 0, "empty graph generates no events"); - bt_put(graph); + bt_object_put_ref(graph); } int main(int argc, char **argv) diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index 13f7e8c4..1bcc4db0 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -20,7 +20,7 @@ */ #include -#include +#include #include #include #include @@ -142,8 +142,8 @@ static void test_minimal(const char *plugin_dir) "bt_plugin_get_path() returns the expected path"); ok(bt_plugin_get_component_class_count(plugin) == 0, "bt_plugin_get_component_class_count() returns the expected value"); - bt_put(plugin); - bt_put(plugin_set); + bt_object_put_ref(plugin); + bt_object_put_ref(plugin_set); ok(check_env_var("BT_TEST_PLUGIN_EXIT_CALLED") == 1, "plugin's exit function is called when the plugin is destroyed"); @@ -242,40 +242,40 @@ static void test_sfs(const char *plugin_dir) "bt_component_class_query() receives the expected parameters"); diag("> putting the plugin object here"); - BT_PUT(plugin); + BT_OBJECT_PUT_REF_AND_RESET(plugin); graph = bt_graph_create(); BT_ASSERT(graph); graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink", NULL, &sink_component); ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component, "bt_graph_add_component() still works after the plugin object is destroyed"); - BT_PUT(sink_component); - BT_PUT(source_comp_class); - bt_put(graph); + BT_OBJECT_PUT_REF_AND_RESET(sink_component); + BT_OBJECT_PUT_REF_AND_RESET(source_comp_class); + bt_object_put_ref(graph); graph = bt_graph_create(); BT_ASSERT(graph); graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink", NULL, &sink_component); ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component, "bt_graph_add_component() still works after the source component class object is destroyed"); - BT_PUT(sink_component); - BT_PUT(filter_comp_class); - bt_put(graph); + BT_OBJECT_PUT_REF_AND_RESET(sink_component); + BT_OBJECT_PUT_REF_AND_RESET(filter_comp_class); + bt_object_put_ref(graph); graph = bt_graph_create(); BT_ASSERT(graph); graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink", NULL, &sink_component); ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component, "bt_graph_add_component() still works after the filter component class object is destroyed"); - BT_PUT(sink_comp_class); - BT_PUT(sink_component); + BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class); + BT_OBJECT_PUT_REF_AND_RESET(sink_component); free(sfs_path); - bt_put(graph); - bt_put(plugin_set); - bt_put(results); - bt_put(params); - bt_put(query_exec); + bt_object_put_ref(graph); + bt_object_put_ref(plugin_set); + bt_object_put_ref(results); + bt_object_put_ref(params); + bt_object_put_ref(query_exec); } static void test_create_all_from_dir(const char *plugin_dir) @@ -296,7 +296,7 @@ static void test_create_all_from_dir(const char *plugin_dir) bt_plugin_set_get_plugin_count(plugin_set) == 4, "bt_plugin_create_all_from_dir() returns the expected number of plugin objects"); - bt_put(plugin_set); + bt_object_put_ref(plugin_set); } static void test_find(const char *plugin_dir) @@ -325,7 +325,7 @@ static void test_find(const char *plugin_dir) "bt_plugin_find() succeeds with a plugin name it can find"); ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0, "bt_plugin_find() finds the correct plugin for a given name"); - BT_PUT(plugin); + BT_OBJECT_PUT_REF_AND_RESET(plugin); comp_cls_sink = bt_plugin_find_component_class(NULL, "sink", BT_COMPONENT_CLASS_TYPE_SINK); ok(!comp_cls_sink, "bt_plugin_find_component_class() handles NULL (plugin name)"); @@ -345,8 +345,8 @@ static void test_find(const char *plugin_dir) ok(comp_cls_sink, "bt_plugin_find_component_class() succeeds with another component class name (same plugin)"); ok(strcmp(bt_component_class_get_name(comp_cls_source), "source") == 0, "bt_plugin_find_component_class() returns the appropriate component class (source)"); - BT_PUT(comp_cls_sink); - BT_PUT(comp_cls_source); + BT_OBJECT_PUT_REF_AND_RESET(comp_cls_sink); + BT_OBJECT_PUT_REF_AND_RESET(comp_cls_source); free(plugin_path); } diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index 1452b1ae..39dcd80a 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -105,9 +105,9 @@ static struct bt_field_class *create_integer_struct(void) ret = bt_field_class_structure_append_member(structure, "payload_32", ui32); BT_ASSERT(ret == 0); - BT_PUT(ui8); - BT_PUT(ui16); - BT_PUT(ui32); + BT_OBJECT_PUT_REF_AND_RESET(ui8); + BT_OBJECT_PUT_REF_AND_RESET(ui16); + BT_OBJECT_PUT_REF_AND_RESET(ui32); return structure; } @@ -134,9 +134,9 @@ static struct bt_ctf_field_type *create_writer_integer_struct(void) ret = bt_ctf_field_type_structure_add_field(structure, ui32, "payload_32"); BT_ASSERT(ret == 0); - BT_PUT(ui8); - BT_PUT(ui16); - BT_PUT(ui32); + BT_OBJECT_PUT_REF_AND_RESET(ui8); + BT_OBJECT_PUT_REF_AND_RESET(ui16); + BT_OBJECT_PUT_REF_AND_RESET(ui32); return structure; } @@ -162,7 +162,7 @@ static struct bt_event_class *create_simple_event(struct bt_stream_class *sc, BT_ASSERT(payload); ret = bt_event_class_set_payload_field_class(event, payload); BT_ASSERT(ret == 0); - BT_PUT(payload); + BT_OBJECT_PUT_REF_AND_RESET(payload); return event; } @@ -197,8 +197,8 @@ static struct bt_event_class *create_complex_event(struct bt_stream_class *sc, BT_ASSERT(ret == 0); ret = bt_event_class_set_payload_field_class(event, outer); BT_ASSERT(ret == 0); - BT_PUT(inner); - BT_PUT(outer); + BT_OBJECT_PUT_REF_AND_RESET(inner); + BT_OBJECT_PUT_REF_AND_RESET(outer); return event; } @@ -219,7 +219,7 @@ static void set_stream_class_field_classes( ret = bt_field_class_structure_append_member(packet_context_type, "packet_size", fc); BT_ASSERT(ret == 0); - bt_put(fc); + bt_object_put_ref(fc); fc = bt_field_class_unsigned_integer_create(); BT_ASSERT(fc); ret = bt_field_class_integer_set_field_value_range(fc, 32); @@ -227,7 +227,7 @@ static void set_stream_class_field_classes( ret = bt_field_class_structure_append_member(packet_context_type, "content_size", fc); BT_ASSERT(ret == 0); - bt_put(fc); + bt_object_put_ref(fc); event_header_type = bt_field_class_structure_create(); BT_ASSERT(event_header_type); fc = bt_field_class_unsigned_integer_create(); @@ -237,15 +237,15 @@ static void set_stream_class_field_classes( ret = bt_field_class_structure_append_member(event_header_type, "id", fc); BT_ASSERT(ret == 0); - bt_put(fc); + bt_object_put_ref(fc); ret = bt_stream_class_set_packet_context_field_class(stream_class, packet_context_type); BT_ASSERT(ret == 0); ret = bt_stream_class_set_event_header_field_class(stream_class, event_header_type); BT_ASSERT(ret == 0); - bt_put(packet_context_type); - bt_put(event_header_type); + bt_object_put_ref(packet_context_type); + bt_object_put_ref(event_header_type); } static void create_sc1(struct bt_trace *trace) @@ -267,9 +267,9 @@ static void create_sc1(struct bt_trace *trace) ok(ret_stream == sc1, "Borrow parent stream SC1 from EC1"); ret_stream = bt_event_class_borrow_stream_class(ec2); ok(ret_stream == sc1, "Borrow parent stream SC1 from EC2"); - BT_PUT(ec1); - BT_PUT(ec2); - BT_PUT(sc1); + BT_OBJECT_PUT_REF_AND_RESET(ec1); + BT_OBJECT_PUT_REF_AND_RESET(ec2); + BT_OBJECT_PUT_REF_AND_RESET(sc1); } static void create_sc2(struct bt_trace *trace) @@ -286,8 +286,8 @@ static void create_sc2(struct bt_trace *trace) ec3 = create_simple_event(sc2, "ec3"); ret_stream = bt_event_class_borrow_stream_class(ec3); ok(ret_stream == sc2, "Borrow parent stream SC2 from EC3"); - BT_PUT(ec3); - BT_PUT(sc2); + BT_OBJECT_PUT_REF_AND_RESET(ec3); + BT_OBJECT_PUT_REF_AND_RESET(sc2); } static void set_trace_packet_header(struct bt_trace *trace) @@ -305,12 +305,12 @@ static void set_trace_packet_header(struct bt_trace *trace) ret = bt_field_class_structure_append_member(packet_header_type, "stream_id", fc); BT_ASSERT(ret == 0); - bt_put(fc); + bt_object_put_ref(fc); ret = bt_trace_set_packet_header_field_class(trace, packet_header_type); BT_ASSERT(ret == 0); - bt_put(packet_header_type); + bt_object_put_ref(packet_header_type); } static struct bt_trace *create_tc1(void) @@ -374,12 +374,12 @@ static void test_example_scenario(void) "Initial EC3 reference count is 0"); /* User A has ownership of the trace. */ - BT_MOVE(user_a.tc, tc1); + BT_OBJECT_MOVE_REF(user_a.tc, tc1); ok(bt_object_get_ref_count((void *) user_a.tc) == 1, "TC1 reference count is 1"); /* User A acquires a reference to SC2 from TC1. */ - user_a.sc = bt_get(bt_trace_borrow_stream_class_by_index(user_a.tc, 1)); + user_a.sc = bt_object_get_ref(bt_trace_borrow_stream_class_by_index(user_a.tc, 1)); ok(user_a.sc, "User A acquires SC2 from TC1"); ok(bt_object_get_ref_count((void *) weak_tc1) == 2, "TC1 reference count is 2"); @@ -387,7 +387,7 @@ static void test_example_scenario(void) "SC2 reference count is 1"); /* User A acquires a reference to EC3 from SC2. */ - user_a.ec = bt_get( + user_a.ec = bt_object_get_ref( bt_stream_class_borrow_event_class_by_index(user_a.sc, 0)); ok(user_a.ec, "User A acquires EC3 from SC2"); ok(bt_object_get_ref_count((void *) weak_tc1) == 2, @@ -399,7 +399,7 @@ static void test_example_scenario(void) /* User A releases its reference to SC2. */ diag("User A releases SC2"); - BT_PUT(user_a.sc); + BT_OBJECT_PUT_REF_AND_RESET(user_a.sc); /* * We keep the pointer to SC2 around to validate its reference * count. @@ -413,7 +413,7 @@ static void test_example_scenario(void) /* User A releases its reference to TC1. */ diag("User A releases TC1"); - BT_PUT(user_a.tc); + BT_OBJECT_PUT_REF_AND_RESET(user_a.tc); /* * We keep the pointer to TC1 around to validate its reference * count. @@ -427,7 +427,7 @@ static void test_example_scenario(void) /* User B acquires a reference to SC1. */ diag("User B acquires a reference to SC1"); - user_b.sc = bt_get(weak_sc1); + user_b.sc = bt_object_get_ref(weak_sc1); ok(bt_object_get_ref_count((void *) weak_tc1) == 2, "TC1 reference count is 2"); ok(bt_object_get_ref_count((void *) weak_sc1) == 1, @@ -435,7 +435,7 @@ static void test_example_scenario(void) /* User C acquires a reference to EC1. */ diag("User C acquires a reference to EC1"); - user_c.ec = bt_get( + user_c.ec = bt_object_get_ref( bt_stream_class_borrow_event_class_by_index(user_b.sc, 0)); ok(bt_object_get_ref_count((void *) weak_ec1) == 1, "EC1 reference count is 1"); @@ -444,7 +444,7 @@ static void test_example_scenario(void) /* User A releases its reference on EC3. */ diag("User A releases its reference on EC3"); - BT_PUT(user_a.ec); + BT_OBJECT_PUT_REF_AND_RESET(user_a.ec); ok(bt_object_get_ref_count((void *) weak_ec3) == 0, "EC3 reference count is 1"); ok(bt_object_get_ref_count((void *) weak_sc2) == 0, @@ -454,7 +454,7 @@ static void test_example_scenario(void) /* User B releases its reference on SC1. */ diag("User B releases its reference on SC1"); - BT_PUT(user_b.sc); + BT_OBJECT_PUT_REF_AND_RESET(user_b.sc); ok(bt_object_get_ref_count((void *) weak_sc1) == 1, "SC1 reference count is 1"); @@ -476,7 +476,7 @@ static void test_example_scenario(void) "EC3 reference count is 0"); /* Reclaim last reference held by User C. */ - BT_PUT(user_c.ec); + BT_OBJECT_PUT_REF_AND_RESET(user_c.ec); } static void create_writer_user_full(struct writer_user *user) @@ -507,7 +507,7 @@ static void create_writer_user_full(struct writer_user *user) BT_ASSERT(!ret); ret = bt_ctf_stream_class_set_clock(user->sc, clock); BT_ASSERT(!ret); - BT_PUT(clock); + BT_OBJECT_PUT_REF_AND_RESET(clock); user->stream = bt_ctf_writer_create_stream(user->writer, user->sc); BT_ASSERT(user->stream); user->ec = bt_ctf_event_class_create("ec"); @@ -515,7 +515,7 @@ static void create_writer_user_full(struct writer_user *user) ft = create_writer_integer_struct(); BT_ASSERT(ft); ret = bt_ctf_event_class_set_payload_field_type(user->ec, ft); - BT_PUT(ft); + BT_OBJECT_PUT_REF_AND_RESET(ft); BT_ASSERT(!ret); ret = bt_ctf_stream_class_add_event_class(user->sc, user->ec); BT_ASSERT(!ret); @@ -525,17 +525,17 @@ static void create_writer_user_full(struct writer_user *user) BT_ASSERT(field); ret = bt_ctf_field_integer_unsigned_set_value(field, 10); BT_ASSERT(!ret); - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); field = bt_ctf_event_get_payload(user->event, "payload_16"); BT_ASSERT(field); ret = bt_ctf_field_integer_unsigned_set_value(field, 20); BT_ASSERT(!ret); - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); field = bt_ctf_event_get_payload(user->event, "payload_32"); BT_ASSERT(field); ret = bt_ctf_field_integer_unsigned_set_value(field, 30); BT_ASSERT(!ret); - BT_PUT(field); + BT_OBJECT_PUT_REF_AND_RESET(field); ret = bt_ctf_stream_append_event(user->stream, user->event); BT_ASSERT(!ret); recursive_rmdir(trace_path); @@ -563,7 +563,7 @@ static void test_put_order_put_objects(size_t *array, size_t size) void *obj = objects[array[i]]; printf("%s", writer_user_names[array[i]]); - BT_PUT(obj); + BT_OBJECT_PUT_REF_AND_RESET(obj); if (i < size - 1) { printf(" -> "); -- 2.34.1