From c5b9b4417bedfbec9b5dd23b8395ccdd4eeffc44 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 7 Dec 2018 17:33:41 -0500 Subject: [PATCH] lib: make public reference count functions have strict types Instead of having generic bt_object_get_ref() and bt_object_put_ref() accepting `const void *`, have one pair of such functions for each shared object API. This can help catch reference count bugs (not putting or getting the correct object type) and makes it illegal at build time to get or put a unique object's reference. Each shared object API also has its own BT_X_PUT_REF_AND_RESET() and BT_X_MOVE_REF() macros. bt_object_get_ref() and bt_object_put_ref() are now internal and only used by the library's implementation. Signed-off-by: Philippe Proulx --- cli/babeltrace-cfg-cli-args-connect.c | 4 +- cli/babeltrace-cfg-cli-args-default.c | 2 +- cli/babeltrace-cfg-cli-args.c | 46 +-- cli/babeltrace-cfg-cli-args.h | 1 - cli/babeltrace-cfg.h | 1 - cli/babeltrace.c | 48 +-- include/Makefile.am | 1 - include/babeltrace/assert-pre-internal.h | 1 + include/babeltrace/babeltrace.h | 1 - .../babeltrace/graph/component-class-const.h | 19 + .../graph/component-class-filter-const.h | 19 + .../graph/component-class-sink-const.h | 19 + .../graph/component-class-source-const.h | 19 + include/babeltrace/graph/component-const.h | 17 + .../babeltrace/graph/component-filter-const.h | 19 + .../babeltrace/graph/component-sink-const.h | 19 + .../babeltrace/graph/component-source-const.h | 19 + include/babeltrace/graph/connection-const.h | 17 + include/babeltrace/graph/const-notification.h | 60 ---- include/babeltrace/graph/graph-const.h | 17 + include/babeltrace/graph/notification-const.h | 17 + include/babeltrace/graph/port-const.h | 17 + include/babeltrace/graph/port-input-const.h | 17 + include/babeltrace/graph/port-output-const.h | 17 + .../graph/port-output-notification-iterator.h | 19 + .../babeltrace/graph/query-executor-const.h | 19 + ...mponent-port-input-notification-iterator.h | 19 + include/babeltrace/object-internal.h | 47 +++ include/babeltrace/object.h | 214 ----------- include/babeltrace/plugin/plugin-const.h | 17 + include/babeltrace/plugin/plugin-internal.h | 1 - include/babeltrace/plugin/plugin-set-const.h | 17 + .../babeltrace/trace-ir/clock-class-const.h | 17 + .../babeltrace/trace-ir/event-class-const.h | 17 + .../babeltrace/trace-ir/field-class-const.h | 18 + .../babeltrace/trace-ir/field-path-const.h | 17 + include/babeltrace/trace-ir/packet-const.h | 17 + .../babeltrace/trace-ir/stream-class-const.h | 19 +- include/babeltrace/trace-ir/stream-const.h | 17 + .../babeltrace/trace-ir/trace-class-const.h | 17 + include/babeltrace/trace-ir/trace-const.h | 17 + include/babeltrace/value-const.h | 17 + lib/Makefile.am | 1 - lib/graph/component-class-sink-colander.c | 5 +- lib/graph/component-class.c | 53 ++- lib/graph/component-filter.c | 17 +- lib/graph/component-sink.c | 17 +- lib/graph/component-source.c | 17 +- lib/graph/component.c | 15 +- lib/graph/connection.c | 15 +- lib/graph/graph.c | 15 +- lib/graph/iterator.c | 25 +- lib/graph/notification/event.c | 5 +- lib/graph/notification/inactivity.c | 3 +- lib/graph/notification/notification.c | 14 +- lib/graph/notification/packet.c | 1 - lib/graph/notification/stream.c | 1 - lib/graph/port.c | 35 +- lib/graph/query-executor.c | 15 +- lib/lib-logging.c | 2 + lib/object-pool.c | 1 + lib/object.c | 57 --- lib/plugin/plugin-so.c | 4 +- lib/plugin/plugin.c | 25 +- lib/trace-ir/attributes.c | 3 +- lib/trace-ir/clock-class.c | 11 +- lib/trace-ir/clock-value.c | 1 - lib/trace-ir/event-class.c | 11 +- lib/trace-ir/event.c | 3 +- lib/trace-ir/field-class.c | 12 +- lib/trace-ir/field-path.c | 11 +- lib/trace-ir/field.c | 1 - lib/trace-ir/packet.c | 11 +- lib/trace-ir/resolve-field-path.c | 1 - lib/trace-ir/stream-class.c | 11 +- lib/trace-ir/stream.c | 11 +- lib/trace-ir/trace-class.c | 11 +- lib/trace-ir/trace.c | 11 +- lib/trace-ir/utils.c | 1 - lib/value.c | 13 +- plugins/ctf/common/bfcr/bfcr.c | 1 - .../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 | 32 +- plugins/ctf/fs-sink/writer.c | 10 +- plugins/ctf/fs-src/data-stream-file.c | 4 +- plugins/ctf/fs-src/fs.c | 14 +- plugins/ctf/fs-src/metadata.c | 2 +- plugins/ctf/fs-src/query.c | 20 +- plugins/ctf/lttng-live/lttng-live.c | 24 +- plugins/ctf/lttng-live/metadata.c | 2 +- plugins/ctf/lttng-live/viewer-connection.c | 22 +- plugins/libctfcopytrace/clock-fields.c | 16 +- plugins/libctfcopytrace/ctfcopytrace.c | 38 +- plugins/lttng-utils/copy.c | 174 ++++----- plugins/lttng-utils/debug-info.c | 2 +- plugins/lttng-utils/plugin.c | 32 +- plugins/text/dmesg/dmesg.c | 24 +- plugins/text/pretty/pretty.c | 11 +- plugins/utils/counter/counter.c | 9 +- plugins/utils/dummy/dummy.c | 7 +- plugins/utils/muxer/muxer.c | 18 +- plugins/utils/trimmer/copy.c | 18 +- plugins/utils/trimmer/iterator.c | 30 +- plugins/utils/trimmer/trimmer.c | 6 +- .../python-plugin-provider.c | 3 +- tests/lib/test-plugin-plugins/sfs.c | 2 +- tests/lib/test_bt_notification_iterator.c | 46 +-- tests/lib/test_bt_values.c | 98 +++--- tests/lib/test_ctf_writer.c | 333 +++++++++--------- tests/lib/test_graph_topo.c | 46 +-- tests/lib/test_plugin.c | 22 +- tests/lib/test_trace_ir_ref.c | 54 +-- 116 files changed, 1562 insertions(+), 1053 deletions(-) delete mode 100644 include/babeltrace/graph/const-notification.h delete mode 100644 include/babeltrace/object.h delete mode 100644 lib/object.c diff --git a/cli/babeltrace-cfg-cli-args-connect.c b/cli/babeltrace-cfg-cli-args-connect.c index e72ff30e..020fbdcc 100644 --- a/cli/babeltrace-cfg-cli-args-connect.c +++ b/cli/babeltrace-cfg-cli-args-connect.c @@ -584,7 +584,7 @@ static int validate_all_components_connected(struct bt_config *cfg, } end: - bt_object_put_ref(connected_components); + bt_value_put_ref(connected_components); return ret; } @@ -635,7 +635,7 @@ static int validate_no_duplicate_connection(struct bt_config *cfg, } end: - bt_object_put_ref(flat_connection_names); + bt_value_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 d0bfe1e5..27eae102 100644 --- a/cli/babeltrace-cfg-cli-args-default.c +++ b/cli/babeltrace-cfg-cli-args-default.c @@ -61,7 +61,7 @@ error: BT_OBJECT_PUT_REF_AND_RESET(cfg); end: - bt_object_put_ref(initial_plugin_paths); + bt_value_put_ref(initial_plugin_paths); return cfg; } diff --git a/cli/babeltrace-cfg-cli-args.c b/cli/babeltrace-cfg-cli-args.c index 6130947b..d881e75c 100644 --- a/cli/babeltrace-cfg-cli-args.c +++ b/cli/babeltrace-cfg-cli-args.c @@ -417,7 +417,7 @@ success: } end: - BT_OBJECT_PUT_REF_AND_RESET(value); + BT_VALUE_PUT_REF_AND_RESET(value); return ret; } @@ -535,7 +535,7 @@ struct bt_value *bt_value_from_ini(const char *arg, goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(state.params); + BT_VALUE_PUT_REF_AND_RESET(state.params); end: if (state.scanner) { @@ -759,7 +759,7 @@ void bt_config_component_destroy(struct bt_object *obj) g_string_free(bt_config_component->instance_name, TRUE); } - BT_OBJECT_PUT_REF_AND_RESET(bt_config_component->params); + BT_VALUE_PUT_REF_AND_RESET(bt_config_component->params); g_free(bt_config_component); end: @@ -875,7 +875,7 @@ void bt_config_destroy(struct bt_object *obj) goto end; } - BT_OBJECT_PUT_REF_AND_RESET(cfg->plugin_paths); + BT_VALUE_PUT_REF_AND_RESET(cfg->plugin_paths); switch (cfg->command) { case BT_CONFIG_COMMAND_RUN: @@ -1104,7 +1104,7 @@ end: return names; error: - BT_OBJECT_PUT_REF_AND_RESET(names); + BT_VALUE_PUT_REF_AND_RESET(names); if (scanner) { g_scanner_destroy(scanner); } @@ -1177,7 +1177,7 @@ struct bt_value *fields_from_arg(const char *arg) goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(fields); + BT_VALUE_PUT_REF_AND_RESET(fields); end: if (scanner) { @@ -2036,7 +2036,7 @@ struct bt_config *bt_config_query_from_args(int argc, const char *argv[], break; case OPT_PARAMS: { - bt_object_put_ref(params); + bt_value_put_ref(params); params = bt_value_from_arg(arg); if (!params) { printf_err("Invalid format for --params option's argument:\n %s\n", @@ -2127,7 +2127,7 @@ end: poptFreeContext(pc); } - bt_object_put_ref(params); + bt_value_put_ref(params); free(arg); return cfg; } @@ -2503,7 +2503,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], } BT_ASSERT(cur_base_params); - bt_object_put_ref(cur_cfg_comp->params); + bt_value_put_ref(cur_cfg_comp->params); status = bt_value_copy(cur_base_params, &cur_cfg_comp->params); if (status != BT_VALUE_STATUS_OK) { @@ -2534,7 +2534,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], status = bt_value_map_extend(cur_cfg_comp->params, params, ¶ms_to_set); - BT_OBJECT_PUT_REF_AND_RESET(params); + BT_VALUE_PUT_REF_AND_RESET(params); if (status != BT_VALUE_STATUS_OK) { printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n", arg); @@ -2595,7 +2595,7 @@ struct bt_config *bt_config_run_from_args(int argc, const char *argv[], break; } case OPT_RESET_BASE_PARAMS: - BT_OBJECT_PUT_REF_AND_RESET(cur_base_params); + BT_VALUE_PUT_REF_AND_RESET(cur_base_params); cur_base_params = bt_value_map_create(); if (!cur_base_params) { print_err_oom(); @@ -2696,9 +2696,9 @@ end: free(arg); 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); + BT_VALUE_PUT_REF_AND_RESET(cur_base_params); + BT_VALUE_PUT_REF_AND_RESET(instance_names); + BT_VALUE_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_object_put_ref(args->extra_params); + bt_value_put_ref(args->extra_params); } static @@ -3541,7 +3541,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_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params); + BT_VALUE_PUT_REF_AND_RESET(impl_args->extra_params); status = bt_value_copy(base_implicit_ctf_input_args->extra_params, &impl_args->extra_params); if (status != BT_VALUE_STATUS_OK) { @@ -4164,7 +4164,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_object_put_ref(fields); + bt_value_put_ref(fields); if (ret) { goto error; } @@ -4182,7 +4182,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_object_put_ref(names); + bt_value_put_ref(names); if (ret) { goto error; } @@ -4748,8 +4748,8 @@ end: g_ptr_array_free(implicit_ctf_inputs_args, TRUE); } - bt_object_put_ref(run_args); - bt_object_put_ref(all_names); + bt_value_put_ref(run_args); + bt_value_put_ref(all_names); destroy_glist_of_gstring(source_names); destroy_glist_of_gstring(filter_names); destroy_glist_of_gstring(sink_names); @@ -4762,7 +4762,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_object_put_ref(plugin_paths); + bt_value_put_ref(plugin_paths); bt_common_destroy_lttng_live_url_parts(<tng_live_url_parts); return cfg; } @@ -4857,7 +4857,7 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[], goto end; } } else { - bt_object_get_ref(initial_plugin_paths); + bt_value_get_ref(initial_plugin_paths); } if (argc <= 1) { @@ -5019,6 +5019,6 @@ struct bt_config *bt_config_cli_args_create(int argc, const char *argv[], } end: - bt_object_put_ref(initial_plugin_paths); + bt_value_put_ref(initial_plugin_paths); return config; } diff --git a/cli/babeltrace-cfg-cli-args.h b/cli/babeltrace-cfg-cli-args.h index fd222724..ff9a3291 100644 --- a/cli/babeltrace-cfg-cli-args.h +++ b/cli/babeltrace-cfg-cli-args.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/cli/babeltrace-cfg.h b/cli/babeltrace-cfg.h index e7e98372..e8796652 100644 --- a/cli/babeltrace-cfg.h +++ b/cli/babeltrace-cfg.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 537ab44d..3dc37e19 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -165,7 +165,7 @@ int create_the_query_executor(void) static void destroy_the_query_executor(void) { - BT_OBJECT_PUT_REF_AND_RESET(the_query_executor); + BT_QUERY_EXECUTOR_PUT_REF_AND_RESET(the_query_executor); } static @@ -256,7 +256,7 @@ error: end: destroy_the_query_executor(); - bt_object_put_ref(result); + bt_value_put_ref(result); return ret; } @@ -287,7 +287,7 @@ const struct bt_plugin *find_plugin(const char *name) } } - bt_object_get_ref(plugin); + bt_plugin_get_ref(plugin); return plugin; } @@ -312,7 +312,7 @@ const void *find_component_class_from_plugin(const char *plugin_name, comp_class = plugin_borrow_comp_cls_func(plugin, comp_class_name); bt_object_get_ref(comp_class); - BT_OBJECT_PUT_REF_AND_RESET(plugin); + BT_PLUGIN_PUT_REF_AND_RESET(plugin); end: if (BT_LOG_ON_DEBUG) { @@ -777,12 +777,12 @@ void add_to_loaded_plugins(const struct bt_plugin_set *plugin_set) bt_plugin_get_name(plugin), bt_plugin_get_path(plugin), bt_plugin_get_path(loaded_plugin)); - bt_object_put_ref(loaded_plugin); + bt_plugin_put_ref(loaded_plugin); } else { /* Add to global array. */ BT_LOGD("Adding plugin to loaded plugins: plugin-path=\"%s\"", bt_plugin_get_name(plugin)); - bt_object_get_ref(plugin); + bt_plugin_get_ref(plugin); g_ptr_array_add(loaded_plugins, (void *) plugin); } } @@ -831,7 +831,7 @@ int load_dynamic_plugins(const struct bt_value *plugin_paths) } add_to_loaded_plugins(plugin_set); - bt_object_put_ref(plugin_set); + bt_plugin_set_put_ref(plugin_set); } end: return ret; @@ -852,7 +852,7 @@ int load_static_plugins(void) } add_to_loaded_plugins(plugin_set); - bt_object_put_ref(plugin_set); + bt_plugin_set_put_ref(plugin_set); end: return ret; } @@ -995,8 +995,8 @@ failed: ret = -1; end: - bt_object_put_ref(comp_cls); - bt_object_put_ref(results); + bt_component_class_put_ref(comp_cls); + bt_value_put_ref(results); return ret; } @@ -1092,8 +1092,8 @@ int cmd_help(struct bt_config *cfg) needed_comp_cls); end: - bt_object_put_ref(needed_comp_cls); - bt_object_put_ref(plugin); + bt_component_class_put_ref(needed_comp_cls); + bt_plugin_put_ref(plugin); return ret; } @@ -1343,9 +1343,9 @@ error: ret = -1; end: - bt_object_put_ref(results); - bt_object_put_ref(params); - bt_object_put_ref(comp_cls); + bt_value_put_ref(results); + bt_value_put_ref(params); + bt_component_class_put_ref(comp_cls); if (out_stream && out_stream != stdout) { int fclose_ret = fclose(out_stream); @@ -1455,9 +1455,9 @@ failed: bt_common_color_reset()); end: - bt_object_put_ref(results); - bt_object_put_ref(params); - bt_object_put_ref(comp_cls); + bt_value_put_ref(results); + bt_value_put_ref(params); + bt_component_class_put_ref(comp_cls); if (out_stream && out_stream != stdout) { int fclose_ret = fclose(out_stream); @@ -1902,9 +1902,9 @@ error: end: free(intersection_begin); free(intersection_end); - BT_OBJECT_PUT_REF_AND_RESET(trimmer_params); - BT_OBJECT_PUT_REF_AND_RESET(trimmer_class); - BT_OBJECT_PUT_REF_AND_RESET(trimmer); + BT_VALUE_PUT_REF_AND_RESET(trimmer_params); + BT_COMPONENT_CLASS_FILTER_PUT_REF_AND_RESET(trimmer_class); + BT_COMPONENT_FILTER_PUT_REF_AND_RESET(trimmer); return ret; } @@ -2067,7 +2067,7 @@ void cmd_run_ctx_destroy(struct cmd_run_ctx *ctx) ctx->intersections = NULL; } - BT_OBJECT_PUT_REF_AND_RESET(ctx->graph); + BT_GRAPH_PUT_REF_AND_RESET(ctx->graph); the_graph = NULL; ctx->cfg = NULL; } @@ -2370,8 +2370,8 @@ error: path ? path : "(unknown)", bt_common_color_reset()); end: - bt_object_put_ref(query_params); - bt_object_put_ref(query_result); + bt_value_put_ref(query_params); + bt_value_put_ref(query_result); g_free(port_id); g_free(trace_range); return ret; diff --git a/include/Makefile.am b/include/Makefile.am index fa75c7c3..09bfcf75 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -73,7 +73,6 @@ babeltraceincludedir = "$(includedir)/babeltrace" babeltraceinclude_HEADERS = \ babeltrace/babeltrace.h \ babeltrace/logging.h \ - babeltrace/object.h \ babeltrace/property.h \ babeltrace/types.h \ babeltrace/value-const.h \ diff --git a/include/babeltrace/assert-pre-internal.h b/include/babeltrace/assert-pre-internal.h index e56d90ec..3cb08b4c 100644 --- a/include/babeltrace/assert-pre-internal.h +++ b/include/babeltrace/assert-pre-internal.h @@ -36,6 +36,7 @@ * , you also need to use logging * explicitly. */ + #ifndef BABELTRACE_LIB_LOGGING_INTERNAL_H # error Include before this header. #endif diff --git a/include/babeltrace/babeltrace.h b/include/babeltrace/babeltrace.h index a1fb21d9..0d349995 100644 --- a/include/babeltrace/babeltrace.h +++ b/include/babeltrace/babeltrace.h @@ -27,7 +27,6 @@ /* Core API */ #include -#include #include #include #include diff --git a/include/babeltrace/graph/component-class-const.h b/include/babeltrace/graph/component-class-const.h index bfd1b904..59dba54c 100644 --- a/include/babeltrace/graph/component-class-const.h +++ b/include/babeltrace/graph/component-class-const.h @@ -75,6 +75,25 @@ bt_bool bt_component_class_is_sink( BT_COMPONENT_CLASS_TYPE_SINK; } +extern void bt_component_class_get_ref( + const struct bt_component_class *component_class); + +extern void bt_component_class_put_ref( + const struct bt_component_class *component_class); + +#define BT_COMPONENT_CLASS_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_class_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_CLASS_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_class_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-class-filter-const.h b/include/babeltrace/graph/component-class-filter-const.h index 9430899e..3fa6dca0 100644 --- a/include/babeltrace/graph/component-class-filter-const.h +++ b/include/babeltrace/graph/component-class-filter-const.h @@ -39,6 +39,25 @@ bt_component_class_filter_as_component_class_const( return (const void *) comp_cls_filter; } +extern void bt_component_class_filter_get_ref( + const struct bt_component_class_filter *component_class_filter); + +extern void bt_component_class_filter_put_ref( + const struct bt_component_class_filter *component_class_filter); + +#define BT_COMPONENT_CLASS_FILTER_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_class_filter_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_CLASS_FILTER_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_class_filter_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-class-sink-const.h b/include/babeltrace/graph/component-class-sink-const.h index 613b9163..4cfa7b7a 100644 --- a/include/babeltrace/graph/component-class-sink-const.h +++ b/include/babeltrace/graph/component-class-sink-const.h @@ -39,6 +39,25 @@ bt_component_class_sink_as_component_class_const( return (const void *) comp_cls_sink; } +extern void bt_component_class_sink_get_ref( + const struct bt_component_class_sink *component_class_sink); + +extern void bt_component_class_sink_put_ref( + const struct bt_component_class_sink *component_class_sink); + +#define BT_COMPONENT_CLASS_SINK_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_class_sink_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_CLASS_SINK_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_class_sink_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-class-source-const.h b/include/babeltrace/graph/component-class-source-const.h index 29815718..aaf6d658 100644 --- a/include/babeltrace/graph/component-class-source-const.h +++ b/include/babeltrace/graph/component-class-source-const.h @@ -39,6 +39,25 @@ bt_component_class_source_as_component_class_const( return (const void *) comp_cls_source; } +extern void bt_component_class_source_get_ref( + const struct bt_component_class_source *component_class_source); + +extern void bt_component_class_source_put_ref( + const struct bt_component_class_source *component_class_source); + +#define BT_COMPONENT_CLASS_SOURCE_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_class_source_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_CLASS_SOURCE_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_class_source_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-const.h b/include/babeltrace/graph/component-const.h index 1877988c..a737d0d5 100644 --- a/include/babeltrace/graph/component-const.h +++ b/include/babeltrace/graph/component-const.h @@ -84,6 +84,23 @@ bt_bool bt_component_is_sink(const struct bt_component *component) extern bt_bool bt_component_graph_is_canceled( const struct bt_component *component); +extern void bt_component_get_ref(const struct bt_component *component); + +extern void bt_component_put_ref(const struct bt_component *component); + +#define BT_COMPONENT_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-filter-const.h b/include/babeltrace/graph/component-filter-const.h index 4cc119e1..5da4869b 100644 --- a/include/babeltrace/graph/component-filter-const.h +++ b/include/babeltrace/graph/component-filter-const.h @@ -64,6 +64,25 @@ extern const struct bt_port_output * bt_component_filter_borrow_output_port_by_index_const( const struct bt_component_filter *component, uint64_t index); +extern void bt_component_filter_get_ref( + const struct bt_component_filter *component_filter); + +extern void bt_component_filter_put_ref( + const struct bt_component_filter *component_filter); + +#define BT_COMPONENT_FILTER_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_filter_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_FILTER_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_filter_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-sink-const.h b/include/babeltrace/graph/component-sink-const.h index 0afeb514..bda32846 100644 --- a/include/babeltrace/graph/component-sink-const.h +++ b/include/babeltrace/graph/component-sink-const.h @@ -52,6 +52,25 @@ extern const struct bt_port_input * bt_component_sink_borrow_input_port_by_index_const( const struct bt_component_sink *component, uint64_t index); +extern void bt_component_sink_get_ref( + const struct bt_component_sink *component_sink); + +extern void bt_component_sink_put_ref( + const struct bt_component_sink *component_sink); + +#define BT_COMPONENT_SINK_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_sink_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_SINK_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_sink_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/component-source-const.h b/include/babeltrace/graph/component-source-const.h index daaaa4ef..7c16d03e 100644 --- a/include/babeltrace/graph/component-source-const.h +++ b/include/babeltrace/graph/component-source-const.h @@ -52,6 +52,25 @@ extern const struct bt_port_output * bt_component_source_borrow_output_port_by_index_const( const struct bt_component_source *component, uint64_t index); +extern void bt_component_source_get_ref( + const struct bt_component_source *component_source); + +extern void bt_component_source_put_ref( + const struct bt_component_source *component_source); + +#define BT_COMPONENT_SOURCE_PUT_REF_AND_RESET(_var) \ + do { \ + bt_component_source_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_COMPONENT_SOURCE_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_component_source_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/connection-const.h b/include/babeltrace/graph/connection-const.h index 59959063..52f605e0 100644 --- a/include/babeltrace/graph/connection-const.h +++ b/include/babeltrace/graph/connection-const.h @@ -43,6 +43,23 @@ extern const struct bt_port_output *bt_connection_borrow_upstream_port_const( extern bt_bool bt_connection_is_ended(const struct bt_connection *connection); +extern void bt_connection_get_ref(const struct bt_connection *connection); + +extern void bt_connection_put_ref(const struct bt_connection *connection); + +#define BT_CONNECTION_PUT_REF_AND_RESET(_var) \ + do { \ + bt_connection_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_CONNECTION_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_connection_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/const-notification.h b/include/babeltrace/graph/const-notification.h deleted file mode 100644 index 335a1c14..00000000 --- a/include/babeltrace/graph/const-notification.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef BABELTRACE_GRAPH_NOTIFICATION_CONST_H -#define BABELTRACE_GRAPH_NOTIFICATION_CONST_H - -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright 2015 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -struct bt_notification; - -typedef struct bt_notification **bt_notification_array; - -/** - * Notification types. Unhandled notification types should be ignored. - */ -enum bt_notification_type { - BT_NOTIFICATION_TYPE_EVENT = 0, - BT_NOTIFICATION_TYPE_INACTIVITY = 1, - BT_NOTIFICATION_TYPE_STREAM_BEGINNING = 2, - BT_NOTIFICATION_TYPE_STREAM_END = 3, - BT_NOTIFICATION_TYPE_PACKET_BEGINNING = 4, - BT_NOTIFICATION_TYPE_PACKET_END = 5, -}; - -/** - * Get a notification's type. - * - * @param notification Notification instance - * @returns One of #bt_notification_type - */ -extern enum bt_notification_type bt_notification_get_type( - const struct bt_notification *notification); - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_NOTIFICATION_CONST_H */ diff --git a/include/babeltrace/graph/graph-const.h b/include/babeltrace/graph/graph-const.h index fe96ee71..c920209c 100644 --- a/include/babeltrace/graph/graph-const.h +++ b/include/babeltrace/graph/graph-const.h @@ -46,6 +46,23 @@ enum bt_graph_status { extern bt_bool bt_graph_is_canceled(const struct bt_graph *graph); +extern void bt_graph_get_ref(const struct bt_graph *graph); + +extern void bt_graph_put_ref(const struct bt_graph *graph); + +#define BT_GRAPH_PUT_REF_AND_RESET(_var) \ + do { \ + bt_graph_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_GRAPH_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_graph_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/notification-const.h b/include/babeltrace/graph/notification-const.h index 47e2f606..a513c0c6 100644 --- a/include/babeltrace/graph/notification-const.h +++ b/include/babeltrace/graph/notification-const.h @@ -53,6 +53,23 @@ enum bt_notification_type { extern enum bt_notification_type bt_notification_get_type( const struct bt_notification *notification); +extern void bt_notification_get_ref(const struct bt_notification *notification); + +extern void bt_notification_put_ref(const struct bt_notification *notification); + +#define BT_NOTIFICATION_PUT_REF_AND_RESET(_var) \ + do { \ + bt_notification_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_NOTIFICATION_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_notification_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/port-const.h b/include/babeltrace/graph/port-const.h index 414c5ccd..826ab02b 100644 --- a/include/babeltrace/graph/port-const.h +++ b/include/babeltrace/graph/port-const.h @@ -66,6 +66,23 @@ bt_bool bt_port_is_output(const struct bt_port *port) return bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT; } +extern void bt_port_get_ref(const struct bt_port *port); + +extern void bt_port_put_ref(const struct bt_port *port); + +#define BT_PORT_PUT_REF_AND_RESET(_var) \ + do { \ + bt_port_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PORT_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_port_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/port-input-const.h b/include/babeltrace/graph/port-input-const.h index d23fd558..1f13de9d 100644 --- a/include/babeltrace/graph/port-input-const.h +++ b/include/babeltrace/graph/port-input-const.h @@ -40,6 +40,23 @@ const struct bt_port *bt_port_input_as_port_const( return (const void *) port_input; } +extern void bt_port_input_get_ref(const struct bt_port_input *port_input); + +extern void bt_port_input_put_ref(const struct bt_port_input *port_input); + +#define BT_PORT_INPUT_PUT_REF_AND_RESET(_var) \ + do { \ + bt_port_input_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PORT_INPUT_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_port_input_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/port-output-const.h b/include/babeltrace/graph/port-output-const.h index 898bdac6..d13c7395 100644 --- a/include/babeltrace/graph/port-output-const.h +++ b/include/babeltrace/graph/port-output-const.h @@ -40,6 +40,23 @@ const struct bt_port *bt_port_output_as_port_const( return (const void *) port_output; } +extern void bt_port_output_get_ref(const struct bt_port_output *port_output); + +extern void bt_port_output_put_ref(const struct bt_port_output *port_output); + +#define BT_PORT_OUTPUT_PUT_REF_AND_RESET(_var) \ + do { \ + bt_port_output_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PORT_OUTPUT_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_port_output_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/port-output-notification-iterator.h b/include/babeltrace/graph/port-output-notification-iterator.h index a13d59e3..dfe5a3f4 100644 --- a/include/babeltrace/graph/port-output-notification-iterator.h +++ b/include/babeltrace/graph/port-output-notification-iterator.h @@ -60,6 +60,25 @@ bt_port_output_notification_iterator_next( struct bt_port_output_notification_iterator *iterator, bt_notification_array_const *notifs, uint64_t *count); +extern void bt_port_output_notification_iterator_get_ref( + const struct bt_port_output_notification_iterator *port_output_notification_iterator); + +extern void bt_port_output_notification_iterator_put_ref( + const struct bt_port_output_notification_iterator *port_output_notification_iterator); + +#define BT_PORT_OUTPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(_var) \ + do { \ + bt_port_output_notification_iterator_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PORT_OUTPUT_NOTIFICATION_ITERATOR_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_port_output_notification_iterator_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/query-executor-const.h b/include/babeltrace/graph/query-executor-const.h index 7da47da0..d2e846ce 100644 --- a/include/babeltrace/graph/query-executor-const.h +++ b/include/babeltrace/graph/query-executor-const.h @@ -47,6 +47,25 @@ extern bt_bool bt_query_executor_is_canceled( const struct bt_query_executor *query_executor); +extern void bt_query_executor_get_ref( + const struct bt_query_executor *query_executor); + +extern void bt_query_executor_put_ref( + const struct bt_query_executor *query_executor); + +#define BT_QUERY_EXECUTOR_PUT_REF_AND_RESET(_var) \ + do { \ + bt_query_executor_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_QUERY_EXECUTOR_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_query_executor_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/graph/self-component-port-input-notification-iterator.h b/include/babeltrace/graph/self-component-port-input-notification-iterator.h index d79f1bc0..45f7e194 100644 --- a/include/babeltrace/graph/self-component-port-input-notification-iterator.h +++ b/include/babeltrace/graph/self-component-port-input-notification-iterator.h @@ -61,6 +61,25 @@ bt_self_component_port_input_notification_iterator_next( struct bt_self_component_port_input_notification_iterator *iterator, bt_notification_array_const *notifs, uint64_t *count); +extern void bt_self_component_port_input_notification_iterator_get_ref( + const struct bt_self_component_port_input_notification_iterator *self_component_port_input_notification_iterator); + +extern void bt_self_component_port_input_notification_iterator_put_ref( + const struct bt_self_component_port_input_notification_iterator *self_component_port_input_notification_iterator); + +#define BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(_var) \ + do { \ + bt_self_component_port_input_notification_iterator_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_self_component_port_input_notification_iterator_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/object-internal.h b/include/babeltrace/object-internal.h index 1420d9fe..00f48ef6 100644 --- a/include/babeltrace/object-internal.h +++ b/include/babeltrace/object-internal.h @@ -324,4 +324,51 @@ void bt_object_put_no_null_check(const void *c_obj) } } +static inline +void bt_object_get_ref(const void *ptr) +{ + struct bt_object *obj = (void *) ptr; + + if (unlikely(!obj)) { + return; + } + +#ifdef BT_ASSERT_PRE + BT_ASSERT_PRE(obj->is_shared, "Object is not shared: %!+O", obj); +#endif + + bt_object_get_no_null_check(obj); +} + +static inline +void bt_object_put_ref(const void *ptr) +{ + struct bt_object *obj = (void *) ptr; + + if (unlikely(!obj)) { + return; + } + +#ifdef BT_ASSERT_PRE + BT_ASSERT_PRE(obj->is_shared, "Object is not shared: %!+O", obj); + BT_ASSERT_PRE(bt_object_get_ref_count(obj) > 0, + "Decrementing a reference count set to 0: %!+O", ptr); +#endif + + bt_object_put_no_null_check(obj); +} + +#define BT_OBJECT_PUT_REF_AND_RESET(_var) \ + do { \ + bt_object_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_OBJECT_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_object_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #endif /* BABELTRACE_OBJECT_INTERNAL_H */ diff --git a/include/babeltrace/object.h b/include/babeltrace/object.h deleted file mode 100644 index 96506d8f..00000000 --- a/include/babeltrace/object.h +++ /dev/null @@ -1,214 +0,0 @@ -#ifndef BABELTRACE_OBJECT_H -#define BABELTRACE_OBJECT_H - -/* - * Copyright (c) 2015-2018 Philippe Proulx - * Copyright (c) 2015 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** -@defgroup refs Reference counting management -@ingroup apiref -@brief Common reference counting management for all Babeltrace objects. - -@code -#include -@endcode - -The macros and functions of this module are everything that is needed -to handle the reference counting of -Babeltrace objects. - -Any Babeltrace object can be shared by multiple owners thanks to -reference -counting. - -The Babeltrace C API complies with the following key principles: - -1. When you call an API function which accepts a Babeltrace object - pointer as a parameter, the API function borrows the - reference for the duration of the function. - - @image html ref-count-user-calls.png - - The API function can also get a new reference if the system needs a - more persistent reference, but the ownership is never - transferred from the caller to the API function. - - In other words, the caller still owns the object after calling any - API function: no function "steals" the user's reference (except - 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 - owner of the object. - - @image html ref-count-api-returns.png - - It is your responsibility to discard the object when you don't - need it anymore with bt_object_put_ref(). - - For example, see bt_value_array_get(). - -3. A Babeltrace object pointer received as a parameter in a user - 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_object_get_ref() on the pointer. - - @image html ref-count-callback.png - - For example, see bt_value_map_foreach_entry(). - -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_OBJECT_MOVE_REF() instead of performing manual reference moves between -variables. - -@file -@brief Reference counting management macros and functions. -@sa refs - -@addtogroup refs -@{ -*/ - -/** -@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_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_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 - can be \c NULL). - -@post If \p _var does not contain \p NULL, - its reference count is decremented. -@post \p _var contains \c NULL. - -@sa BT_OBJECT_MOVE_REF(): Transfers the ownership of a Babeltrace object from a - variable to another. -*/ -#define BT_OBJECT_PUT_REF_AND_RESET(_var) \ - do { \ - bt_object_put_ref(_var); \ - (_var) = NULL; \ - } while (0) - -/** -@brief Transfers the ownership of a Babeltrace object from a variable - named \p _var_src to a variable named \p _var_dst. - -This macro implements the following common pattern: - - 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 - decrementation of \p _var_src. - -@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_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 - either the address of a Babeltrace object to - put first, or \c NULL. -@param[in,out] _var_src Name of the source variable, containing - either the address of a Babeltrace object to - move, or \c NULL. - -@pre If \p _var_dst and \p _var_src contain the same - value which is not \c NULL, this object's reference - count is greater than 1. -@post If \c _var_dst is not \c NULL, its reference - count is decremented. -@post \p _var_dst is equal to the value of \p _var_src \em before - you called this macro. -@post \p _var_src is \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_OBJECT_MOVE_REF(_var_dst, _var_src) \ - do { \ - bt_object_put_ref(_var_dst); \ - (_var_dst) = (_var_src); \ - (_var_src) = NULL; \ - } while (0) - -/** -@brief Increments the reference count of the Babeltrace object \p obj. - -@param[in] obj Babeltrace object of which to get a new reference - (can be \c NULL). -@returns \p obj - -@post If \c obj is not \c NULL, its reference - count is incremented. - -@sa bt_object_put_ref(): Decrements the reference count of a Babeltrace object. -*/ -void bt_object_get_ref(const void *obj); - -/** -@brief Decrements the reference count of the Babeltrace object - \p obj. - -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_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 - (can be \c NULL). - -@post If \c obj is not \c NULL, its reference - count is decremented. - -@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_object_get_ref(): Increments the reference count of a Babeltrace object. -*/ -void bt_object_put_ref(const void *obj); - -/** -@} -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_OBJECT_H */ diff --git a/include/babeltrace/plugin/plugin-const.h b/include/babeltrace/plugin/plugin-const.h index 4bf3564c..ad0b454d 100644 --- a/include/babeltrace/plugin/plugin-const.h +++ b/include/babeltrace/plugin/plugin-const.h @@ -121,6 +121,23 @@ extern const struct bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_name_const( const struct bt_plugin *plugin, const char *name); +extern void bt_plugin_get_ref(const struct bt_plugin *plugin); + +extern void bt_plugin_put_ref(const struct bt_plugin *plugin); + +#define BT_PLUGIN_PUT_REF_AND_RESET(_var) \ + do { \ + bt_plugin_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PLUGIN_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_plugin_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/plugin/plugin-internal.h b/include/babeltrace/plugin/plugin-internal.h index 02b74742..65926c0b 100644 --- a/include/babeltrace/plugin/plugin-internal.h +++ b/include/babeltrace/plugin/plugin-internal.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/include/babeltrace/plugin/plugin-set-const.h b/include/babeltrace/plugin/plugin-set-const.h index 66e06225..53f8c24a 100644 --- a/include/babeltrace/plugin/plugin-set-const.h +++ b/include/babeltrace/plugin/plugin-set-const.h @@ -39,6 +39,23 @@ extern uint64_t bt_plugin_set_get_plugin_count( extern const struct bt_plugin *bt_plugin_set_borrow_plugin_by_index_const( const struct bt_plugin_set *plugin_set, uint64_t index); +extern void bt_plugin_set_get_ref(const struct bt_plugin_set *plugin_set); + +extern void bt_plugin_set_put_ref(const struct bt_plugin_set *plugin_set); + +#define BT_PLUGIN_SET_PUT_REF_AND_RESET(_var) \ + do { \ + bt_plugin_set_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PLUGIN_SET_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_plugin_set_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/clock-class-const.h b/include/babeltrace/trace-ir/clock-class-const.h index 3032b316..0a0cecf8 100644 --- a/include/babeltrace/trace-ir/clock-class-const.h +++ b/include/babeltrace/trace-ir/clock-class-const.h @@ -63,6 +63,23 @@ extern int bt_clock_class_cycles_to_ns_from_origin( const struct bt_clock_class *clock_class, uint64_t cycles, int64_t *ns_from_origin); +extern void bt_clock_class_get_ref(const struct bt_clock_class *clock_class); + +extern void bt_clock_class_put_ref(const struct bt_clock_class *clock_class); + +#define BT_CLOCK_CLASS_PUT_REF_AND_RESET(_var) \ + do { \ + bt_clock_class_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_CLOCK_CLASS_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_clock_class_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/event-class-const.h b/include/babeltrace/trace-ir/event-class-const.h index 39d025f6..2cc9d793 100644 --- a/include/babeltrace/trace-ir/event-class-const.h +++ b/include/babeltrace/trace-ir/event-class-const.h @@ -80,6 +80,23 @@ bt_event_class_borrow_specific_context_field_class( extern const struct bt_field_class *bt_event_class_borrow_payload_field_class( const struct bt_event_class *event_class); +extern void bt_event_class_get_ref(const struct bt_event_class *event_class); + +extern void bt_event_class_put_ref(const struct bt_event_class *event_class); + +#define BT_EVENT_CLASS_PUT_REF_AND_RESET(_var) \ + do { \ + bt_event_class_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_EVENT_CLASS_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_event_class_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/field-class-const.h b/include/babeltrace/trace-ir/field-class-const.h index 3e0e16e6..3f902ceb 100644 --- a/include/babeltrace/trace-ir/field-class-const.h +++ b/include/babeltrace/trace-ir/field-class-const.h @@ -158,6 +158,24 @@ bt_field_class_variant_borrow_option_field_class_by_name_const( const struct bt_field_class *field_class, const char *name); +extern void bt_field_class_get_ref(const struct bt_field_class *field_class); + +extern void bt_field_class_put_ref(const struct bt_field_class *field_class); + +#define BT_FIELD_CLASS_PUT_REF_AND_RESET(_var) \ + do { \ + bt_field_class_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_FIELD_CLASS_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_field_class_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/field-path-const.h b/include/babeltrace/trace-ir/field-path-const.h index a832bc4d..066bc456 100644 --- a/include/babeltrace/trace-ir/field-path-const.h +++ b/include/babeltrace/trace-ir/field-path-const.h @@ -52,6 +52,23 @@ extern uint64_t bt_field_path_get_index_count( extern uint64_t bt_field_path_get_index_by_index( const struct bt_field_path *field_path, uint64_t index); +extern void bt_field_path_get_ref(const struct bt_field_path *field_path); + +extern void bt_field_path_put_ref(const struct bt_field_path *field_path); + +#define BT_FIELD_PATH_PUT_REF_AND_RESET(_var) \ + do { \ + bt_field_path_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_FIELD_PATH_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_field_path_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/packet-const.h b/include/babeltrace/trace-ir/packet-const.h index a59324fc..3aee95ec 100644 --- a/include/babeltrace/trace-ir/packet-const.h +++ b/include/babeltrace/trace-ir/packet-const.h @@ -73,6 +73,23 @@ extern enum bt_property_availability bt_packet_get_packet_counter_snapshot( const struct bt_packet *packet, uint64_t *value); +extern void bt_packet_get_ref(const struct bt_packet *packet); + +extern void bt_packet_put_ref(const struct bt_packet *packet); + +#define BT_PACKET_PUT_REF_AND_RESET(_var) \ + do { \ + bt_packet_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PACKET_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_packet_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/stream-class-const.h b/include/babeltrace/trace-ir/stream-class-const.h index 8452c56c..b740b936 100644 --- a/include/babeltrace/trace-ir/stream-class-const.h +++ b/include/babeltrace/trace-ir/stream-class-const.h @@ -39,7 +39,7 @@ extern "C" { struct bt_trace_class; struct bt_stream_class; struct bt_event_class; -struct bt_clock_class; +struct bt_stream_class; struct bt_event_header_field; struct bt_packet_context_field; @@ -100,6 +100,23 @@ extern bt_bool bt_stream_class_packets_have_default_beginning_clock_value( extern bt_bool bt_stream_class_packets_have_default_end_clock_value( const struct bt_stream_class *stream_class); +extern void bt_stream_class_get_ref(const struct bt_stream_class *stream_class); + +extern void bt_stream_class_put_ref(const struct bt_stream_class *stream_class); + +#define BT_STREAM_CLASS_PUT_REF_AND_RESET(_var) \ + do { \ + bt_stream_class_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_STREAM_CLASS_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_stream_class_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/stream-const.h b/include/babeltrace/trace-ir/stream-const.h index e204f4c9..328441c8 100644 --- a/include/babeltrace/trace-ir/stream-const.h +++ b/include/babeltrace/trace-ir/stream-const.h @@ -47,6 +47,23 @@ extern const char *bt_stream_get_name(const struct bt_stream *stream); extern uint64_t bt_stream_get_id(const struct bt_stream *stream); +extern void bt_stream_get_ref(const struct bt_stream *stream); + +extern void bt_stream_put_ref(const struct bt_stream *stream); + +#define BT_STREAM_PUT_REF_AND_RESET(_var) \ + do { \ + bt_stream_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_STREAM_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_stream_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/trace-class-const.h b/include/babeltrace/trace-ir/trace-class-const.h index 539e1f62..179d3ce6 100644 --- a/include/babeltrace/trace-ir/trace-class-const.h +++ b/include/babeltrace/trace-ir/trace-class-const.h @@ -75,6 +75,23 @@ bt_trace_class_borrow_stream_class_by_index_const( extern const struct bt_stream_class *bt_trace_class_borrow_stream_class_by_id_const( const struct bt_trace_class *trace_class, uint64_t id); +extern void bt_trace_class_get_ref(const struct bt_trace_class *trace_class); + +extern void bt_trace_class_put_ref(const struct bt_trace_class *trace_class); + +#define BT_TRACE_CLASS_PUT_REF_AND_RESET(_var) \ + do { \ + bt_trace_class_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_TRACE_CLASS_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_trace_class_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/trace-ir/trace-const.h b/include/babeltrace/trace-ir/trace-const.h index d5987801..ba629e05 100644 --- a/include/babeltrace/trace-ir/trace-const.h +++ b/include/babeltrace/trace-ir/trace-const.h @@ -71,6 +71,23 @@ extern int bt_trace_add_is_static_listener(const struct bt_trace *trace, extern int bt_trace_remove_is_static_listener(const struct bt_trace *trace, uint64_t listener_id); +extern void bt_trace_get_ref(const struct bt_trace *trace); + +extern void bt_trace_put_ref(const struct bt_trace *trace); + +#define BT_TRACE_PUT_REF_AND_RESET(_var) \ + do { \ + bt_trace_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_TRACE_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_trace_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/include/babeltrace/value-const.h b/include/babeltrace/value-const.h index 1b335c45..a1bf532e 100644 --- a/include/babeltrace/value-const.h +++ b/include/babeltrace/value-const.h @@ -164,6 +164,23 @@ extern enum bt_value_status bt_value_map_extend( const struct bt_value *extension_map_obj, struct bt_value **extended_map_obj); +extern void bt_value_get_ref(const struct bt_value *value); + +extern void bt_value_put_ref(const struct bt_value *value); + +#define BT_VALUE_PUT_REF_AND_RESET(_var) \ + do { \ + bt_value_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_VALUE_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_value_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index 01187650..5665b013 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,7 +5,6 @@ lib_LTLIBRARIES = libbabeltrace.la libbabeltrace-ctf.la libbabeltrace_la_SOURCES = \ babeltrace.c \ value.c \ - object.c \ lib-logging.c \ logging.c \ object-pool.c diff --git a/lib/graph/component-class-sink-colander.c b/lib/graph/component-class-sink-colander.c index 6161244b..58217675 100644 --- a/lib/graph/component-class-sink-colander.c +++ b/lib/graph/component-class-sink-colander.c @@ -23,14 +23,15 @@ #define BT_LOG_TAG "COLANDER" #include -#include +#include +#include +#include #include #include #include #include #include #include -#include #include static diff --git a/lib/graph/component-class.c b/lib/graph/component-class.c index 57ade14d..12a3eec0 100644 --- a/lib/graph/component-class.c +++ b/lib/graph/component-class.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "COMP-CLASS" #include +#include +#include #include #include #include @@ -34,10 +36,7 @@ #include #include #include -#include #include -#include -#include #include #define BT_ASSERT_PRE_COMP_CLS_HOT(_cc) \ @@ -652,3 +651,51 @@ void _bt_component_class_freeze(const struct bt_component_class *comp_cls) BT_LIB_LOGD("Freezing component class: %!+C", comp_cls); ((struct bt_component_class *) comp_cls)->frozen = true; } + +void bt_component_class_get_ref( + const struct bt_component_class *component_class) +{ + bt_object_get_ref(component_class); +} + +void bt_component_class_put_ref( + const struct bt_component_class *component_class) +{ + bt_object_put_ref(component_class); +} + +void bt_component_class_source_get_ref( + const struct bt_component_class_source *component_class_source) +{ + bt_object_get_ref(component_class_source); +} + +void bt_component_class_source_put_ref( + const struct bt_component_class_source *component_class_source) +{ + bt_object_put_ref(component_class_source); +} + +void bt_component_class_filter_get_ref( + const struct bt_component_class_filter *component_class_filter) +{ + bt_object_get_ref(component_class_filter); +} + +void bt_component_class_filter_put_ref( + const struct bt_component_class_filter *component_class_filter) +{ + bt_object_put_ref(component_class_filter); +} + +void bt_component_class_sink_get_ref( + const struct bt_component_class_sink *component_class_sink) +{ + bt_object_get_ref(component_class_sink); +} + +void bt_component_class_sink_put_ref( + const struct bt_component_class_sink *component_class_sink) +{ + bt_object_put_ref(component_class_sink); +} diff --git a/lib/graph/component-filter.c b/lib/graph/component-filter.c index a27b6e72..32a12924 100644 --- a/lib/graph/component-filter.c +++ b/lib/graph/component-filter.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "COMP-FILTER" #include +#include +#include #include #include #include @@ -32,9 +34,6 @@ #include #include #include -#include -#include -#include BT_HIDDEN void bt_component_filter_destroy(struct bt_component *component) @@ -190,3 +189,15 @@ end: bt_object_put_ref(port); return status; } + +void bt_component_filter_get_ref( + const struct bt_component_filter *component_filter) +{ + bt_object_get_ref(component_filter); +} + +void bt_component_filter_put_ref( + const struct bt_component_filter *component_filter) +{ + bt_object_put_ref(component_filter); +} diff --git a/lib/graph/component-sink.c b/lib/graph/component-sink.c index 1d32d609..41a9a376 100644 --- a/lib/graph/component-sink.c +++ b/lib/graph/component-sink.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "COMP-SINK" #include +#include +#include #include #include #include @@ -31,9 +33,6 @@ #include #include #include -#include -#include -#include BT_HIDDEN void bt_component_sink_destroy(struct bt_component *component) @@ -123,3 +122,15 @@ end: bt_object_put_ref(port); return status; } + +void bt_component_sink_get_ref( + const struct bt_component_sink *component_sink) +{ + bt_object_get_ref(component_sink); +} + +void bt_component_sink_put_ref( + const struct bt_component_sink *component_sink) +{ + bt_object_put_ref(component_sink); +} diff --git a/lib/graph/component-source.c b/lib/graph/component-source.c index d6a492a8..e23200a5 100644 --- a/lib/graph/component-source.c +++ b/lib/graph/component-source.c @@ -24,7 +24,8 @@ #define BT_LOG_TAG "COMP-SOURCE" #include -#include +#include +#include #include #include #include @@ -34,8 +35,6 @@ #include #include #include -#include -#include BT_HIDDEN void bt_component_source_destroy(struct bt_component *component) @@ -120,3 +119,15 @@ end: bt_object_put_ref(port); return status; } + +void bt_component_source_get_ref( + const struct bt_component_source *component_source) +{ + bt_object_get_ref(component_source); +} + +void bt_component_source_put_ref( + const struct bt_component_source *component_source) +{ + bt_object_put_ref(component_source); +} diff --git a/lib/graph/component.c b/lib/graph/component.c index 7448be02..eb911861 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "COMP" #include +#include +#include #include #include #include @@ -40,12 +42,9 @@ #include #include #include -#include #include #include #include -#include -#include #include #include @@ -822,3 +821,13 @@ void bt_component_remove_destroy_listener(struct bt_component *component, } } } + +void bt_component_get_ref(const struct bt_component *component) +{ + bt_object_get_ref(component); +} + +void bt_component_put_ref(const struct bt_component *component) +{ + bt_object_put_ref(component); +} diff --git a/lib/graph/connection.c b/lib/graph/connection.c index 3fabe213..ebe03903 100644 --- a/lib/graph/connection.c +++ b/lib/graph/connection.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "CONNECTION" #include +#include +#include #include #include #include @@ -32,9 +34,6 @@ #include #include #include -#include -#include -#include #include #include @@ -284,3 +283,13 @@ bt_bool bt_connection_is_ended(const struct bt_connection *connection) { return !connection->downstream_port && !connection->upstream_port; } + +void bt_connection_get_ref(const struct bt_connection *connection) +{ + bt_object_get_ref(connection); +} + +void bt_connection_put_ref(const struct bt_connection *connection) +{ + bt_object_put_ref(connection); +} diff --git a/lib/graph/graph.c b/lib/graph/graph.c index 56f98b13..3588c54a 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "GRAPH" #include +#include +#include #include #include #include @@ -42,9 +44,6 @@ #include #include #include -#include -#include -#include #include #include @@ -1937,3 +1936,13 @@ void bt_graph_add_notification(struct bt_graph *graph, */ g_ptr_array_add(graph->notifications, notif); } + +void bt_graph_get_ref(const struct bt_graph *graph) +{ + bt_object_get_ref(graph); +} + +void bt_graph_put_ref(const struct bt_graph *graph) +{ + bt_object_put_ref(graph); +} diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 46b30db0..db774dfd 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -1041,3 +1040,27 @@ end: bt_object_put_ref(colander_comp_cls); return (void *) iterator; } + +void bt_port_output_notification_iterator_get_ref( + const struct bt_port_output_notification_iterator *iterator) +{ + bt_object_get_ref(iterator); +} + +void bt_port_output_notification_iterator_put_ref( + const struct bt_port_output_notification_iterator *iterator) +{ + bt_object_put_ref(iterator); +} + +void bt_self_component_port_input_notification_iterator_get_ref( + const struct bt_self_component_port_input_notification_iterator *iterator) +{ + bt_object_get_ref(iterator); +} + +void bt_self_component_port_input_notification_iterator_put_ref( + const struct bt_self_component_port_input_notification_iterator *iterator) +{ + bt_object_put_ref(iterator); +} diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c index 038da740..3321af22 100644 --- a/lib/graph/notification/event.c +++ b/lib/graph/notification/event.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "NOTIF-EVENT" #include +#include +#include #include #include #include @@ -36,9 +38,6 @@ #include #include #include -#include -#include -#include #include #include diff --git a/lib/graph/notification/inactivity.c b/lib/graph/notification/inactivity.c index a8bd0367..47d759d4 100644 --- a/lib/graph/notification/inactivity.c +++ b/lib/graph/notification/inactivity.c @@ -23,6 +23,7 @@ #define BT_LOG_TAG "NOTIF-INACTIVITY" #include +#include #include #include #include @@ -31,8 +32,6 @@ #include #include #include -#include -#include static void bt_notification_inactivity_destroy(struct bt_object *obj) diff --git a/lib/graph/notification/notification.c b/lib/graph/notification/notification.c index 3338780d..7a2d859b 100644 --- a/lib/graph/notification/notification.c +++ b/lib/graph/notification/notification.c @@ -24,11 +24,11 @@ #define BT_LOG_TAG "NOTIF" #include +#include +#include #include #include #include -#include -#include BT_ASSERT_PRE_FUNC static inline void _init_seq_num(struct bt_notification *notification) @@ -73,3 +73,13 @@ void bt_notification_unlink_graph(struct bt_notification *notif) BT_ASSERT(notif); notif->graph = NULL; } + +void bt_notification_get_ref(const struct bt_notification *notification) +{ + bt_object_get_ref(notification); +} + +void bt_notification_put_ref(const struct bt_notification *notification) +{ + bt_object_put_ref(notification); +} diff --git a/lib/graph/notification/packet.c b/lib/graph/notification/packet.c index d5b8625b..f548f8c5 100644 --- a/lib/graph/notification/packet.c +++ b/lib/graph/notification/packet.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/graph/notification/stream.c b/lib/graph/notification/stream.c index 44456ee2..61ff2780 100644 --- a/lib/graph/notification/stream.c +++ b/lib/graph/notification/stream.c @@ -33,7 +33,6 @@ #include #include #include -#include #include static diff --git a/lib/graph/port.c b/lib/graph/port.c index 01ee3944..da83725e 100644 --- a/lib/graph/port.c +++ b/lib/graph/port.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "PORT" #include +#include +#include #include #include #include @@ -34,10 +36,7 @@ #include #include #include -#include #include -#include -#include static void destroy_port(struct bt_object *obj) @@ -171,3 +170,33 @@ void *bt_self_component_port_get_data(const struct bt_self_component_port *port) BT_ASSERT_PRE_NON_NULL(port, "Port"); return ((struct bt_port *) port)->user_data; } + +void bt_port_get_ref(const struct bt_port *port) +{ + bt_object_get_ref(port); +} + +void bt_port_put_ref(const struct bt_port *port) +{ + bt_object_put_ref(port); +} + +void bt_port_input_get_ref(const struct bt_port_input *port_input) +{ + bt_object_get_ref(port_input); +} + +void bt_port_input_put_ref(const struct bt_port_input *port_input) +{ + bt_object_put_ref(port_input); +} + +void bt_port_output_get_ref(const struct bt_port_output *port_output) +{ + bt_object_get_ref(port_output); +} + +void bt_port_output_put_ref(const struct bt_port_output *port_output) +{ + bt_object_put_ref(port_output); +} diff --git a/lib/graph/query-executor.c b/lib/graph/query-executor.c index 4ef28cc7..c7613ce9 100644 --- a/lib/graph/query-executor.c +++ b/lib/graph/query-executor.c @@ -23,6 +23,8 @@ #define BT_LOG_TAG "QUERY-EXECUTOR" #include +#include +#include #include #include #include @@ -31,10 +33,7 @@ #include #include #include -#include #include -#include -#include static void bt_query_executor_destroy(struct bt_object *obj) @@ -157,3 +156,13 @@ bt_bool bt_query_executor_is_canceled(const struct bt_query_executor *query_exec BT_ASSERT_PRE_NON_NULL(query_exec, "Query executor"); return query_exec->canceled; } + +void bt_query_executor_get_ref(const struct bt_query_executor *query_executor) +{ + bt_object_get_ref(query_executor); +} + +void bt_query_executor_put_ref(const struct bt_query_executor *query_executor) +{ + bt_object_put_ref(query_executor); +} diff --git a/lib/lib-logging.c b/lib/lib-logging.c index 46ac3a54..d3d709bb 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/lib/object-pool.c b/lib/object-pool.c index 1612a05c..3b88650a 100644 --- a/lib/object-pool.c +++ b/lib/object-pool.c @@ -25,6 +25,7 @@ #include #include +#include #include int bt_object_pool_initialize(struct bt_object_pool *pool, diff --git a/lib/object.c b/lib/object.c deleted file mode 100644 index f28831dd..00000000 --- a/lib/object.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017-2018 Philippe Proulx - * Copyright (c) 2015 Jérémie Galarneau - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_TAG "OBJECT" -#include - -#include -#include - -void bt_object_get_ref(const void *ptr) -{ - struct bt_object *obj = (void *) ptr; - - if (unlikely(!obj)) { - goto end; - } - - BT_ASSERT_PRE(obj->is_shared, "Object is not shared: addr=%p", obj); - bt_object_get_no_null_check(obj); - -end: - return; -} - -void bt_object_put_ref(const void *ptr) -{ - struct bt_object *obj = (void *) ptr; - - if (unlikely(!obj)) { - return; - } - - BT_ASSERT_PRE(obj->is_shared, "Object is not shared: addr=%p", obj); - BT_ASSERT_PRE(bt_object_get_ref_count(obj) > 0, - "Decrementing a reference count set to 0: addr=%p", ptr); - bt_object_put_no_null_check(obj); -} diff --git a/lib/plugin/plugin-so.c b/lib/plugin/plugin-so.c index 35233b81..b06a1b6b 100644 --- a/lib/plugin/plugin-so.c +++ b/lib/plugin/plugin-so.c @@ -26,8 +26,9 @@ #define BT_LOG_TAG "PLUGIN-SO" #include +#include +#include #include -#include #include #include #include @@ -39,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/plugin/plugin.c b/lib/plugin/plugin.c index 09d85974..1d7661de 100644 --- a/lib/plugin/plugin.c +++ b/lib/plugin/plugin.c @@ -26,9 +26,10 @@ #define BT_LOG_TAG "PLUGIN" #include +#include +#include #include #include -#include #include #include #include @@ -36,8 +37,6 @@ #include #include #include -#include -#include #include #include #include @@ -613,3 +612,23 @@ bt_plugin_borrow_sink_component_class_by_name_const( return (const void *) borrow_component_class_by_name(plugin, plugin->sink_comp_classes, name); } + +void bt_plugin_get_ref(const struct bt_plugin *plugin) +{ + bt_object_get_ref(plugin); +} + +void bt_plugin_put_ref(const struct bt_plugin *plugin) +{ + bt_object_put_ref(plugin); +} + +void bt_plugin_set_get_ref(const struct bt_plugin_set *plugin_set) +{ + bt_object_get_ref(plugin_set); +} + +void bt_plugin_set_put_ref(const struct bt_plugin_set *plugin_set) +{ + bt_object_put_ref(plugin_set); +} diff --git a/lib/trace-ir/attributes.c b/lib/trace-ir/attributes.c index af8a4936..8c1a0823 100644 --- a/lib/trace-ir/attributes.c +++ b/lib/trace-ir/attributes.c @@ -24,9 +24,10 @@ #define BT_LOG_TAG "ATTRS" #include -#include #include #include +#include +#include #include #include #include diff --git a/lib/trace-ir/clock-class.c b/lib/trace-ir/clock-class.c index fd82342f..45b47c1e 100644 --- a/lib/trace-ir/clock-class.c +++ b/lib/trace-ir/clock-class.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -322,3 +321,13 @@ int bt_clock_class_cycles_to_ns_from_origin( return ret; } + +void bt_clock_class_get_ref(const struct bt_clock_class *clock_class) +{ + bt_object_get_ref(clock_class); +} + +void bt_clock_class_put_ref(const struct bt_clock_class *clock_class) +{ + bt_object_put_ref(clock_class); +} diff --git a/lib/trace-ir/clock-value.c b/lib/trace-ir/clock-value.c index a89fdca9..8bd2b1cb 100644 --- a/lib/trace-ir/clock-value.c +++ b/lib/trace-ir/clock-value.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/trace-ir/event-class.c b/lib/trace-ir/event-class.c index 52d23a6b..0c8b9f6c 100644 --- a/lib/trace-ir/event-class.c +++ b/lib/trace-ir/event-class.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -387,3 +386,13 @@ void _bt_event_class_freeze(const struct bt_event_class *event_class) BT_LIB_LOGD("Freezing event class: %!+E", event_class); ((struct bt_event_class *) event_class)->frozen = true; } + +void bt_event_class_get_ref(const struct bt_event_class *event_class) +{ + bt_object_get_ref(event_class); +} + +void bt_event_class_put_ref(const struct bt_event_class *event_class) +{ + bt_object_put_ref(event_class); +} diff --git a/lib/trace-ir/event.c b/lib/trace-ir/event.c index 433963ca..d65d7637 100644 --- a/lib/trace-ir/event.c +++ b/lib/trace-ir/event.c @@ -44,10 +44,9 @@ #include #include #include -#include #include -#include #include +#include #include BT_HIDDEN diff --git a/lib/trace-ir/field-class.c b/lib/trace-ir/field-class.c index ed7b2121..2361c5d5 100644 --- a/lib/trace-ir/field-class.c +++ b/lib/trace-ir/field-class.c @@ -33,11 +33,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -1196,3 +1194,13 @@ void _bt_field_class_make_part_of_trace_class(const struct bt_field_class *c_fc) break; } } + +void bt_field_class_get_ref(const struct bt_field_class *field_class) +{ + bt_object_get_ref(field_class); +} + +void bt_field_class_put_ref(const struct bt_field_class *field_class) +{ + bt_object_put_ref(field_class); +} diff --git a/lib/trace-ir/field-path.c b/lib/trace-ir/field-path.c index ca0c81be..3303134b 100644 --- a/lib/trace-ir/field-path.c +++ b/lib/trace-ir/field-path.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -98,3 +97,13 @@ uint64_t bt_field_path_get_index_by_index( BT_ASSERT_PRE_VALID_INDEX(index, field_path->indexes->len); return bt_field_path_get_index_by_index_inline(field_path, index); } + +void bt_field_path_get_ref(const struct bt_field_path *field_path) +{ + bt_object_get_ref(field_path); +} + +void bt_field_path_put_ref(const struct bt_field_path *field_path) +{ + bt_object_put_ref(field_path); +} diff --git a/lib/trace-ir/field.c b/lib/trace-ir/field.c index 88806118..ef031963 100644 --- a/lib/trace-ir/field.c +++ b/lib/trace-ir/field.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/trace-ir/packet.c b/lib/trace-ir/packet.c index 6a5d3f90..cf320389 100644 --- a/lib/trace-ir/packet.c +++ b/lib/trace-ir/packet.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -506,3 +505,13 @@ void bt_packet_set_packet_counter_snapshot(struct bt_packet *packet, "%![packet-]+a", packet); bt_property_uint_set(&packet->packet_counter_snapshot, value); } + +void bt_packet_get_ref(const struct bt_packet *packet) +{ + bt_object_get_ref(packet); +} + +void bt_packet_put_ref(const struct bt_packet *packet) +{ + bt_object_put_ref(packet); +} diff --git a/lib/trace-ir/resolve-field-path.c b/lib/trace-ir/resolve-field-path.c index 0254dd42..00ec6447 100644 --- a/lib/trace-ir/resolve-field-path.c +++ b/lib/trace-ir/resolve-field-path.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/lib/trace-ir/stream-class.c b/lib/trace-ir/stream-class.c index 49a3f350..b032b8ee 100644 --- a/lib/trace-ir/stream-class.c +++ b/lib/trace-ir/stream-class.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -601,3 +600,13 @@ bt_bool bt_stream_class_default_clock_is_always_known( /* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */ return BT_TRUE; } + +void bt_stream_class_get_ref(const struct bt_stream_class *stream_class) +{ + bt_object_get_ref(stream_class); +} + +void bt_stream_class_put_ref(const struct bt_stream_class *stream_class) +{ + bt_object_put_ref(stream_class); +} diff --git a/lib/trace-ir/stream.c b/lib/trace-ir/stream.c index 50371750..b578d3be 100644 --- a/lib/trace-ir/stream.c +++ b/lib/trace-ir/stream.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -233,3 +232,13 @@ void _bt_stream_freeze(const struct bt_stream *stream) BT_LIB_LOGD("Freezing stream: %!+s", stream); ((struct bt_stream *) stream)->frozen = true; } + +void bt_stream_get_ref(const struct bt_stream *stream) +{ + bt_object_get_ref(stream); +} + +void bt_stream_put_ref(const struct bt_stream *stream) +{ + bt_object_put_ref(stream); +} diff --git a/lib/trace-ir/trace-class.c b/lib/trace-ir/trace-class.c index 6bff90a7..265aa73a 100644 --- a/lib/trace-ir/trace-class.c +++ b/lib/trace-ir/trace-class.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -419,3 +418,13 @@ void bt_trace_class_set_assigns_automatic_stream_class_id(struct bt_trace_class BT_LIB_LOGV("Set trace class's automatic stream class ID " "assignment property: %!+T", tc); } + +void bt_trace_class_get_ref(const struct bt_trace_class *trace_class) +{ + bt_object_get_ref(trace_class); +} + +void bt_trace_class_put_ref(const struct bt_trace_class *trace_class) +{ + bt_object_put_ref(trace_class); +} diff --git a/lib/trace-ir/trace.c b/lib/trace-ir/trace.c index d30e3ccd..46380fd3 100644 --- a/lib/trace-ir/trace.c +++ b/lib/trace-ir/trace.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -416,3 +415,13 @@ const struct bt_trace_class *bt_trace_borrow_class_const( { return bt_trace_borrow_class((void *) trace); } + +void bt_trace_get_ref(const struct bt_trace *trace) +{ + bt_object_get_ref(trace); +} + +void bt_trace_put_ref(const struct bt_trace *trace) +{ + bt_object_put_ref(trace); +} diff --git a/lib/trace-ir/utils.c b/lib/trace-ir/utils.c index 54063b94..508c5790 100644 --- a/lib/trace-ir/utils.c +++ b/lib/trace-ir/utils.c @@ -28,5 +28,4 @@ #include #include #include -#include #include diff --git a/lib/value.c b/lib/value.c index 93c2d832..eb78ca9e 100644 --- a/lib/value.c +++ b/lib/value.c @@ -29,15 +29,14 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include -#include #define BT_VALUE_FROM_CONCRETE(_concrete) ((struct bt_value *) (_concrete)) #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base)) @@ -1299,3 +1298,13 @@ bt_bool bt_value_compare(const struct bt_value *object_a, end: return ret; } + +void bt_value_get_ref(const struct bt_value *value) +{ + bt_object_get_ref(value); +} + +void bt_value_put_ref(const struct bt_value *value) +{ + bt_object_put_ref(value); +} diff --git a/plugins/ctf/common/bfcr/bfcr.c b/plugins/ctf/common/bfcr/bfcr.c index 40d5b2a1..6ddd1dd1 100644 --- a/plugins/ctf/common/bfcr/bfcr.c +++ b/plugins/ctf/common/bfcr/bfcr.c @@ -37,7 +37,6 @@ #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 ddd24f4f..4b5e219a 100644 --- a/plugins/ctf/common/metadata/ctf-meta-translate.c +++ b/plugins/ctf/common/metadata/ctf-meta-translate.c @@ -151,7 +151,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_object_put_ref(member_ir_fc); + bt_field_class_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_object_put_ref(option_ir_fc); + bt_field_class_put_ref(option_ir_fc); } return ir_fc; @@ -232,7 +232,7 @@ struct bt_field_class *ctf_field_class_array_to_ir( ir_fc = bt_field_class_static_array_create(elem_ir_fc, fc->length); BT_ASSERT(ir_fc); - bt_object_put_ref(elem_ir_fc); + bt_field_class_put_ref(elem_ir_fc); end: return ir_fc; @@ -259,7 +259,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_object_put_ref(elem_ir_fc); + bt_field_class_put_ref(elem_ir_fc); BT_ASSERT(ir_fc); ret = bt_field_class_dynamic_array_set_length_field_class( ir_fc, @@ -407,7 +407,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_object_put_ref(ir_ec); + bt_event_class_put_ref(ir_ec); if (ec->spec_context_fc) { struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir( @@ -417,7 +417,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_object_put_ref(ir_fc); + bt_field_class_put_ref(ir_fc); } } @@ -429,7 +429,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_object_put_ref(ir_fc); + bt_field_class_put_ref(ir_fc); } } @@ -471,7 +471,7 @@ struct bt_stream_class *ctf_stream_class_to_ir(struct ctf_stream_class *sc, ir_sc = bt_stream_class_create_with_id(ir_tc, sc->id); BT_ASSERT(ir_sc); - bt_object_put_ref(ir_sc); + bt_stream_class_put_ref(ir_sc); if (sc->packet_context_fc) { struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir( @@ -481,7 +481,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_object_put_ref(ir_fc); + bt_field_class_put_ref(ir_fc); } } @@ -493,7 +493,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_object_put_ref(ir_fc); + bt_field_class_put_ref(ir_fc); } } @@ -505,7 +505,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_object_put_ref(ir_fc); + bt_field_class_put_ref(ir_fc); } } @@ -581,7 +581,7 @@ int ctf_trace_class_to_ir(struct bt_trace_class *ir_tc, ret = bt_trace_class_set_packet_header_field_class( ir_tc, ir_fc); BT_ASSERT(ret == 0); - bt_object_put_ref(ir_fc); + bt_field_class_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 d000c688..8bc957f2 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 @@ -161,7 +161,7 @@ int update_stream_class_default_clock_class( if (!stream_class->default_clock_class) { stream_class->default_clock_class = clock_class; - bt_object_get_ref(stream_class->default_clock_class); + bt_clock_class_get_ref(stream_class->default_clock_class); } end: diff --git a/plugins/ctf/common/metadata/ctf-meta.h b/plugins/ctf/common/metadata/ctf-meta.h index 76e24d42..a5299525 100644 --- a/plugins/ctf/common/metadata/ctf-meta.h +++ b/plugins/ctf/common/metadata/ctf-meta.h @@ -471,7 +471,7 @@ static inline void _ctf_field_class_int_destroy(struct ctf_field_class_int *fc) { BT_ASSERT(fc); - bt_object_put_ref(fc->mapped_clock_class); + bt_clock_class_put_ref(fc->mapped_clock_class); g_free(fc); } @@ -479,7 +479,7 @@ static inline void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc) { BT_ASSERT(fc); - bt_object_put_ref(fc->base.mapped_clock_class); + bt_clock_class_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->disp_base = src_fc->disp_base; dst_fc->encoding = src_fc->encoding; dst_fc->mapped_clock_class = src_fc->mapped_clock_class; - bt_object_get_ref(dst_fc->mapped_clock_class); + bt_clock_class_get_ref(dst_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_object_put_ref(sc->default_clock_class); + bt_clock_class_put_ref(sc->default_clock_class); g_free(sc); } @@ -1451,7 +1451,7 @@ struct ctf_trace_class *ctf_trace_class_create(void) BT_ASSERT(tc); tc->default_byte_order = -1; tc->clock_classes = g_ptr_array_new_with_free_func( - (GDestroyNotify) bt_object_put_ref); + (GDestroyNotify) bt_clock_class_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 e57d0b30..c225491b 100644 --- a/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -551,7 +551,7 @@ void ctx_destroy(struct ctx *ctx) scope = parent_scope; } - bt_object_put_ref(ctx->trace_class); + bt_trace_class_put_ref(ctx->trace_class); if (ctx->ctf_tc) { ctf_trace_class_destroy(ctx->ctf_tc); @@ -2705,7 +2705,7 @@ int visit_integer_decl(struct ctx *ctx, (*integer_decl)->disp_base = base; (*integer_decl)->encoding = encoding; (*integer_decl)->mapped_clock_class = mapped_clock_class; - bt_object_get_ref((*integer_decl)->mapped_clock_class); + bt_clock_class_get_ref((*integer_decl)->mapped_clock_class); return 0; error: @@ -3599,7 +3599,7 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx, BT_ASSERT(ret == 0); g_ptr_array_add(ctx->ctf_tc->clock_classes, clock_class_to_map_to); - bt_object_get_ref(clock_class_to_map_to); + bt_clock_class_get_ref(clock_class_to_map_to); break; case 1: /* @@ -3607,7 +3607,7 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx, * this one. */ clock_class_to_map_to = ctx->ctf_tc->clock_classes->pdata[0]; - bt_object_get_ref(clock_class_to_map_to); + bt_clock_class_get_ref(clock_class_to_map_to); break; default: /* @@ -3622,10 +3622,10 @@ int auto_map_field_to_trace_clock_class(struct ctx *ctx, BT_ASSERT(clock_class_to_map_to); int_fc->mapped_clock_class = clock_class_to_map_to; - bt_object_get_ref(int_fc->mapped_clock_class); + bt_clock_class_get_ref(int_fc->mapped_clock_class); end: - bt_object_put_ref(clock_class_to_map_to); + bt_clock_class_put_ref(clock_class_to_map_to); return ret; } @@ -4729,10 +4729,10 @@ int visit_clock_decl(struct ctx *ctx, struct ctf_node *clock_node) bt_clock_class_set_offset(clock, offset_seconds, offset_cycles); apply_clock_class_offset(ctx, clock); g_ptr_array_add(ctx->ctf_tc->clock_classes, clock); - bt_object_get_ref(clock); + bt_clock_class_get_ref(clock); end: - BT_OBJECT_PUT_REF_AND_RESET(clock); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock); return ret; } @@ -4837,7 +4837,7 @@ struct bt_trace_class *ctf_visitor_generate_ir_get_ir_trace_class( BT_ASSERT(ctx); BT_ASSERT(ctx->trace_class); - bt_object_get_ref(ctx->trace_class); + bt_trace_class_get_ref(ctx->trace_class); return ctx->trace_class; } diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index 501c3004..a9e35552 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -801,7 +801,7 @@ enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) stream = notit->medium.medops.borrow_stream( notit->meta.sc->ir_sc, notit->cur_data_stream_id, notit->medium.data); - bt_object_get_ref(stream); + bt_stream_get_ref(stream); BT_LOGV("User function returned: stream-addr=%p", stream); if (!stream) { BT_LOGW_STR("User function failed to return a stream object " @@ -817,10 +817,10 @@ enum bt_notif_iter_status set_current_stream(struct bt_notif_iter *notit) goto end; } - BT_OBJECT_MOVE_REF(notit->stream, stream); + BT_STREAM_MOVE_REF(notit->stream, stream); end: - bt_object_put_ref(stream); + bt_stream_put_ref(stream); return status; } @@ -855,11 +855,11 @@ enum bt_notif_iter_status set_current_packet(struct bt_notif_iter *notit) goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(packet); + BT_PACKET_PUT_REF_AND_RESET(packet); status = BT_NOTIF_ITER_STATUS_ERROR; end: - BT_OBJECT_MOVE_REF(notit->packet, packet); + BT_PACKET_MOVE_REF(notit->packet, packet); return status; } @@ -1215,11 +1215,11 @@ enum bt_notif_iter_status set_current_event_notification( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(notif); + BT_NOTIFICATION_PUT_REF_AND_RESET(notif); status = BT_NOTIF_ITER_STATUS_ERROR; end: - BT_OBJECT_MOVE_REF(notit->event_notif, notif); + BT_NOTIFICATION_MOVE_REF(notit->event_notif, notif); return status; } @@ -1571,9 +1571,9 @@ void bt_notif_iter_reset(struct bt_notif_iter *notit) stack_clear(notit->stack); notit->meta.sc = NULL; notit->meta.ec = NULL; - 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); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); + BT_STREAM_PUT_REF_AND_RESET(notit->stream); + BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -1628,8 +1628,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_OBJECT_PUT_REF_AND_RESET(notit->packet); - BT_OBJECT_PUT_REF_AND_RESET(notit->event_notif); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); + BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif); release_all_dscopes(notit); notit->cur_dscope_field = NULL; @@ -2268,7 +2268,7 @@ void notify_new_stream(struct bt_notif_iter *notit, status = set_current_stream(notit); if (status != BT_NOTIF_ITER_STATUS_OK) { - BT_OBJECT_PUT_REF_AND_RESET(ret); + BT_NOTIFICATION_PUT_REF_AND_RESET(ret); goto end; } @@ -2433,7 +2433,7 @@ void notify_end_of_packet(struct bt_notif_iter *notit, } - BT_OBJECT_PUT_REF_AND_RESET(notit->packet); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); *notification = notif; } @@ -2508,8 +2508,8 @@ error: void bt_notif_iter_destroy(struct bt_notif_iter *notit) { - BT_OBJECT_PUT_REF_AND_RESET(notit->packet); - BT_OBJECT_PUT_REF_AND_RESET(notit->stream); + BT_PACKET_PUT_REF_AND_RESET(notit->packet); + BT_STREAM_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 b386eec8..55d7b344 100644 --- a/plugins/ctf/fs-sink/write.c +++ b/plugins/ctf/fs-sink/write.c @@ -40,13 +40,13 @@ static void unref_stream_class(const struct bt_stream_class *writer_stream_class) { - bt_object_put_ref(writer_stream_class); + bt_stream_class_put_ref(writer_stream_class); } static void unref_stream(const struct bt_stream_class *writer_stream) { - bt_object_put_ref(writer_stream); + bt_stream_class_put_ref(writer_stream); } static @@ -145,10 +145,10 @@ const struct bt_stream_class *insert_new_stream_class( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); + BT_STREAM_CLASS_PUT_REF_AND_RESET(writer_stream_class); end: - bt_object_put_ref(writer_trace); - bt_object_put_ref(trace); + bt_trace_put_ref(writer_trace); + bt_trace_put_ref(trace); return writer_stream_class; } @@ -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_OBJECT_PUT_REF_AND_RESET(writer_trace); + BT_TRACE_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_OBJECT_PUT_REF_AND_RESET(stream); + BT_STREAM_PUT_REF_AND_RESET(stream); } /* Check if the trace is already static or register a listener. */ @@ -366,8 +366,8 @@ struct fs_writer *insert_new_writer( error: g_free(fs_writer); fs_writer = NULL; - bt_object_put_ref(writer_trace); - bt_object_put_ref(stream); + bt_trace_put_ref(writer_trace); + bt_stream_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_OBJECT_PUT_REF_AND_RESET(trace); + BT_TRACE_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_object_put_ref(stream_class); + bt_stream_class_put_ref(stream_class); return fs_writer; } @@ -454,7 +454,7 @@ const struct bt_stream *insert_new_stream( goto error; } } - bt_object_get_ref(writer_stream_class); + bt_stream_class_get_ref(writer_stream_class); writer_stream = bt_stream_create(writer_stream_class, bt_stream_get_name(stream)); @@ -466,10 +466,10 @@ const struct bt_stream *insert_new_stream( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); end: bt_object_put_ref(ctf_writer); - bt_object_put_ref(writer_stream_class); + bt_stream_class_put_ref(writer_stream_class); return writer_stream; } @@ -494,12 +494,12 @@ const struct bt_stream *get_writer_stream( BT_LOGE_STR("Failed to find existing stream."); goto error; } - bt_object_get_ref(writer_stream); + bt_stream_get_ref(writer_stream); goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); end: return writer_stream; } diff --git a/plugins/ctf/fs-sink/writer.c b/plugins/ctf/fs-sink/writer.c index 7ff45840..74e0b7eb 100644 --- a/plugins/ctf/fs-sink/writer.c +++ b/plugins/ctf/fs-sink/writer.c @@ -132,7 +132,7 @@ enum bt_component_status handle_notification( } ret = writer_new_packet(writer_component, packet); - bt_object_put_ref(packet); + bt_packet_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_object_put_ref(packet); + bt_packet_put_ref(packet); break; } case BT_NOTIFICATION_TYPE_EVENT: @@ -174,7 +174,7 @@ enum bt_component_status handle_notification( goto end; } ret = writer_stream_begin(writer_component, stream); - bt_object_put_ref(stream); + bt_stream_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_object_put_ref(stream); + bt_stream_put_ref(stream); break; } default: @@ -285,7 +285,7 @@ enum bt_component_status apply_one_bool(const char *key, *found = true; } end: - bt_object_put_ref(value); + bt_value_put_ref(value); return ret; } diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index 803d424f..b6e301cc 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -643,7 +643,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( } ds_file->stream = stream; - bt_object_get_ref(ds_file->stream); + bt_stream_get_ref(ds_file->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"); @@ -695,7 +695,7 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file) return; } - bt_object_put_ref(ds_file->stream); + bt_stream_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 7241e732..abdf8e2b 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -109,7 +109,7 @@ enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( * BT_NOTIFICATION_TYPE_STREAM_BEGINNING * notification: skip this one, get a new one. */ - BT_OBJECT_PUT_REF_AND_RESET(*notif); + BT_NOTIFICATION_PUT_REF_AND_RESET(*notif); status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif); *notif = priv_notif; @@ -144,7 +144,7 @@ enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( goto end; } - BT_OBJECT_PUT_REF_AND_RESET(*notif); + BT_NOTIFICATION_PUT_REF_AND_RESET(*notif); bt_notif_iter_reset(notif_iter_data->notif_iter); /* @@ -181,7 +181,7 @@ enum bt_self_notification_iterator_status ctf_fs_iterator_next_one( if (status == BT_SELF_NOTIFICATION_ITERATOR_STATUS_OK) { BT_ASSERT(bt_notification_get_type(*notif) == BT_NOTIFICATION_TYPE_STREAM_BEGINNING); - BT_OBJECT_PUT_REF_AND_RESET(*notif); + BT_NOTIFICATION_PUT_REF_AND_RESET(*notif); status = ctf_fs_ds_file_next(notif_iter_data->ds_file, &priv_notif); *notif = priv_notif; @@ -322,7 +322,7 @@ void ctf_fs_trace_destroy(struct ctf_fs_trace *ctf_fs_trace) g_ptr_array_free(ctf_fs_trace->ds_file_groups, TRUE); } - BT_OBJECT_PUT_REF_AND_RESET(ctf_fs_trace->trace); + BT_TRACE_PUT_REF_AND_RESET(ctf_fs_trace->trace); if (ctf_fs_trace->path) { g_string_free(ctf_fs_trace->path, TRUE); @@ -512,8 +512,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_object_put_ref(ds_file_group->stream); - bt_object_put_ref(ds_file_group->stream_class); + bt_stream_put_ref(ds_file_group->stream); + bt_stream_class_put_ref(ds_file_group->stream_class); g_free(ds_file_group); } @@ -539,7 +539,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 = stream_class; - bt_object_get_ref(ds_file_group->stream_class); + bt_stream_class_get_ref(ds_file_group->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 48d416c8..7d480d16 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_class) { - BT_OBJECT_PUT_REF_AND_RESET(metadata->trace_class); + BT_TRACE_CLASS_PUT_REF_AND_RESET(metadata->trace_class); } if (metadata->decoder) { diff --git a/plugins/ctf/fs-src/query.c b/plugins/ctf/fs-src/query.c index 6f2017b2..7b222866 100644 --- a/plugins/ctf/fs-src/query.c +++ b/plugins/ctf/fs-src/query.c @@ -158,7 +158,7 @@ enum bt_query_status metadata_info_query( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(result); + BT_VALUE_PUT_REF_AND_RESET(result); result = NULL; if (status >= 0) { @@ -221,7 +221,7 @@ int add_range(struct bt_value *info, struct range *range, } end: - bt_object_put_ref(range_map); + bt_value_put_ref(range_map); return ret; } @@ -336,7 +336,7 @@ int populate_stream_info(struct ctf_fs_ds_file_group *group, goto end; } end: - bt_object_put_ref(file_paths); + bt_value_put_ref(file_paths); return ret; } @@ -408,7 +408,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_object_put_ref(group_info); + bt_value_put_ref(group_info); goto end; } @@ -427,7 +427,7 @@ int populate_trace_info(const char *trace_path, const char *trace_name, status = bt_value_array_append_element( file_groups, group_info); - bt_object_put_ref(group_info); + bt_value_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_OBJECT_PUT_REF_AND_RESET(file_groups); + BT_VALUE_PUT_REF_AND_RESET(file_groups); if (status != BT_VALUE_STATUS_OK) { ret = -1; goto end; } end: - bt_object_put_ref(file_groups); + bt_value_put_ref(file_groups); ctf_fs_trace_destroy(trace); return ret; } @@ -532,12 +532,12 @@ enum bt_query_status trace_info_query( ret = populate_trace_info(trace_path->str, trace_name->str, trace_info); if (ret) { - bt_object_put_ref(trace_info); + bt_value_put_ref(trace_info); goto error; } status = bt_value_array_append_element(result, trace_info); - bt_object_put_ref(trace_info); + bt_value_put_ref(trace_info); if (status != BT_VALUE_STATUS_OK) { goto error; } @@ -546,7 +546,7 @@ enum bt_query_status trace_info_query( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(result); + BT_VALUE_PUT_REF_AND_RESET(result); result = NULL; if (status >= 0) { diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index 48789348..c61bff6c 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_object_put_ref(port); + bt_port_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_object_put_ref(graph); - bt_object_put_ref(component); + bt_graph_put_ref(graph); + bt_component_put_ref(component); return ret; } @@ -154,7 +154,7 @@ int lttng_live_remove_port(struct lttng_live_component *lttng_live, if (nr_ports < 0) { return -1; } - BT_OBJECT_PUT_REF_AND_RESET(component); + BT_COMPONENT_PUT_REF_AND_RESET(component); if (nr_ports == 1) { enum bt_component_status status; @@ -214,7 +214,7 @@ void lttng_live_destroy_trace(struct bt_object *obj) retval = bt_trace_set_is_static(trace->trace); BT_ASSERT(!retval); - BT_OBJECT_PUT_REF_AND_RESET(trace->trace); + BT_TRACE_PUT_REF_AND_RESET(trace->trace); } lttng_live_metadata_fini(trace); BT_OBJECT_PUT_REF_AND_RESET(trace->cc_prio_map); @@ -590,12 +590,12 @@ enum bt_lttng_live_iterator_status emit_inactivity_notification( *notification = notif; end: bt_object_put_ref(clock_value); - bt_object_put_ref(clock_class); + bt_clock_class_put_ref(clock_class); return ret; error: ret = BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR; - bt_object_put_ref(notif); + bt_notification_put_ref(notif); goto end; } @@ -628,7 +628,7 @@ enum bt_lttng_live_iterator_status lttng_live_iterator_next_handle_one_quiescent lttng_live_stream->current_inactivity_timestamp; end: bt_object_put_ref(clock_value); - bt_object_put_ref(clock_class); + bt_clock_class_put_ref(clock_class); return ret; } @@ -999,7 +999,7 @@ end: if (viewer_connection) { bt_live_viewer_connection_destroy(viewer_connection); } - BT_OBJECT_PUT_REF_AND_RESET(url_value); + BT_VALUE_PUT_REF_AND_RESET(url_value); return query_ret; } @@ -1085,7 +1085,7 @@ struct lttng_live_component *lttng_live_component_create(struct bt_value *params if (!lttng_live->url) { goto error; } - BT_OBJECT_PUT_REF_AND_RESET(value); + BT_VALUE_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) { @@ -1164,7 +1164,7 @@ enum bt_component_status lttng_live_accept_port_connection( const struct bt_port *self_port = bt_port_from_private(self_private_port); other_component = bt_port_get_component(other_port); - bt_object_put_ref(other_component); /* weak */ + bt_component_put_ref(other_component); /* weak */ if (!lttng_live->downstream_component) { lttng_live->downstream_component = other_component; @@ -1184,6 +1184,6 @@ enum bt_component_status lttng_live_accept_port_connection( goto end; } end: - bt_object_put_ref(self_port); + bt_port_put_ref(self_port); return status; } diff --git a/plugins/ctf/lttng-live/metadata.c b/plugins/ctf/lttng-live/metadata.c index 4cfd8830..0beb0f1e 100644 --- a/plugins/ctf/lttng-live/metadata.c +++ b/plugins/ctf/lttng-live/metadata.c @@ -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_OBJECT_PUT_REF_AND_RESET(clock_class); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class); if (ret) { goto error; diff --git a/plugins/ctf/lttng-live/viewer-connection.c b/plugins/ctf/lttng-live/viewer-connection.c index f371095c..17fc234d 100644 --- a/plugins/ctf/lttng-live/viewer-connection.c +++ b/plugins/ctf/lttng-live/viewer-connection.c @@ -351,7 +351,7 @@ enum bt_value_status list_update_session(struct bt_value *results, if (ret != BT_VALUE_STATUS_OK) { goto end; } - BT_OBJECT_PUT_REF_AND_RESET(btval); + BT_VALUE_PUT_REF_AND_RESET(btval); btval = bt_value_map_get(map, "client-count"); if (!btval) { @@ -365,22 +365,22 @@ enum bt_value_status list_update_session(struct bt_value *results, if (ret != BT_VALUE_STATUS_OK) { goto end; } - BT_OBJECT_PUT_REF_AND_RESET(btval); + BT_VALUE_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); + BT_VALUE_PUT_REF_AND_RESET(hostname); + BT_VALUE_PUT_REF_AND_RESET(session_name); + BT_VALUE_PUT_REF_AND_RESET(map); if (found) { break; } } end: - 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); + BT_VALUE_PUT_REF_AND_RESET(btval); + BT_VALUE_PUT_REF_AND_RESET(hostname); + BT_VALUE_PUT_REF_AND_RESET(session_name); + BT_VALUE_PUT_REF_AND_RESET(map); *_found = found; return ret; } @@ -497,7 +497,7 @@ end: if (url) { g_string_free(url, TRUE); } - BT_OBJECT_PUT_REF_AND_RESET(map); + BT_VALUE_PUT_REF_AND_RESET(map); return ret; } @@ -603,7 +603,7 @@ struct bt_value *bt_live_viewer_connection_list_sessions(struct bt_live_viewer_c } goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(results); + BT_VALUE_PUT_REF_AND_RESET(results); end: return results; } diff --git a/plugins/libctfcopytrace/clock-fields.c b/plugins/libctfcopytrace/clock-fields.c index 5f7c7246..c7199d8b 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_OBJECT_PUT_REF_AND_RESET(clock); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock); ret = bt_field_type_integer_set_size(type, 64); if (ret) { @@ -322,12 +322,12 @@ struct bt_field_type *override_header_type(FILE *err, BT_LOGE_STR("Failed to find clock fields in struct."); goto error; } - BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(writer_clock_class); goto end; error: - bt_object_put_ref(writer_clock_class); + bt_clock_class_put_ref(writer_clock_class); BT_OBJECT_PUT_REF_AND_RESET(new_type); end: return new_type; @@ -732,7 +732,7 @@ const struct bt_clock_class *stream_class_get_clock_class(FILE *err, /* FIXME multi-clock? */ clock_class = bt_trace_get_clock_class_by_index(trace, 0); - bt_object_put_ref(trace); + bt_trace_put_ref(trace); return clock_class; } @@ -747,11 +747,11 @@ const struct bt_clock_class *event_get_clock_class(FILE *err, const struct bt_ev BT_ASSERT(event_class); stream_class = bt_event_class_get_stream_class(event_class); - BT_OBJECT_PUT_REF_AND_RESET(event_class); + BT_EVENT_CLASS_PUT_REF_AND_RESET(event_class); BT_ASSERT(stream_class); clock_class = stream_class_get_clock_class(err, stream_class); - bt_object_put_ref(stream_class); + bt_stream_class_put_ref(stream_class); return clock_class; } @@ -773,7 +773,7 @@ int copy_find_clock_int_field(FILE *err, } clock_value = bt_event_get_clock_value(event, clock_class); - BT_OBJECT_PUT_REF_AND_RESET(clock_class); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class); BT_ASSERT(clock_value); ret = bt_clock_value_get_value(clock_value, &value); @@ -793,7 +793,7 @@ 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_OBJECT_PUT_REF_AND_RESET(writer_clock_class); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(writer_clock_class); if (!writer_clock_value) { BT_LOGE_STR("Failed to create clock value."); goto error; diff --git a/plugins/libctfcopytrace/ctfcopytrace.c b/plugins/libctfcopytrace/ctfcopytrace.c index 62ce7425..3ce5663f 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_object_put_ref(clock_class); + bt_clock_class_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_OBJECT_PUT_REF_AND_RESET(writer_clock_class); + BT_CLOCK_CLASS_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_object_put_ref(writer_clock_class); + bt_clock_class_put_ref(writer_clock_class); } ret = BT_COMPONENT_STATUS_OK; @@ -168,8 +168,8 @@ void replace_clock_classes(const struct bt_trace *trace_copy, ret = bt_field_type_integer_set_mapped_clock_class( field_type, clock_class_copy); BT_ASSERT(ret == 0); - bt_object_put_ref(mapped_clock_class); - bt_object_put_ref(clock_class_copy); + bt_clock_class_put_ref(mapped_clock_class); + bt_clock_class_put_ref(clock_class_copy); break; } case BT_FIELD_TYPE_ID_ENUM: @@ -334,7 +334,7 @@ const struct bt_event_class *ctf_copy_event_class(FILE *err, goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_event_class); + BT_EVENT_CLASS_PUT_REF_AND_RESET(writer_event_class); end: BT_OBJECT_PUT_REF_AND_RESET(context); BT_OBJECT_PUT_REF_AND_RESET(payload_type); @@ -373,8 +373,8 @@ enum bt_component_status ctf_copy_event_classes(FILE *err, * event_classes after a trace has become * static. */ - BT_OBJECT_PUT_REF_AND_RESET(writer_event_class); - BT_OBJECT_PUT_REF_AND_RESET(event_class); + BT_EVENT_CLASS_PUT_REF_AND_RESET(writer_event_class); + BT_EVENT_CLASS_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_OBJECT_PUT_REF_AND_RESET(writer_event_class); - BT_OBJECT_PUT_REF_AND_RESET(event_class); + BT_EVENT_CLASS_PUT_REF_AND_RESET(writer_event_class); + BT_EVENT_CLASS_PUT_REF_AND_RESET(event_class); } goto end; error: - bt_object_put_ref(event_class); - bt_object_put_ref(writer_event_class); + bt_event_class_put_ref(event_class); + bt_event_class_put_ref(writer_event_class); end: - bt_object_put_ref(writer_trace); + bt_trace_put_ref(writer_trace); return ret; } @@ -502,7 +502,7 @@ const struct bt_stream_class *ctf_copy_stream_class(FILE *err, goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); + BT_STREAM_CLASS_PUT_REF_AND_RESET(writer_stream_class); end: bt_object_put_ref(type); bt_object_put_ref(type_copy); @@ -668,7 +668,7 @@ int ctf_copy_event_header(FILE *err, const struct bt_event *event, } clock_value = bt_event_get_clock_value(event, clock_class); - BT_OBJECT_PUT_REF_AND_RESET(clock_class); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class); BT_ASSERT(clock_value); ret = bt_clock_value_get_value(clock_value, &value); @@ -685,7 +685,7 @@ int ctf_copy_event_header(FILE *err, const struct bt_event *event, } writer_clock_value = bt_clock_value_create(writer_clock_class, value); - BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(writer_clock_class); if (!writer_clock_value) { BT_LOGE_STR("Failed to create clock value."); goto error; @@ -734,7 +734,7 @@ const struct bt_trace *event_class_get_trace(FILE *err, trace = bt_stream_class_get_trace(stream_class); BT_ASSERT(trace); - bt_object_put_ref(stream_class); + bt_stream_class_put_ref(stream_class); return trace; } @@ -850,7 +850,7 @@ error: end: bt_object_put_ref(field); bt_object_put_ref(copy_field); - bt_object_put_ref(writer_trace); + bt_trace_put_ref(writer_trace); return writer_event; } @@ -881,7 +881,7 @@ enum bt_component_status ctf_copy_trace(FILE *err, const struct bt_trace *trace, ret_int = bt_trace_set_environment_field(writer_trace, name, value); - BT_OBJECT_PUT_REF_AND_RESET(value); + BT_VALUE_PUT_REF_AND_RESET(value); if (ret_int < 0) { BT_LOGE("Failed to set environment: field-name=\"%s\"", name); diff --git a/plugins/lttng-utils/copy.c b/plugins/lttng-utils/copy.c index adb6619e..0a4dbf1d 100644 --- a/plugins/lttng-utils/copy.c +++ b/plugins/lttng-utils/copy.c @@ -45,19 +45,19 @@ const struct bt_stream *insert_new_stream( static void unref_stream(const struct bt_stream *stream) { - bt_object_put_ref(stream); + bt_stream_put_ref(stream); } static void unref_packet(const struct bt_packet *packet) { - bt_object_put_ref(packet); + bt_packet_put_ref(packet); } static void unref_stream_class(const struct bt_stream_class *stream_class) { - bt_object_put_ref(stream_class); + bt_stream_class_put_ref(stream_class); } static @@ -94,7 +94,7 @@ const struct bt_field *get_payload_field(FILE *err, field = bt_field_structure_get_field_by_name(payload, field_name); end: - bt_object_put_ref(payload_class); + bt_field_class_put_ref(payload_class); bt_object_put_ref(payload); return field; } @@ -123,7 +123,7 @@ const struct bt_field *get_stream_event_context_field(FILE *err, field = bt_field_structure_get_field_by_name(sec, field_name); end: - bt_object_put_ref(sec_class); + bt_field_class_put_ref(sec_class); bt_object_put_ref(sec); return field; } @@ -168,7 +168,7 @@ int get_stream_event_context_unsigned_int_field_value(FILE *err, error: ret = -1; end: - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); bt_object_put_ref(field); return ret; } @@ -206,7 +206,7 @@ int get_stream_event_context_int_field_value(FILE *err, const struct bt_event *e error: ret = -1; end: - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); bt_object_put_ref(field); return ret; } @@ -252,7 +252,7 @@ int get_payload_unsigned_int_field_value(FILE *err, error: ret = -1; end: - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); bt_object_put_ref(field); return ret; } @@ -296,7 +296,7 @@ int get_payload_int_field_value(FILE *err, const struct bt_event *event, error: ret = -1; end: - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); bt_object_put_ref(field); return ret; } @@ -340,7 +340,7 @@ int get_payload_string_field_value(FILE *err, error: ret = -1; end: - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); bt_object_put_ref(field); return ret; } @@ -371,7 +371,7 @@ int get_payload_build_id_field_value(FILE *err, BT_LOGE("Wrong type, expected sequence: field-name=\"%s\"", field_name); goto error; } - BT_OBJECT_PUT_REF_AND_RESET(field_class); + BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class); seq_len = bt_field_sequence_get_length(field); BT_ASSERT(seq_len); @@ -417,7 +417,7 @@ error: g_free(*build_id); ret = -1; end: - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); bt_object_put_ref(field); return ret; } @@ -454,7 +454,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it, if (strcmp(str_value, "ust") != 0) { goto end; } - BT_OBJECT_PUT_REF_AND_RESET(field); + BT_VALUE_PUT_REF_AND_RESET(field); /* No tracer_name, no debug info */ field = bt_trace_get_environment_field_value_by_name(writer_trace, @@ -469,7 +469,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it, if (strcmp(str_value, "lttng-ust") != 0) { goto end; } - BT_OBJECT_PUT_REF_AND_RESET(field); + BT_VALUE_PUT_REF_AND_RESET(field); debug_info = debug_info_create(debug_it->debug_info_component); if (!debug_info) { @@ -481,7 +481,7 @@ struct debug_info *insert_new_debug_info(struct debug_info_iterator *debug_it, debug_info); end: - bt_object_put_ref(field); + bt_value_put_ref(field); return debug_info; } @@ -613,8 +613,8 @@ int sync_event_classes(struct debug_info_iterator *debug_it, error: int_ret = -1; end: - bt_object_put_ref(stream_class); - bt_object_put_ref(writer_stream_class); + bt_stream_class_put_ref(stream_class); + bt_stream_class_put_ref(writer_stream_class); return int_ret; } @@ -644,8 +644,8 @@ void trace_is_static_listener(const struct bt_trace *trace, void *data) BT_LOGE_STR("Failed to synchronize the event classes."); goto error; } - BT_OBJECT_PUT_REF_AND_RESET(stream); - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); } bt_trace_set_is_static(di_trace->writer_trace); @@ -660,8 +660,8 @@ void trace_is_static_listener(const struct bt_trace *trace, void *data) } error: - bt_object_put_ref(writer_stream); - bt_object_put_ref(stream); + bt_stream_put_ref(writer_stream); + bt_stream_put_ref(stream); } static @@ -726,14 +726,14 @@ struct debug_info_trace *insert_new_trace(struct debug_info_iterator *debug_it, BT_LOGE_STR("Failed to insert new stream."); goto error; } - bt_object_get_ref(writer_stream); + bt_stream_get_ref(writer_stream); ret = sync_event_classes(debug_it, stream, writer_stream); if (ret) { BT_LOGE_STR("Failed to synchronize event classes."); goto error; } - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); - BT_OBJECT_PUT_REF_AND_RESET(stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(stream); } /* Check if the trace is already static or register a listener. */ @@ -752,14 +752,14 @@ struct debug_info_trace *insert_new_trace(struct debug_info_iterator *debug_it, goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_trace); + BT_TRACE_PUT_REF_AND_RESET(writer_trace); g_free(di_trace); di_trace = NULL; end: - bt_object_put_ref(stream); - bt_object_put_ref(writer_stream); - bt_object_put_ref(stream_class); - bt_object_put_ref(trace); + bt_stream_put_ref(stream); + bt_stream_put_ref(writer_stream); + bt_stream_class_put_ref(stream_class); + bt_trace_put_ref(trace); return di_trace; } @@ -799,7 +799,7 @@ const struct bt_packet *insert_new_packet(struct debug_info_iterator *debug_it, goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_packet); + BT_PACKET_PUT_REF_AND_RESET(writer_packet); end: return writer_packet; } @@ -820,7 +820,7 @@ int add_debug_info_fields(FILE *err, if (!ip_field) { goto end; } - BT_OBJECT_PUT_REF_AND_RESET(ip_field); + BT_FIELD_CLASS_PUT_REF_AND_RESET(ip_field); debug_field_class = bt_field_class_structure_get_field_class_by_name( writer_event_context_class, @@ -886,13 +886,13 @@ int add_debug_info_fields(FILE *err, goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(debug_field_class); + BT_FIELD_CLASS_PUT_REF_AND_RESET(debug_field_class); ret = -1; end: - bt_object_put_ref(src_field_class); - bt_object_put_ref(func_field_class); - bt_object_put_ref(bin_field_class); - bt_object_put_ref(debug_field_class); + bt_field_class_put_ref(src_field_class); + bt_field_class_put_ref(func_field_class); + bt_field_class_put_ref(bin_field_class); + bt_field_class_put_ref(debug_field_class); return ret; } @@ -918,7 +918,7 @@ int create_debug_info_event_context_class(FILE *err, ret = bt_field_class_structure_add_field(writer_event_context_class, field_class, field_name); - BT_OBJECT_PUT_REF_AND_RESET(field_class); + BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class); if (ret) { BT_LOGE("Failed to add a field to the event-context: field-name=\"%s\"", field_name); @@ -997,15 +997,15 @@ const struct bt_stream_class *copy_stream_class_debug_info(FILE *err, BT_LOGE_STR("Failed to set event_context type."); goto error; } - BT_OBJECT_PUT_REF_AND_RESET(writer_event_context_class); + BT_FIELD_CLASS_PUT_REF_AND_RESET(writer_event_context_class); } goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); + BT_STREAM_CLASS_PUT_REF_AND_RESET(writer_stream_class); end: - bt_object_put_ref(writer_event_context_class); + bt_field_class_put_ref(writer_event_context_class); bt_object_put_ref(type); return writer_stream_class; } @@ -1033,14 +1033,14 @@ int add_clock_classes(FILE *err, const 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_object_put_ref(existing_clock_class); + bt_clock_class_put_ref(existing_clock_class); if (existing_clock_class) { - bt_object_put_ref(clock_class); + bt_clock_class_put_ref(clock_class); continue; } ret = bt_trace_add_clock_class(writer_trace, clock_class); - BT_OBJECT_PUT_REF_AND_RESET(clock_class); + BT_CLOCK_CLASS_PUT_REF_AND_RESET(clock_class); if (ret != 0) { BT_LOGE_STR("Failed to add clock_class."); goto error; @@ -1078,7 +1078,7 @@ const struct bt_stream_class *insert_new_stream_class( goto error; } writer_trace = di_trace->writer_trace; - bt_object_get_ref(writer_trace); + bt_trace_get_ref(writer_trace); writer_stream_class = copy_stream_class_debug_info(debug_it->err, stream_class, writer_trace, debug_it->debug_info_component); @@ -1106,10 +1106,10 @@ const struct bt_stream_class *insert_new_stream_class( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class); + BT_STREAM_CLASS_PUT_REF_AND_RESET(writer_stream_class); end: - bt_object_put_ref(trace); - bt_object_put_ref(writer_trace); + bt_trace_put_ref(trace); + bt_trace_put_ref(writer_trace); return writer_stream_class; } @@ -1139,7 +1139,7 @@ const struct bt_stream *insert_new_stream( goto error; } } - bt_object_get_ref(writer_stream_class); + bt_stream_class_get_ref(writer_stream_class); id = bt_stream_get_id(stream); if (id < 0) { @@ -1162,10 +1162,10 @@ const struct bt_stream *insert_new_stream( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); end: - bt_object_put_ref(stream_class); - bt_object_put_ref(writer_stream_class); + bt_stream_class_put_ref(stream_class); + bt_stream_class_put_ref(writer_stream_class); return writer_stream; } @@ -1205,8 +1205,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_OBJECT_PUT_REF_AND_RESET(stream_class); - BT_OBJECT_PUT_REF_AND_RESET(trace); + BT_STREAM_CLASS_PUT_REF_AND_RESET(stream_class); + BT_TRACE_PUT_REF_AND_RESET(trace); return di_trace; } @@ -1233,14 +1233,14 @@ const struct bt_stream *get_writer_stream( BT_LOGE_STR("Failed to find existing stream."); goto error; } - bt_object_get_ref(writer_stream); + bt_stream_get_ref(writer_stream); goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); end: - bt_object_put_ref(stream_class); + bt_stream_class_put_ref(stream_class); return writer_stream; } @@ -1277,7 +1277,7 @@ const struct bt_packet *debug_info_new_packet( writer_packet = lookup_packet(debug_it, packet, di_trace); if (writer_packet) { g_hash_table_remove(di_trace->packet_map, packet); - BT_OBJECT_PUT_REF_AND_RESET(writer_packet); + BT_PACKET_PUT_REF_AND_RESET(writer_packet); } writer_packet = insert_new_packet(debug_it, packet, writer_stream, @@ -1298,15 +1298,15 @@ const struct bt_packet *debug_info_new_packet( BT_OBJECT_PUT_REF_AND_RESET(packet_context); } - bt_object_get_ref(writer_packet); + bt_packet_get_ref(writer_packet); goto end; error: end: bt_object_put_ref(packet_context); - bt_object_put_ref(writer_stream); - bt_object_put_ref(stream); + bt_stream_put_ref(writer_stream); + bt_stream_put_ref(stream); return writer_packet; } @@ -1333,11 +1333,11 @@ const struct bt_packet *debug_info_close_packet( BT_LOGE_STR("Failed to find existing packet."); goto end; } - bt_object_get_ref(writer_packet); + bt_packet_get_ref(writer_packet); g_hash_table_remove(di_trace->packet_map, packet); end: - bt_object_put_ref(stream); + bt_stream_put_ref(stream); return writer_packet; } @@ -1383,12 +1383,12 @@ const struct bt_stream *debug_info_stream_begin( if (!writer_stream) { writer_stream = insert_new_stream(debug_it, stream, di_trace); } - bt_object_get_ref(writer_stream); + bt_stream_get_ref(writer_stream); goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); end: return writer_stream; } @@ -1416,7 +1416,7 @@ const struct bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_ * Take the ref on the stream and keep it until the notification * is created. */ - bt_object_get_ref(writer_stream); + bt_stream_get_ref(writer_stream); state = g_hash_table_lookup(di_trace->stream_states, stream); if (*state != DEBUG_INFO_ACTIVE_STREAM) { @@ -1442,7 +1442,7 @@ const struct bt_stream *debug_info_stream_end(struct debug_info_iterator *debug_ goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_stream); + BT_STREAM_PUT_REF_AND_RESET(writer_stream); end: return writer_stream; @@ -1500,7 +1500,7 @@ int set_debug_info_field(FILE *err, const struct bt_field *debug_field, field_name); goto error; } - BT_OBJECT_PUT_REF_AND_RESET(field_class); + BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class); field = bt_field_structure_get_field_by_index(debug_field, i); if (!strcmp(field_name, "bin")) { @@ -1560,9 +1560,9 @@ int set_debug_info_field(FILE *err, const struct bt_field *debug_field, error: ret = -1; end: - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); bt_object_put_ref(field); - bt_object_put_ref(debug_field_class); + bt_field_class_put_ref(debug_field_class); return ret; } @@ -1654,7 +1654,7 @@ int copy_set_debug_info_stream_event_context(FILE *err, } BT_OBJECT_PUT_REF_AND_RESET(copy_field); } - BT_OBJECT_PUT_REF_AND_RESET(field_class); + BT_FIELD_CLASS_PUT_REF_AND_RESET(field_class); BT_OBJECT_PUT_REF_AND_RESET(field); } @@ -1664,13 +1664,13 @@ int copy_set_debug_info_stream_event_context(FILE *err, error: ret = -1; end: - bt_object_put_ref(event_context_class); - bt_object_put_ref(writer_event_context_class); + bt_field_class_put_ref(event_context_class); + bt_field_class_put_ref(writer_event_context_class); bt_object_put_ref(writer_event_context); bt_object_put_ref(field); bt_object_put_ref(copy_field); bt_object_put_ref(debug_field); - bt_object_put_ref(field_class); + bt_field_class_put_ref(field_class); return ret; } @@ -1692,7 +1692,7 @@ const struct bt_clock_class *stream_class_get_clock_class(FILE *err, /* FIXME multi-clock? */ clock_class = bt_trace_get_clock_class_by_index(trace, 0); - bt_object_put_ref(trace); + bt_trace_put_ref(trace); end: return clock_class; @@ -1715,8 +1715,8 @@ const struct bt_clock_class *event_get_clock_class(FILE *err, const struct bt_ev goto end; end: - bt_object_put_ref(stream_class); - bt_object_put_ref(event_class); + bt_stream_class_put_ref(stream_class); + bt_event_class_put_ref(event_class); return clock_class; } @@ -1756,7 +1756,7 @@ int set_event_clock_value(FILE *err, const struct bt_event *event, error: ret = -1; end: - bt_object_put_ref(clock_class); + bt_clock_class_put_ref(clock_class); bt_object_put_ref(clock_value); return ret; } @@ -1886,7 +1886,7 @@ const struct bt_event *debug_info_output_event( BT_LOGE_STR("Failed to find existing stream_class."); goto error; } - bt_object_get_ref(writer_stream_class); + bt_stream_class_get_ref(writer_stream_class); writer_trace = bt_stream_class_get_trace(writer_stream_class); BT_ASSERT(writer_trace); writer_event_class = get_event_class(debug_it, @@ -1928,7 +1928,7 @@ const struct bt_event *debug_info_output_event( BT_LOGE_STR("Failed to find existing packet."); goto error; } - bt_object_get_ref(writer_packet); + bt_packet_get_ref(writer_packet); int_ret = bt_event_set_packet(writer_event, writer_packet); if (int_ret < 0) { @@ -1944,13 +1944,13 @@ error: BT_OBJECT_PUT_REF_AND_RESET(writer_event); end: - bt_object_put_ref(stream); - bt_object_put_ref(writer_trace); - bt_object_put_ref(writer_packet); - bt_object_put_ref(packet); - bt_object_put_ref(writer_event_class); - bt_object_put_ref(writer_stream_class); - bt_object_put_ref(stream_class); - bt_object_put_ref(event_class); + bt_stream_put_ref(stream); + bt_trace_put_ref(writer_trace); + bt_packet_put_ref(writer_packet); + bt_packet_put_ref(packet); + bt_event_class_put_ref(writer_event_class); + bt_stream_class_put_ref(writer_stream_class); + bt_stream_class_put_ref(stream_class); + bt_event_class_put_ref(event_class); return writer_event; } diff --git a/plugins/lttng-utils/debug-info.c b/plugins/lttng-utils/debug-info.c index 45b0f1c1..ff193c2c 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, const struct bt_event *event, } end_put_class: - bt_object_put_ref(event_class); + bt_event_class_put_ref(event_class); end: return; } diff --git a/plugins/lttng-utils/plugin.c b/plugins/lttng-utils/plugin.c index e3ebc514..6b2f5349 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_object_put_ref(di_trace->writer_trace); + bt_trace_put_ref(di_trace->writer_trace); g_free(di_trace); } @@ -98,7 +98,7 @@ void debug_info_iterator_destroy(struct bt_self_notification_iterator *it) empty_trace_map, it_data); g_hash_table_destroy(it_data->trace_map); - bt_object_put_ref(it_data->current_notification); + bt_notification_put_ref(it_data->current_notification); bt_object_put_ref(it_data->input_iterator); g_free(it_data); @@ -127,8 +127,8 @@ const struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_packet_beginning_create( writer_packet); BT_ASSERT(new_notification); - bt_object_put_ref(packet); - bt_object_put_ref(writer_packet); + bt_packet_put_ref(packet); + bt_packet_put_ref(writer_packet); break; } case BT_NOTIFICATION_TYPE_PACKET_END: @@ -146,8 +146,8 @@ const struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_packet_end_create( writer_packet); BT_ASSERT(new_notification); - bt_object_put_ref(packet); - bt_object_put_ref(writer_packet); + bt_packet_put_ref(packet); + bt_packet_put_ref(writer_packet); break; } case BT_NOTIFICATION_TYPE_EVENT: @@ -187,8 +187,8 @@ const struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_stream_beginning_create( writer_stream); BT_ASSERT(new_notification); - bt_object_put_ref(stream); - bt_object_put_ref(writer_stream); + bt_stream_put_ref(stream); + bt_stream_put_ref(writer_stream); break; } case BT_NOTIFICATION_TYPE_STREAM_END: @@ -206,12 +206,12 @@ const struct bt_notification *handle_notification(FILE *err, new_notification = bt_notification_stream_end_create( writer_stream); BT_ASSERT(new_notification); - bt_object_put_ref(stream); - bt_object_put_ref(writer_stream); + bt_stream_put_ref(stream); + bt_stream_put_ref(writer_stream); break; } default: - new_notification = bt_object_get_ref(notification); + new_notification = bt_notification_get_ref(notification); break; } @@ -258,7 +258,7 @@ 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_object_put_ref(notification); + bt_notification_put_ref(notification); end: bt_object_put_ref(component); @@ -340,7 +340,7 @@ enum bt_component_status init_from_params( tmp = bt_value_string_get(value); strcpy(debug_info_component->arg_debug_info_field_name, tmp); - bt_object_put_ref(value); + bt_value_put_ref(value); } else { debug_info_component->arg_debug_info_field_name = malloc(strlen("debug_info") + 1); @@ -362,7 +362,7 @@ enum bt_component_status init_from_params( debug_info_component->arg_debug_dir = bt_value_string_get(value); } - bt_object_put_ref(value); + bt_value_put_ref(value); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } @@ -373,7 +373,7 @@ enum bt_component_status init_from_params( debug_info_component->arg_target_prefix = bt_value_string_get(value); } - bt_object_put_ref(value); + bt_value_put_ref(value); if (ret != BT_COMPONENT_STATUS_OK) { goto end; } @@ -387,7 +387,7 @@ enum bt_component_status init_from_params( debug_info_component->arg_full_path = bool_val; } - bt_object_put_ref(value); + bt_value_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 c317a7b0..ffe35fde 100644 --- a/plugins/text/dmesg/dmesg.c +++ b/plugins/text/dmesg/dmesg.c @@ -107,10 +107,10 @@ struct bt_field_class *create_event_payload_fc(void) goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(root_fc); + BT_FIELD_CLASS_PUT_REF_AND_RESET(root_fc); end: - bt_object_put_ref(fc); + bt_field_class_put_ref(fc); return root_fc; } @@ -179,7 +179,7 @@ error: ret = -1; end: - bt_object_put_ref(fc); + bt_field_class_put_ref(fc); return ret; } @@ -348,12 +348,12 @@ void destroy_dmesg_component(struct dmesg_component *dmesg_comp) g_string_free(dmesg_comp->params.path, TRUE); } - 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_packet_put_ref(dmesg_comp->packet); + bt_trace_put_ref(dmesg_comp->trace); + bt_stream_class_put_ref(dmesg_comp->stream_class); + bt_event_class_put_ref(dmesg_comp->event_class); + bt_stream_put_ref(dmesg_comp->stream); + bt_clock_class_put_ref(dmesg_comp->clock_class); g_free(dmesg_comp); } @@ -524,7 +524,7 @@ skip_ts: goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(notif); + BT_NOTIFICATION_PUT_REF_AND_RESET(notif); end: return notif; @@ -604,7 +604,7 @@ struct bt_notification *create_notif_from_line( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(notif); + BT_NOTIFICATION_PUT_REF_AND_RESET(notif); end: return notif; @@ -623,7 +623,7 @@ void destroy_dmesg_notif_iter(struct dmesg_notif_iter *dmesg_notif_iter) } } - bt_object_put_ref(dmesg_notif_iter->tmp_event_notif); + bt_notification_put_ref(dmesg_notif_iter->tmp_event_notif); free(dmesg_notif_iter->linebuf); g_free(dmesg_notif_iter); } diff --git a/plugins/text/pretty/pretty.c b/plugins/text/pretty/pretty.c index ae064c5e..846cbdae 100644 --- a/plugins/text/pretty/pretty.c +++ b/plugins/text/pretty/pretty.c @@ -65,7 +65,7 @@ const char *plugin_options[] = { static void destroy_pretty_data(struct pretty_component *pretty) { - bt_object_put_ref(pretty->iterator); + bt_self_component_port_input_notification_iterator_put_ref(pretty->iterator); if (pretty->string) { (void) g_string_free(pretty->string, TRUE); @@ -200,7 +200,8 @@ enum bt_self_component_status pretty_consume( goto end; case BT_NOTIFICATION_ITERATOR_STATUS_END: ret = BT_SELF_COMPONENT_STATUS_END; - BT_OBJECT_PUT_REF_AND_RESET(pretty->iterator); + BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET( + pretty->iterator); goto end; default: ret = BT_SELF_COMPONENT_STATUS_ERROR; @@ -215,12 +216,12 @@ enum bt_self_component_status pretty_consume( goto end; } - bt_object_put_ref(notifs[i]); + bt_notification_put_ref(notifs[i]); } end: for (; i < count; i++) { - bt_object_put_ref(notifs[i]); + bt_notification_put_ref(notifs[i]); } return ret; @@ -592,7 +593,7 @@ int apply_params(struct pretty_component *pretty, const struct bt_value *params) } end: - bt_object_put_ref(pretty->plugin_opt_map); + bt_value_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 3da0fb90..ba4c521e 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_object_put_ref(counter->notif_iter); + bt_self_component_port_input_notification_iterator_put_ref(counter->notif_iter); g_free(counter); } @@ -117,7 +117,7 @@ void counter_finalize(struct bt_self_component_sink *comp) bt_self_component_sink_as_self_component(comp)); BT_ASSERT(counter); try_print_last(counter); - bt_object_put_ref(counter->notif_iter); + bt_self_component_port_input_notification_iterator_put_ref(counter->notif_iter); g_free(counter); } @@ -195,7 +195,8 @@ enum bt_self_component_status counter_port_connected( goto end; } - BT_OBJECT_MOVE_REF(counter->notif_iter, iterator); + BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_MOVE_REF( + counter->notif_iter, iterator); end: return status; @@ -261,7 +262,7 @@ enum bt_self_component_status counter_consume( counter->count.other++; } - bt_object_put_ref(notif); + bt_notification_put_ref(notif); } ret = BT_SELF_COMPONENT_STATUS_OK; diff --git a/plugins/utils/dummy/dummy.c b/plugins/utils/dummy/dummy.c index d6230f72..ebd94674 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_object_put_ref(dummy->notif_iter); + bt_self_component_port_input_notification_iterator_put_ref(dummy->notif_iter); g_free(dummy); } @@ -96,7 +96,8 @@ enum bt_self_component_status dummy_port_connected( goto end; } - BT_OBJECT_MOVE_REF(dummy->notif_iter, iterator); + BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_MOVE_REF( + dummy->notif_iter, iterator); end: return status; @@ -130,7 +131,7 @@ enum bt_self_component_status dummy_consume( ret = BT_SELF_COMPONENT_STATUS_OK; for (i = 0; i < count; i++) { - bt_object_put_ref(notifs[i]); + bt_notification_put_ref(notifs[i]); } break; diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index 1d273beb..4e97a014 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -122,14 +122,14 @@ void destroy_muxer_upstream_notif_iter( muxer_upstream_notif_iter, muxer_upstream_notif_iter->notif_iter, muxer_upstream_notif_iter->notifs->length); - bt_object_put_ref(muxer_upstream_notif_iter->notif_iter); + bt_self_component_port_input_notification_iterator_put_ref(muxer_upstream_notif_iter->notif_iter); if (muxer_upstream_notif_iter->notifs) { const struct bt_notification *notif; while ((notif = g_queue_pop_head( muxer_upstream_notif_iter->notifs))) { - bt_object_put_ref(notif); + bt_notification_put_ref(notif); } g_queue_free(muxer_upstream_notif_iter->notifs); @@ -152,7 +152,7 @@ struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter( } muxer_upstream_notif_iter->notif_iter = self_notif_iter; - bt_object_get_ref(muxer_upstream_notif_iter->notif_iter); + bt_self_component_port_input_notification_iterator_get_ref(muxer_upstream_notif_iter->notif_iter); muxer_upstream_notif_iter->notifs = g_queue_new(); if (!muxer_upstream_notif_iter->notifs) { BT_LOGE_STR("Failed to allocate a GQueue."); @@ -265,7 +265,7 @@ struct bt_value *get_default_params(void) goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(params); + BT_VALUE_PUT_REF_AND_RESET(params); end: return params; @@ -320,8 +320,8 @@ error: ret = -1; end: - bt_object_put_ref(default_params); - bt_object_put_ref(real_params); + bt_value_put_ref(default_params); + bt_value_put_ref(real_params); return ret; } @@ -498,7 +498,7 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next( * won't be considered again to find the youngest * notification. */ - BT_OBJECT_PUT_REF_AND_RESET(muxer_upstream_notif_iter->notif_iter); + BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(muxer_upstream_notif_iter->notif_iter); status = BT_NOTIFICATION_ITERATOR_STATUS_OK; break; default: @@ -568,7 +568,7 @@ int muxer_notif_iter_handle_newly_connected_ports( muxer_upstream_notif_iter = muxer_notif_iter_add_upstream_notif_iter( muxer_notif_iter, upstream_notif_iter); - BT_OBJECT_PUT_REF_AND_RESET(upstream_notif_iter); + BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(upstream_notif_iter); if (!muxer_upstream_notif_iter) { /* * muxer_notif_iter_add_upstream_notif_iter() @@ -578,7 +578,7 @@ int muxer_notif_iter_handle_newly_connected_ports( } remove_node: - bt_object_put_ref(upstream_notif_iter); + bt_self_component_port_input_notification_iterator_put_ref(upstream_notif_iter); muxer_notif_iter->newly_connected_self_ports = g_list_delete_link( muxer_notif_iter->newly_connected_self_ports, diff --git a/plugins/utils/trimmer/copy.c b/plugins/utils/trimmer/copy.c index 79d1e8b2..423a7665 100644 --- a/plugins/utils/trimmer/copy.c +++ b/plugins/utils/trimmer/copy.c @@ -70,7 +70,7 @@ const struct bt_packet *insert_new_packet(struct trimmer_iterator *trim_it, goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_packet); + BT_PACKET_PUT_REF_AND_RESET(writer_packet); end: return writer_packet; } @@ -170,7 +170,7 @@ const 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_OBJECT_PUT_REF_AND_RESET(writer_packet); + BT_PACKET_PUT_REF_AND_RESET(writer_packet); } writer_packet = insert_new_packet(trim_it, packet, stream); @@ -178,7 +178,7 @@ const struct bt_packet *trimmer_new_packet( BT_LOGE_STR("Failed to insert new packet."); goto error; } - bt_object_get_ref(writer_packet); + bt_packet_get_ref(writer_packet); int_ret = ctf_packet_copy_context(trim_it->err, packet, stream, writer_packet); @@ -190,9 +190,9 @@ const struct bt_packet *trimmer_new_packet( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(writer_packet); + BT_PACKET_PUT_REF_AND_RESET(writer_packet); end: - bt_object_put_ref(stream); + bt_stream_put_ref(stream); return writer_packet; } @@ -247,7 +247,7 @@ const struct bt_event *trimmer_output_event( BT_LOGE_STR("Failed to find existing packet."); goto error; } - bt_object_get_ref(writer_packet); + bt_packet_get_ref(writer_packet); int_ret = bt_event_set_packet(writer_event, writer_packet); if (int_ret < 0) { @@ -263,8 +263,8 @@ const struct bt_event *trimmer_output_event( error: BT_OBJECT_PUT_REF_AND_RESET(writer_event); end: - bt_object_put_ref(writer_packet); - bt_object_put_ref(packet); - bt_object_put_ref(event_class); + bt_packet_put_ref(writer_packet); + bt_packet_put_ref(packet); + bt_event_class_put_ref(event_class); return writer_event; } diff --git a/plugins/utils/trimmer/iterator.c b/plugins/utils/trimmer/iterator.c index 29e9951b..0f9d2487 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) { const struct bt_packet *writer_packet = value; - bt_object_put_ref(writer_packet); + bt_packet_put_ref(writer_packet); return TRUE; } @@ -254,14 +254,14 @@ const struct bt_notification *evaluate_event_notification( goto end; error: - BT_OBJECT_PUT_REF_AND_RESET(new_notification); + BT_NOTIFICATION_PUT_REF_AND_RESET(new_notification); end: 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_clock_class_put_ref(clock_class); + bt_trace_put_ref(trace); + bt_stream_put_ref(stream); + bt_stream_class_put_ref(stream_class); bt_object_put_ref(clock_value); *_event_in_range = in_range; return new_notification; @@ -306,8 +306,8 @@ int ns_from_integer_field(const struct bt_field *integer, int64_t *ns) ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ns); end: - bt_object_put_ref(integer_class); - bt_object_put_ref(clock_class); + bt_field_class_put_ref(integer_class); + bt_clock_class_put_ref(clock_class); bt_object_put_ref(clock_value); return ret; } @@ -366,10 +366,10 @@ int64_t get_raw_timestamp(const struct bt_packet *writer_packet, ns += ns_from_value(freq, cycles_offset); - 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); + bt_clock_class_put_ref(writer_clock_class); + bt_trace_put_ref(writer_trace); + bt_stream_class_put_ref(writer_stream_class); + bt_stream_put_ref(writer_stream); return timestamp - ns; } @@ -492,8 +492,8 @@ end: } end_no_notif: *_packet_in_range = in_range; - bt_object_put_ref(packet); - bt_object_put_ref(writer_packet); + bt_packet_put_ref(packet); + bt_packet_put_ref(writer_packet); bt_object_put_ref(packet_context); bt_object_put_ref(timestamp_begin); bt_object_put_ref(timestamp_end); @@ -545,7 +545,7 @@ enum bt_notification_iterator_status evaluate_notification( default: break; } - BT_OBJECT_PUT_REF_AND_RESET(*notification); + BT_NOTIFICATION_PUT_REF_AND_RESET(*notification); *notification = new_notification; if (finished) { diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index 21dc871a..a7bc66d5 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -310,7 +310,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, goto end; } - BT_OBJECT_PUT_REF_AND_RESET(value); + BT_VALUE_PUT_REF_AND_RESET(value); value = bt_value_map_get(params, "begin"); if (value) { if (timestamp_from_param("begin", value, @@ -321,7 +321,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, } } - BT_OBJECT_PUT_REF_AND_RESET(value); + BT_VALUE_PUT_REF_AND_RESET(value); value = bt_value_map_get(params, "end"); if (value) { if (timestamp_from_param("end", value, @@ -333,7 +333,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, } end: - bt_object_put_ref(value); + bt_value_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 11fae932..1eb1fa34 100644 --- a/python-plugin-provider/python-plugin-provider.c +++ b/python-plugin-provider/python-plugin-provider.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -495,7 +494,7 @@ error: BT_OBJECT_PUT_REF_AND_RESET(plugin_set); end: - bt_object_put_ref(plugin); + bt_plugin_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 46e3eec0..beac9725 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -71,7 +71,7 @@ static enum bt_query_status flt_query_method( BT_ASSERT(iret == 0); iret = bt_value_array_append_element(res, val); BT_ASSERT(iret == 0); - bt_object_put_ref(val); + bt_value_put_ref(val); return BT_QUERY_STATUS_OK; } diff --git a/tests/lib/test_bt_notification_iterator.c b/tests/lib/test_bt_notification_iterator.c index f121df05..5a2f9a3e 100644 --- a/tests/lib/test_bt_notification_iterator.c +++ b/tests/lib/test_bt_notification_iterator.c @@ -90,7 +90,7 @@ struct src_iter_user_data { }; struct sink_user_data { - void *notif_iter; + struct bt_self_component_port_input_notification_iterator *notif_iter; }; /* @@ -279,8 +279,8 @@ void init_static_data(void) fprintf(stderr, ":: stream 2, packet 2: %p\n", src_stream2_packet2); } - bt_object_put_ref(trace); - bt_object_put_ref(trace_class); + bt_trace_put_ref(trace); + bt_trace_class_put_ref(trace_class); } static @@ -290,14 +290,14 @@ void fini_static_data(void) g_array_free(test_events, TRUE); /* Metadata */ - 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); + bt_stream_class_put_ref(src_stream_class); + bt_event_class_put_ref(src_event_class); + bt_stream_put_ref(src_stream1); + bt_stream_put_ref(src_stream2); + bt_packet_put_ref(src_stream1_packet1); + bt_packet_put_ref(src_stream1_packet2); + bt_packet_put_ref(src_stream2_packet1); + bt_packet_put_ref(src_stream2_packet2); } static @@ -575,7 +575,7 @@ enum bt_notification_iterator_status common_consume( for (i = 0; i < count; i++) { append_test_events_from_notification(notifications[i]); - bt_object_put_ref(notifications[i]); + bt_notification_put_ref(notifications[i]); } end: @@ -604,7 +604,8 @@ enum bt_self_component_status sink_consume( switch (it_ret) { case BT_NOTIFICATION_ITERATOR_STATUS_END: ret = BT_SELF_COMPONENT_STATUS_END; - BT_OBJECT_PUT_REF_AND_RESET(user_data->notif_iter); + BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET( + user_data->notif_iter); goto end; case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN: abort(); @@ -661,7 +662,8 @@ void sink_finalize(struct bt_self_component_sink *self_comp) self_comp)); if (user_data) { - bt_object_put_ref(user_data->notif_iter); + BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET( + user_data->notif_iter); g_free(user_data); } } @@ -695,7 +697,7 @@ void create_source_sink(struct bt_graph *graph, ret = bt_graph_add_source_component(graph, src_comp_class, "source", NULL, source); BT_ASSERT(ret == 0); - bt_object_put_ref(src_comp_class); + bt_component_class_source_put_ref(src_comp_class); } /* Create sink component */ @@ -715,7 +717,7 @@ void create_source_sink(struct bt_graph *graph, sink_comp_class, "sink", NULL, sink); BT_ASSERT(ret == 0); - bt_object_put_ref(sink_comp_class); + bt_component_class_sink_put_ref(sink_comp_class); } } @@ -763,9 +765,9 @@ void do_std_test(enum test test, const char *name, "the produced sequence of test events is the expected one"); } - bt_object_put_ref(src_comp); - bt_object_put_ref(sink_comp); - BT_OBJECT_PUT_REF_AND_RESET(graph); + bt_component_source_put_ref(src_comp); + bt_component_sink_put_ref(sink_comp); + BT_GRAPH_PUT_REF_AND_RESET(graph); } static @@ -852,9 +854,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_object_put_ref(src_comp); - BT_OBJECT_PUT_REF_AND_RESET(graph); - bt_object_put_ref(notif_iter); + bt_component_source_put_ref(src_comp); + BT_GRAPH_PUT_REF_AND_RESET(graph); + bt_port_output_notification_iterator_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 9b9cd3a4..e88535e5 100644 --- a/tests/lib/test_bt_values.c +++ b/tests/lib/test_bt_values.c @@ -33,9 +33,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_object_get_ref(bt_value_null); + bt_value_get_ref(bt_value_null); pass("getting bt_value_null does not cause a crash"); - bt_object_put_ref(bt_value_null); + bt_value_put_ref(bt_value_null); pass("putting bt_value_null does not cause a crash"); } @@ -58,7 +58,7 @@ void test_bool(void) value = bt_value_bool_get(obj); ok(value, "bt_value_bool_set() works"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); pass("putting an existing boolean value object does not cause a crash") value = BT_FALSE; @@ -69,7 +69,7 @@ void test_bool(void) ok(value, "bt_value_bool_create_init() sets the appropriate initial value"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); } static @@ -90,7 +90,7 @@ void test_integer(void) value = bt_value_integer_get(obj); ok(value == -98765, "bt_private_integer_bool_set() works"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); pass("putting an existing integer value object does not cause a crash") obj = bt_value_integer_create_init(321456987); @@ -100,7 +100,7 @@ void test_integer(void) ok(value == 321456987, "bt_value_integer_create_init() sets the appropriate initial value"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); } static @@ -122,7 +122,7 @@ void test_real(void) value = bt_value_real_get(obj); ok(value == -3.1416, "bt_value_real_set() works"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_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); @@ -132,7 +132,7 @@ void test_real(void) ok(value == 33.1649758, "bt_value_real_create_init() sets the appropriate initial value"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); } static @@ -154,7 +154,7 @@ void test_string(void) ok(value && !strcmp(value, "hello worldz"), "bt_value_string_get() works"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_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"); @@ -164,7 +164,7 @@ void test_string(void) ok(value && !strcmp(value, "initial value"), "bt_value_string_create_init() sets the appropriate initial value"); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); } static @@ -186,13 +186,13 @@ void test_array(void) obj = bt_value_integer_create_init(345); ret = bt_value_array_append_element(array_obj, obj); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); obj = bt_value_real_create_init(-17.45); ret |= bt_value_array_append_element(array_obj, obj); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); obj = bt_value_bool_create_init(BT_TRUE); ret |= bt_value_array_append_element(array_obj, obj); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); ret |= bt_value_array_append_element(array_obj, bt_value_null); ok(!ret, "bt_value_array_append_element() succeeds"); @@ -225,7 +225,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_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_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"); @@ -291,7 +291,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_OBJECT_PUT_REF_AND_RESET(array_obj); + BT_VALUE_PUT_REF_AND_RESET(array_obj); pass("putting an existing array value object does not cause a crash") } @@ -487,13 +487,13 @@ void test_map(void) obj = bt_value_integer_create_init(19457); ret = bt_value_map_insert_entry(map_obj, "int", obj); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); obj = bt_value_real_create_init(5.444); ret |= bt_value_map_insert_entry(map_obj, "real", obj); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_PUT_REF_AND_RESET(obj); obj = bt_value_bool_create(); ret |= bt_value_map_insert_entry(map_obj, "bt_bool", obj); - BT_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_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"); @@ -502,7 +502,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_OBJECT_PUT_REF_AND_RESET(obj); + BT_VALUE_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"); @@ -589,7 +589,7 @@ void test_map(void) checklist.array2 && checklist.map2, "bt_value_map_foreach_entry() iterates over all the map value object's elements"); - BT_OBJECT_PUT_REF_AND_RESET(map_obj); + BT_VALUE_PUT_REF_AND_RESET(map_obj); pass("putting an existing map value object does not cause a crash") } @@ -633,9 +633,9 @@ void test_compare_bool(void) bool3), "boolean value objects are equivalent (BT_FALSE and BT_FALSE)"); - BT_OBJECT_PUT_REF_AND_RESET(bool1); - BT_OBJECT_PUT_REF_AND_RESET(bool2); - BT_OBJECT_PUT_REF_AND_RESET(bool3); + BT_VALUE_PUT_REF_AND_RESET(bool1); + BT_VALUE_PUT_REF_AND_RESET(bool2); + BT_VALUE_PUT_REF_AND_RESET(bool3); } static @@ -659,9 +659,9 @@ void test_compare_integer(void) int3), "integer value objects are equivalent (10 and 10)"); - BT_OBJECT_PUT_REF_AND_RESET(int1); - BT_OBJECT_PUT_REF_AND_RESET(int2); - BT_OBJECT_PUT_REF_AND_RESET(int3); + BT_VALUE_PUT_REF_AND_RESET(int1); + BT_VALUE_PUT_REF_AND_RESET(int2); + BT_VALUE_PUT_REF_AND_RESET(int3); } static @@ -686,9 +686,9 @@ void test_compare_real(void) real3), "real number value objects are equivalent (17.38 and 17.38)"); - BT_OBJECT_PUT_REF_AND_RESET(real1); - BT_OBJECT_PUT_REF_AND_RESET(real2); - BT_OBJECT_PUT_REF_AND_RESET(real3); + BT_VALUE_PUT_REF_AND_RESET(real1); + BT_VALUE_PUT_REF_AND_RESET(real2); + BT_VALUE_PUT_REF_AND_RESET(real3); } static @@ -713,9 +713,9 @@ void test_compare_string(void) string3), "string value objects are equivalent (\"hello\" and \"hello\")"); - BT_OBJECT_PUT_REF_AND_RESET(string1); - BT_OBJECT_PUT_REF_AND_RESET(string2); - BT_OBJECT_PUT_REF_AND_RESET(string3); + BT_VALUE_PUT_REF_AND_RESET(string1); + BT_VALUE_PUT_REF_AND_RESET(string2); + BT_VALUE_PUT_REF_AND_RESET(string3); } static @@ -764,9 +764,9 @@ void test_compare_array(void) array3), "array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])"); - BT_OBJECT_PUT_REF_AND_RESET(array1); - BT_OBJECT_PUT_REF_AND_RESET(array2); - BT_OBJECT_PUT_REF_AND_RESET(array3); + BT_VALUE_PUT_REF_AND_RESET(array1); + BT_VALUE_PUT_REF_AND_RESET(array2); + BT_VALUE_PUT_REF_AND_RESET(array3); } static @@ -819,9 +819,9 @@ void test_compare_map(void) map3), "map value objects are equivalent"); - BT_OBJECT_PUT_REF_AND_RESET(map1); - BT_OBJECT_PUT_REF_AND_RESET(map2); - BT_OBJECT_PUT_REF_AND_RESET(map3); + BT_VALUE_PUT_REF_AND_RESET(map1); + BT_VALUE_PUT_REF_AND_RESET(map2); + BT_VALUE_PUT_REF_AND_RESET(map3); } static @@ -920,13 +920,13 @@ void test_copy(void) map_copy_obj), "source and destination value objects have the same content"); - 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); + BT_VALUE_PUT_REF_AND_RESET(map_copy_obj); + BT_VALUE_PUT_REF_AND_RESET(bool_obj); + BT_VALUE_PUT_REF_AND_RESET(integer_obj); + BT_VALUE_PUT_REF_AND_RESET(real_obj); + BT_VALUE_PUT_REF_AND_RESET(string_obj); + BT_VALUE_PUT_REF_AND_RESET(array_obj); + BT_VALUE_PUT_REF_AND_RESET(map_obj); } static @@ -997,10 +997,10 @@ void test_extend(void) extended_map, "project"), "bt_value_map_extend() picks the appropriate element (project)"); - 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); + BT_VALUE_PUT_REF_AND_RESET(array); + BT_VALUE_PUT_REF_AND_RESET(base_map); + BT_VALUE_PUT_REF_AND_RESET(extension_map); + BT_VALUE_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 c3608701..c2cef117 100644 --- a/tests/lib/test_ctf_writer.c +++ b/tests/lib/test_ctf_writer.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -193,7 +192,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_object_put_ref(returned_type); + bt_ctf_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 +315,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_object_put_ref(returned_type); + bt_ctf_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 +325,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_OBJECT_PUT_REF_AND_RESET(event_context_type); - BT_OBJECT_PUT_REF_AND_RESET(event_payload_type); + BT_CTF_OBJECT_PUT_REF_AND_RESET(event_context_type); + BT_CTF_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 +351,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_object_put_ref(ret_event_class); + bt_ctf_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_object_put_ref(ret_event_class); + bt_ctf_object_put_ref(ret_event_class); simple_event = bt_ctf_event_create(simple_event_class); ok(simple_event, @@ -386,7 +385,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_OBJECT_PUT_REF_AND_RESET(iter); + BT_CTF_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 +433,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_object_put_ref(packet_context_field); + bt_ctf_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 +445,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_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); + bt_ctf_object_put_ref(simple_event_class); + bt_ctf_object_put_ref(simple_event); + bt_ctf_object_put_ref(uint_12_type); + bt_ctf_object_put_ref(int_64_type); + bt_ctf_object_put_ref(float_type); + bt_ctf_object_put_ref(enum_type); + bt_ctf_object_put_ref(enum_type_unsigned); + bt_ctf_object_put_ref(returned_type); + bt_ctf_object_put_ref(event_context_type); + bt_ctf_object_put_ref(integer_field); + bt_ctf_object_put_ref(float_field); + bt_ctf_object_put_ref(enum_field); + bt_ctf_object_put_ref(enum_field_unsigned); + bt_ctf_object_put_ref(enum_container_field); + bt_ctf_object_put_ref(enum_container_field_unsigned); + bt_ctf_object_put_ref(packet_context); + bt_ctf_object_put_ref(packet_context_field); + bt_ctf_object_put_ref(stream_event_context); + bt_ctf_object_put_ref(stream_event_context_field); + bt_ctf_object_put_ref(event_context); + bt_ctf_object_put_ref(event_context_field); + bt_ctf_object_put_ref(event_payload_type); + bt_ctf_object_put_ref(ep_integer_field_type); + bt_ctf_object_put_ref(ep_enum_field_type); + bt_ctf_object_put_ref(ep_enum_field_unsigned_type); + bt_ctf_object_put_ref(iter); } static @@ -544,7 +543,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_object_put_ref(ret_field_type); + bt_ctf_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 +576,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_object_put_ref(ret_field_type); + bt_ctf_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 +585,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_object_put_ref(ret_field_type); + bt_ctf_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_object_put_ref(ret_field_type); + bt_ctf_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 +601,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_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(ret_field_type); ok(!bt_ctf_field_type_structure_add_field(complex_structure_type, enum_variant_type, "variant_selector"), @@ -679,13 +678,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_object_put_ref(ret_stream_class); + bt_ctf_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_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(ret_field_type); event = bt_ctf_event_create(event_class); ok(event, "Instanciate a complex event"); @@ -693,7 +692,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_object_put_ref(ret_event_class); + bt_ctf_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 +702,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_object_put_ref(uint_35_field); + bt_ctf_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 +711,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_object_put_ref(int_16_field); + bt_ctf_object_put_ref(int_16_field); complex_structure_field = bt_ctf_event_get_payload(event, "complex_structure"); @@ -720,8 +719,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_object_put_ref(inner_structure_field); - bt_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(inner_structure_field); + bt_ctf_object_put_ref(ret_field_type); inner_structure_field = bt_ctf_field_structure_get_field_by_name( complex_structure_field, "inner_structure"); @@ -744,7 +743,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_object_put_ref(int_16_field); + bt_ctf_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 +774,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_object_put_ref(int_16_field); + bt_ctf_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_object_put_ref(int_16_field); + bt_ctf_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_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_field); + BT_CTF_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_field); bt_ctf_field_integer_unsigned_set_value(stream_event_ctx_int_field, 17); - BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_int_field); + BT_CTF_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 +808,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_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); + bt_ctf_object_put_ref(uint_35_field); + bt_ctf_object_put_ref(a_string_field); + bt_ctf_object_put_ref(inner_structure_field); + bt_ctf_object_put_ref(complex_structure_field); + bt_ctf_object_put_ref(a_sequence_field); + bt_ctf_object_put_ref(an_array_field); + bt_ctf_object_put_ref(enum_variant_field); + bt_ctf_object_put_ref(enum_container_field); + bt_ctf_object_put_ref(variant_field); + bt_ctf_object_put_ref(packet_context_field); + bt_ctf_object_put_ref(packet_context); + bt_ctf_object_put_ref(uint_35_type); + bt_ctf_object_put_ref(int_16_type); + bt_ctf_object_put_ref(string_type); + bt_ctf_object_put_ref(sequence_type); + bt_ctf_object_put_ref(array_type); + bt_ctf_object_put_ref(inner_structure_type); + bt_ctf_object_put_ref(complex_structure_type); + bt_ctf_object_put_ref(uint_3_type); + bt_ctf_object_put_ref(enum_variant_type); + bt_ctf_object_put_ref(variant_type); + bt_ctf_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(event_class); + bt_ctf_object_put_ref(event); } static @@ -939,7 +938,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_object_put_ref(returned_type); + bt_ctf_object_put_ref(returned_type); string_type = bt_ctf_field_type_string_create(); ok(string_type, "Create a string type"); @@ -975,7 +974,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_object_put_ref(returned_type); + bt_ctf_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 +985,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_object_put_ref(returned_type); + bt_ctf_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_object_put_ref(returned_type); + bt_ctf_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 +1005,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_object_put_ref(returned_type); + bt_ctf_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 +1044,18 @@ void type_field_tests() ok(enumeration_type, "Create an enumeration type with an unsigned 12-bit integer as container"); - 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); + bt_ctf_object_put_ref(string); + bt_ctf_object_put_ref(uint_12); + bt_ctf_object_put_ref(int_16); + bt_ctf_object_put_ref(composite_structure_type); + bt_ctf_object_put_ref(structure_seq_type); + bt_ctf_object_put_ref(string_type); + bt_ctf_object_put_ref(sequence_type); + bt_ctf_object_put_ref(uint_8_type); + bt_ctf_object_put_ref(int_16_type); + bt_ctf_object_put_ref(uint_12_type); + bt_ctf_object_put_ref(enumeration_type); + bt_ctf_object_put_ref(returned_type); } static @@ -1114,9 +1113,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_object_put_ref(ret_field_type); - bt_object_put_ref(ret_field); - bt_object_put_ref(event); + bt_ctf_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(ret_field); + bt_ctf_object_put_ref(event); for (i = 0; i < packet_resize_test_length; i++) { event = bt_ctf_event_create(event_class); @@ -1129,24 +1128,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_object_put_ref(integer); + bt_ctf_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_object_put_ref(string); + bt_ctf_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_OBJECT_PUT_REF_AND_RESET(stream_event_context); + BT_CTF_OBJECT_PUT_REF_AND_RESET(stream_event_context); ret |= bt_ctf_field_integer_unsigned_set_value(integer, i % 42); - bt_object_put_ref(integer); + bt_ctf_object_put_ref(integer); ret |= bt_ctf_stream_append_event(stream, event); - bt_object_put_ref(event); + bt_ctf_object_put_ref(event); if (ret) { break; @@ -1179,15 +1178,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_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); + bt_ctf_object_put_ref(integer_type); + bt_ctf_object_put_ref(string_type); + bt_ctf_object_put_ref(packet_context); + bt_ctf_object_put_ref(packet_context_field); + bt_ctf_object_put_ref(stream_event_context); + bt_ctf_object_put_ref(event_class); + bt_ctf_object_put_ref(ep_field_1_type); + bt_ctf_object_put_ref(ep_a_string_type); + bt_ctf_object_put_ref(ep_type); } static @@ -1233,10 +1232,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_object_put_ref(trace); - bt_object_put_ref(ret_trace); - bt_object_put_ref(stream); - bt_object_put_ref(stream_class); + bt_ctf_object_put_ref(trace); + bt_ctf_object_put_ref(ret_trace); + bt_ctf_object_put_ref(stream); + bt_ctf_object_put_ref(stream_class); } static @@ -1348,7 +1347,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_object_put_ref(integer); + bt_ctf_object_put_ref(integer); event = bt_ctf_event_create(event_class); if (!event) { @@ -1387,7 +1386,7 @@ void test_custom_event_header_stream(struct bt_ctf_writer *writer, fail("Failed to set sequence length"); goto end; } - bt_object_put_ref(integer); + bt_ctf_object_put_ref(integer); for (i = 0; i < 2; i++) { integer = bt_ctf_field_sequence_get_field(sequence, i); @@ -1402,7 +1401,7 @@ void test_custom_event_header_stream(struct bt_ctf_writer *writer, goto end; } - bt_object_put_ref(integer); + bt_ctf_object_put_ref(integer); integer = NULL; } @@ -1417,17 +1416,17 @@ void test_custom_event_header_stream(struct bt_ctf_writer *writer, fail("Failed to flush custom_event_header stream"); } end: - 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); + bt_ctf_object_put_ref(stream); + bt_ctf_object_put_ref(stream_class); + bt_ctf_object_put_ref(event_class); + bt_ctf_object_put_ref(event); + bt_ctf_object_put_ref(integer); + bt_ctf_object_put_ref(sequence); + bt_ctf_object_put_ref(event_header); + bt_ctf_object_put_ref(packet_header); + bt_ctf_object_put_ref(sequence_type); + bt_ctf_object_put_ref(integer_type); + bt_ctf_object_put_ref(event_header_type); } static @@ -1524,14 +1523,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_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); + bt_ctf_object_put_ref(stream); + bt_ctf_object_put_ref(ret_stream); + bt_ctf_object_put_ref(stream_class); + bt_ctf_object_put_ref(event_class); + bt_ctf_object_put_ref(event); + bt_ctf_object_put_ref(integer_type); + bt_ctf_object_put_ref(integer); + bt_ctf_object_put_ref(payload_field); } static @@ -1544,7 +1543,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_object_put_ref(event_class); + bt_ctf_object_put_ref(event_class); event_class = bt_ctf_event_class_create("different name, ok"); BT_ASSERT(event_class); @@ -1552,7 +1551,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_object_put_ref(event_class); + bt_ctf_object_put_ref(event_class); } static @@ -1572,7 +1571,7 @@ void test_clock_utils(void) ret = bt_ctf_clock_set_frequency(clock, 1534); BT_ASSERT(!ret); - BT_OBJECT_PUT_REF_AND_RESET(clock); + BT_CTF_OBJECT_PUT_REF_AND_RESET(clock); } int main(int argc, char **argv) @@ -1809,7 +1808,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_object_put_ref(ret_clock); + bt_ctf_object_put_ref(ret_clock); /* Test the event fields and event types APIs */ type_field_tests(); @@ -1838,7 +1837,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_object_put_ref(event_header_field_type); + bt_ctf_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"); @@ -1847,8 +1846,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_object_put_ref(event_header_field_type); - bt_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(event_header_field_type); + bt_ctf_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); @@ -1859,15 +1858,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_object_put_ref(ret_field_type); + bt_ctf_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_object_put_ref(ret_field_type); + bt_ctf_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_object_put_ref(ret_field_type); + bt_ctf_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, @@ -1922,7 +1921,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_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(ret_field_type); /* Instantiate a stream and append events */ @@ -1938,7 +1937,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_OBJECT_PUT_REF_AND_RESET(stream); + BT_CTF_OBJECT_PUT_REF_AND_RESET(stream); /* * Creating a stream through a writer adds the given stream @@ -1957,9 +1956,9 @@ int main(int argc, char **argv) * event context types were copied for the resolving * process */ - 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); + BT_CTF_OBJECT_PUT_REF_AND_RESET(packet_header_type); + BT_CTF_OBJECT_PUT_REF_AND_RESET(packet_context_type); + BT_CTF_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 = @@ -2009,7 +2008,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_object_put_ref(ret_field_type); + bt_ctf_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, @@ -2050,22 +2049,22 @@ int main(int argc, char **argv) bt_ctf_writer_flush_metadata(writer); - 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); + bt_ctf_object_put_ref(clock); + bt_ctf_object_put_ref(ret_stream_class); + bt_ctf_object_put_ref(writer); + bt_ctf_object_put_ref(stream1); + bt_ctf_object_put_ref(packet_context_type); + bt_ctf_object_put_ref(packet_context_field_type); + bt_ctf_object_put_ref(integer_type); + bt_ctf_object_put_ref(stream_event_context_type); + bt_ctf_object_put_ref(ret_field_type); + bt_ctf_object_put_ref(packet_header_type); + bt_ctf_object_put_ref(packet_header_field_type); + bt_ctf_object_put_ref(packet_header); + bt_ctf_object_put_ref(packet_header_field); + bt_ctf_object_put_ref(trace); free(metadata_string); - bt_object_put_ref(stream_class); + bt_ctf_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 720dfb06..4f04fb48 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -731,8 +731,8 @@ void init_test(void) static void fini_test(void) { - bt_object_put_ref(src_comp_class); - bt_object_put_ref(sink_comp_class); + bt_component_class_source_put_ref(src_comp_class); + bt_component_class_sink_put_ref(sink_comp_class); g_array_free(events, TRUE); } @@ -973,9 +973,9 @@ void test_sink_removes_port_in_consume_then_src_removes_disconnected_port(void) ok(graph_port_removed_src_pos < graph_port_removed_sink_pos, "event order is good (13)"); - bt_object_put_ref(graph); - bt_object_put_ref(sink); - bt_object_put_ref(src); + bt_graph_put_ref(graph); + bt_component_sink_put_ref(sink); + bt_component_source_put_ref(src); } static @@ -1139,9 +1139,9 @@ void test_sink_removes_port_in_consume(void) ok(graph_ports_disconnected_pos < graph_port_removed_sink_pos, "event order is good (11)"); - bt_object_put_ref(sink); - bt_object_put_ref(src); - bt_object_put_ref(graph); + bt_component_sink_put_ref(sink); + bt_component_source_put_ref(src); + bt_graph_put_ref(graph); } static @@ -1268,9 +1268,9 @@ 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_object_put_ref(src); - bt_object_put_ref(sink); - bt_object_put_ref(graph); + bt_component_source_put_ref(src); + bt_component_sink_put_ref(sink); + bt_graph_put_ref(graph); } static @@ -1378,9 +1378,9 @@ void test_simple(void) ok(sink_accept_port_connection_pos < sink_port_connected_pos, "event order is good (4)"); - bt_object_put_ref(sink); - bt_object_put_ref(graph); - bt_object_put_ref(src); + bt_component_sink_put_ref(sink); + bt_graph_put_ref(graph); + bt_component_source_put_ref(src); } static @@ -1464,10 +1464,10 @@ void test_src_port_connected_error(void) ok(src_accept_port_connection_pos < src_port_connected_pos, "event order is good (1)"); - bt_object_put_ref(graph); - bt_object_put_ref(sink); - bt_object_put_ref(src); - bt_object_put_ref(conn); + bt_graph_put_ref(graph); + bt_component_sink_put_ref(sink); + bt_component_source_put_ref(src); + bt_connection_put_ref(conn); } static @@ -1574,10 +1574,10 @@ void test_sink_port_connected_error(void) ok(sink_port_connected_pos < src_port_disconnected_pos, "event order is good (3)"); - bt_object_put_ref(conn); - bt_object_put_ref(graph); - bt_object_put_ref(sink); - bt_object_put_ref(src); + bt_connection_put_ref(conn); + bt_graph_put_ref(graph); + bt_component_sink_put_ref(sink); + bt_component_source_put_ref(src); } static @@ -1588,7 +1588,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_object_put_ref(graph); + bt_graph_put_ref(graph); } int main(int argc, char **argv) diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index a8ddcb50..c8fc32d7 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -100,7 +100,7 @@ static void test_minimal(const char *plugin_dir) "bt_plugin_get_filter_component_class_count() returns the expected value"); ok(bt_plugin_get_sink_component_class_count(plugin) == 0, "bt_plugin_get_sink_component_class_count() returns the expected value"); - bt_object_put_ref(plugin_set); + bt_plugin_set_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"); @@ -189,23 +189,23 @@ static void test_sfs(const char *plugin_dir) ok(bt_value_compare(res_params, params), "bt_component_class_query() receives the expected parameters"); - bt_object_get_ref(sink_comp_class); + bt_component_class_sink_get_ref(sink_comp_class); diag("> putting the plugin set object here"); - BT_OBJECT_PUT_REF_AND_RESET(plugin_set); + BT_PLUGIN_SET_PUT_REF_AND_RESET(plugin_set); graph = bt_graph_create(); BT_ASSERT(graph); graph_ret = bt_graph_add_sink_component(graph, sink_comp_class, "the-sink", NULL, &sink_component); ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component, "bt_graph_add_sink_component() still works after the plugin object is destroyed"); - BT_OBJECT_PUT_REF_AND_RESET(sink_component); - bt_object_put_ref(graph); + BT_COMPONENT_SINK_PUT_REF_AND_RESET(sink_component); + bt_graph_put_ref(graph); free(sfs_path); - bt_object_put_ref(sink_comp_class); - bt_object_put_ref(results); - bt_object_put_ref(params); - bt_object_put_ref(query_exec); + bt_component_class_sink_put_ref(sink_comp_class); + bt_value_put_ref(results); + bt_value_put_ref(params); + bt_query_executor_put_ref(query_exec); } static void test_create_all_from_dir(const char *plugin_dir) @@ -226,7 +226,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_object_put_ref(plugin_set); + bt_plugin_set_put_ref(plugin_set); } static void test_find(const char *plugin_dir) @@ -251,7 +251,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_OBJECT_PUT_REF_AND_RESET(plugin); + BT_PLUGIN_PUT_REF_AND_RESET(plugin); free(plugin_path); } diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index 9f9da406..1c827892 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -89,9 +89,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_OBJECT_PUT_REF_AND_RESET(ui8); - BT_OBJECT_PUT_REF_AND_RESET(ui16); - BT_OBJECT_PUT_REF_AND_RESET(ui32); + BT_FIELD_CLASS_PUT_REF_AND_RESET(ui8); + BT_FIELD_CLASS_PUT_REF_AND_RESET(ui16); + BT_FIELD_CLASS_PUT_REF_AND_RESET(ui32); return structure; } @@ -146,7 +146,7 @@ static struct bt_event_class *create_simple_event( BT_ASSERT(payload); ret = bt_event_class_set_payload_field_class(event, payload); BT_ASSERT(ret == 0); - BT_OBJECT_PUT_REF_AND_RESET(payload); + BT_FIELD_CLASS_PUT_REF_AND_RESET(payload); return event; } @@ -182,8 +182,8 @@ static struct bt_event_class *create_complex_event( BT_ASSERT(ret == 0); ret = bt_event_class_set_payload_field_class(event, outer); BT_ASSERT(ret == 0); - BT_OBJECT_PUT_REF_AND_RESET(inner); - BT_OBJECT_PUT_REF_AND_RESET(outer); + BT_FIELD_CLASS_PUT_REF_AND_RESET(inner); + BT_FIELD_CLASS_PUT_REF_AND_RESET(outer); return event; } @@ -203,14 +203,14 @@ 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_object_put_ref(fc); + bt_field_class_put_ref(fc); fc = bt_field_class_unsigned_integer_create(); BT_ASSERT(fc); bt_field_class_integer_set_field_value_range(fc, 32); ret = bt_field_class_structure_append_member(packet_context_type, "content_size", fc); BT_ASSERT(ret == 0); - bt_object_put_ref(fc); + bt_field_class_put_ref(fc); event_header_type = bt_field_class_structure_create(); BT_ASSERT(event_header_type); fc = bt_field_class_unsigned_integer_create(); @@ -219,15 +219,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_object_put_ref(fc); + bt_field_class_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_object_put_ref(packet_context_type); - bt_object_put_ref(event_header_type); + bt_field_class_put_ref(packet_context_type); + bt_field_class_put_ref(event_header_type); } static void create_sc1(struct bt_trace_class *trace_class) @@ -249,9 +249,9 @@ static void create_sc1(struct bt_trace_class *trace_class) 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_OBJECT_PUT_REF_AND_RESET(ec1); - BT_OBJECT_PUT_REF_AND_RESET(ec2); - BT_OBJECT_PUT_REF_AND_RESET(sc1); + BT_EVENT_CLASS_PUT_REF_AND_RESET(ec1); + BT_EVENT_CLASS_PUT_REF_AND_RESET(ec2); + BT_STREAM_CLASS_PUT_REF_AND_RESET(sc1); } static void create_sc2(struct bt_trace_class *trace_class) @@ -268,8 +268,8 @@ static void create_sc2(struct bt_trace_class *trace_class) 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_OBJECT_PUT_REF_AND_RESET(ec3); - BT_OBJECT_PUT_REF_AND_RESET(sc2); + BT_EVENT_CLASS_PUT_REF_AND_RESET(ec3); + BT_STREAM_CLASS_PUT_REF_AND_RESET(sc2); } static void set_trace_packet_header(struct bt_trace_class *trace_class) @@ -286,12 +286,12 @@ static void set_trace_packet_header(struct bt_trace_class *trace_class) ret = bt_field_class_structure_append_member(packet_header_type, "stream_id", fc); BT_ASSERT(ret == 0); - bt_object_put_ref(fc); + bt_field_class_put_ref(fc); ret = bt_trace_class_set_packet_header_field_class(trace_class, packet_header_type); BT_ASSERT(ret == 0); - bt_object_put_ref(packet_header_type); + bt_field_class_put_ref(packet_header_type); } static struct bt_trace_class *create_tc1(void) @@ -362,7 +362,7 @@ static void test_example_scenario(void) /* User A acquires a reference to SC2 from TC1. */ user_a.sc = bt_trace_class_borrow_stream_class_by_index( user_a.tc, 1); - bt_object_get_ref(user_a.sc); + bt_stream_class_get_ref(user_a.sc); 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"); @@ -372,7 +372,7 @@ static void test_example_scenario(void) /* User A acquires a reference to EC3 from SC2. */ user_a.ec = bt_stream_class_borrow_event_class_by_index( user_a.sc, 0); - bt_object_get_ref(user_a.ec); + bt_event_class_get_ref(user_a.ec); ok(user_a.ec, "User A acquires EC3 from SC2"); ok(bt_object_get_ref_count((void *) weak_tc1) == 2, "TC1 reference count is 2"); @@ -383,7 +383,7 @@ static void test_example_scenario(void) /* User A releases its reference to SC2. */ diag("User A releases SC2"); - BT_OBJECT_PUT_REF_AND_RESET(user_a.sc); + BT_STREAM_CLASS_PUT_REF_AND_RESET(user_a.sc); /* * We keep the pointer to SC2 around to validate its reference * count. @@ -397,7 +397,7 @@ static void test_example_scenario(void) /* User A releases its reference to TC1. */ diag("User A releases TC1"); - BT_OBJECT_PUT_REF_AND_RESET(user_a.tc); + BT_TRACE_CLASS_PUT_REF_AND_RESET(user_a.tc); /* * We keep the pointer to TC1 around to validate its reference * count. @@ -412,7 +412,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 = weak_sc1; - bt_object_get_ref(user_b.sc); + bt_stream_class_get_ref(user_b.sc); 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, @@ -422,7 +422,7 @@ static void test_example_scenario(void) diag("User C acquires a reference to EC1"); user_c.ec = bt_stream_class_borrow_event_class_by_index( user_b.sc, 0); - bt_object_get_ref(user_c.ec); + bt_event_class_get_ref(user_c.ec); ok(bt_object_get_ref_count((void *) weak_ec1) == 1, "EC1 reference count is 1"); ok(bt_object_get_ref_count((void *) weak_sc1) == 2, @@ -430,7 +430,7 @@ static void test_example_scenario(void) /* User A releases its reference on EC3. */ diag("User A releases its reference on EC3"); - BT_OBJECT_PUT_REF_AND_RESET(user_a.ec); + BT_EVENT_CLASS_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, @@ -440,7 +440,7 @@ static void test_example_scenario(void) /* User B releases its reference on SC1. */ diag("User B releases its reference on SC1"); - BT_OBJECT_PUT_REF_AND_RESET(user_b.sc); + BT_STREAM_CLASS_PUT_REF_AND_RESET(user_b.sc); ok(bt_object_get_ref_count((void *) weak_sc1) == 1, "SC1 reference count is 1"); @@ -462,7 +462,7 @@ static void test_example_scenario(void) "EC3 reference count is 0"); /* Reclaim last reference held by User C. */ - BT_OBJECT_PUT_REF_AND_RESET(user_c.ec); + BT_EVENT_CLASS_PUT_REF_AND_RESET(user_c.ec); } static void create_writer_user_full(struct writer_user *user) -- 2.34.1