struct bt_config_component *comp = g_ptr_array_index(comps, i);
if (strcmp(name, comp->instance_name->str) == 0) {
- found_comp = bt_get(comp);
+ found_comp = bt_object_get_ref(comp);
goto end;
}
}
struct bt_config_component *comp;
comp = find_component(cfg, connection->upstream_comp_name->str);
- bt_put(comp);
+ bt_object_put_ref(comp);
if (!comp) {
snprintf(error_buf, error_buf_size,
"Invalid connection: cannot find upstream component `%s`:\n %s\n",
}
comp = find_component(cfg, connection->downstream_comp_name->str);
- bt_put(comp);
+ bt_object_put_ref(comp);
if (!comp) {
snprintf(error_buf, error_buf_size,
"Invalid connection: cannot find downstream component `%s`:\n %s\n",
goto end;
}
- BT_PUT(src_comp);
- BT_PUT(dst_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(src_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(dst_comp);
}
end:
- bt_put(src_comp);
- bt_put(dst_comp);
+ bt_object_put_ref(src_comp);
+ bt_object_put_ref(dst_comp);
return ret;
}
}
end:
- bt_put(connected_components);
+ bt_object_put_ref(connected_components);
return ret;
}
}
end:
- bt_put(flat_connection_names);
+ bt_object_put_ref(flat_connection_names);
if (flat_connection_name) {
g_string_free(flat_connection_name, TRUE);
error:
*retcode = 1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
- bt_put(initial_plugin_paths);
+ bt_object_put_ref(initial_plugin_paths);
return cfg;
}
}
end:
- BT_PUT(value);
+ BT_OBJECT_PUT_REF_AND_RESET(value);
return ret;
}
goto end;
error:
- BT_PUT(state.params);
+ BT_OBJECT_PUT_REF_AND_RESET(state.params);
end:
if (state.scanner) {
g_string_free(bt_config_component->instance_name, TRUE);
}
- BT_PUT(bt_config_component->params);
+ BT_OBJECT_PUT_REF_AND_RESET(bt_config_component->params);
g_free(bt_config_component);
end:
goto end;
error:
- BT_PUT(cfg_component);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg_component);
end:
return cfg_component;
goto end;
error:
- BT_PUT(cfg_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg_comp);
end:
g_free(name);
goto end;
}
- BT_PUT(cfg->plugin_paths);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg->plugin_paths);
switch (cfg->command) {
case BT_CONFIG_COMMAND_RUN:
case BT_CONFIG_COMMAND_LIST_PLUGINS:
break;
case BT_CONFIG_COMMAND_HELP:
- BT_PUT(cfg->cmd_data.help.cfg_component);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg->cmd_data.help.cfg_component);
break;
case BT_CONFIG_COMMAND_QUERY:
- BT_PUT(cfg->cmd_data.query.cfg_component);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg->cmd_data.query.cfg_component);
if (cfg->cmd_data.query.object) {
g_string_free(cfg->cmd_data.query.object, TRUE);
return names;
error:
- BT_PUT(names);
+ BT_OBJECT_PUT_REF_AND_RESET(names);
if (scanner) {
g_scanner_destroy(scanner);
}
goto end;
error:
- BT_PUT(fields);
+ BT_OBJECT_PUT_REF_AND_RESET(fields);
end:
if (scanner) {
struct bt_config_component *cfg_comp,
enum bt_config_component_dest dest)
{
- bt_get(cfg_comp);
+ bt_object_get_ref(cfg_comp);
switch (dest) {
case BT_CONFIG_COMPONENT_DEST_SOURCE:
cfg->command_needs_plugins = needs_plugins;
if (initial_plugin_paths) {
- cfg->plugin_paths = bt_get(initial_plugin_paths);
+ cfg->plugin_paths = bt_object_get_ref(initial_plugin_paths);
} else {
cfg->plugin_paths = bt_value_array_create();
if (!cfg->plugin_paths) {
goto end;
error:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
return cfg;
}
cfg->cmd_data.run.sources = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
if (!cfg->cmd_data.run.sources) {
print_err_oom();
goto error;
}
cfg->cmd_data.run.filters = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
if (!cfg->cmd_data.run.filters) {
print_err_oom();
goto error;
}
cfg->cmd_data.run.sinks = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
if (!cfg->cmd_data.run.sinks) {
print_err_oom();
goto error;
goto end;
error:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
return cfg;
goto end;
error:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
return cfg;
goto end;
error:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
return cfg;
goto end;
error:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
return cfg;
goto end;
error:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
return cfg;
goto end;
error:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
return cfg;
case OPT_HELP:
print_help_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
default:
printf_err("Unknown command-line option specified (option code %d)\n",
} else {
print_help_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
}
error:
*retcode = 1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
g_free(plugin_name);
break;
case OPT_PARAMS:
{
- bt_put(params);
+ bt_object_put_ref(params);
params = bt_value_from_arg(arg);
if (!params) {
printf_err("Invalid format for --params option's argument:\n %s\n",
case OPT_HELP:
print_query_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
default:
printf_err("Unknown command-line option specified (option code %d)\n",
}
BT_ASSERT(params);
- BT_MOVE(cfg->cmd_data.query.cfg_component->params, params);
+ BT_OBJECT_MOVE_REF(cfg->cmd_data.query.cfg_component->params, params);
} else {
print_query_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
}
} else {
print_query_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
}
error:
*retcode = 1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
if (pc) {
poptFreeContext(pc);
}
- bt_put(params);
+ bt_object_put_ref(params);
free(arg);
return cfg;
}
case OPT_HELP:
print_list_plugins_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
default:
printf_err("Unknown command-line option specified (option code %d)\n",
error:
*retcode = 1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
if (pc) {
ret = add_run_cfg_comp_check_name(cfg,
cur_cfg_comp, cur_cfg_comp_dest,
instance_names);
- BT_PUT(cur_cfg_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(cur_cfg_comp);
if (ret) {
goto error;
}
}
BT_ASSERT(cur_base_params);
- bt_put(cur_cfg_comp->params);
+ bt_object_put_ref(cur_cfg_comp->params);
cur_cfg_comp->params = bt_value_copy(cur_base_params);
if (!cur_cfg_comp->params) {
print_err_oom();
params_to_set = bt_value_map_extend(cur_cfg_comp->params,
params);
- BT_PUT(params);
+ BT_OBJECT_PUT_REF_AND_RESET(params);
if (!params_to_set) {
printf_err("Cannot extend current component parameters with --params option's argument:\n %s\n",
arg);
goto error;
}
- BT_MOVE(cur_cfg_comp->params, params_to_set);
+ BT_OBJECT_MOVE_REF(cur_cfg_comp->params, params_to_set);
break;
}
case OPT_KEY:
goto error;
}
- BT_MOVE(cur_base_params, params);
+ BT_OBJECT_MOVE_REF(cur_base_params, params);
break;
}
case OPT_RESET_BASE_PARAMS:
- BT_PUT(cur_base_params);
+ BT_OBJECT_PUT_REF_AND_RESET(cur_base_params);
cur_base_params = bt_value_map_create();
if (!cur_base_params) {
print_err_oom();
case OPT_HELP:
print_run_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
default:
printf_err("Unknown command-line option specified (option code %d)\n",
if (cur_cfg_comp) {
ret = add_run_cfg_comp_check_name(cfg, cur_cfg_comp,
cur_cfg_comp_dest, instance_names);
- BT_PUT(cur_cfg_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(cur_cfg_comp);
if (ret) {
goto error;
}
error:
*retcode = 1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
if (pc) {
}
free(arg);
- BT_PUT(cur_cfg_comp);
- BT_PUT(cur_base_params);
- BT_PUT(instance_names);
- BT_PUT(connection_args);
+ BT_OBJECT_PUT_REF_AND_RESET(cur_cfg_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(cur_base_params);
+ BT_OBJECT_PUT_REF_AND_RESET(instance_names);
+ BT_OBJECT_PUT_REF_AND_RESET(connection_args);
return cfg;
}
g_string_free(args->params_arg, TRUE);
}
- bt_put(args->extra_params);
+ bt_object_put_ref(args->extra_params);
}
static
* We need our own copy of the extra parameters because
* this is where the unique path goes.
*/
- BT_PUT(impl_args->extra_params);
+ BT_OBJECT_PUT_REF_AND_RESET(impl_args->extra_params);
impl_args->extra_params =
bt_value_copy(base_implicit_ctf_input_args->extra_params);
if (!impl_args->extra_params) {
struct implicit_component_args implicit_debug_info_args = { 0 };
struct implicit_component_args implicit_muxer_args = { 0 };
struct implicit_component_args implicit_trimmer_args = { 0 };
- struct bt_value *plugin_paths = bt_get(initial_plugin_paths);
+ struct bt_value *plugin_paths = bt_object_get_ref(initial_plugin_paths);
char error_buf[256] = { 0 };
size_t i;
struct bt_common_lttng_live_url_parts lttng_live_url_parts = { 0 };
case OPT_HELP:
print_convert_usage(stdout);
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
case OPT_BEGIN:
case OPT_CLOCK_CYCLES:
ret = insert_flat_params_from_array(
implicit_text_args.params_arg,
fields, "field");
- bt_put(fields);
+ bt_object_put_ref(fields);
if (ret) {
goto error;
}
ret = insert_flat_params_from_array(
implicit_text_args.params_arg,
names, "name");
- bt_put(names);
+ bt_object_put_ref(names);
if (ret) {
goto error;
}
}
*retcode = -1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
goto end;
}
error:
*retcode = 1;
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
end:
if (pc) {
g_ptr_array_free(implicit_ctf_inputs_args, TRUE);
}
- bt_put(run_args);
- bt_put(all_names);
+ bt_object_put_ref(run_args);
+ bt_object_put_ref(all_names);
destroy_glist_of_gstring(source_names);
destroy_glist_of_gstring(filter_names);
destroy_glist_of_gstring(sink_names);
finalize_implicit_component_args(&implicit_debug_info_args);
finalize_implicit_component_args(&implicit_muxer_args);
finalize_implicit_component_args(&implicit_trimmer_args);
- bt_put(plugin_paths);
+ bt_object_put_ref(plugin_paths);
bt_common_destroy_lttng_live_url_parts(<tng_live_url_parts);
return cfg;
}
goto end;
}
} else {
- bt_get(initial_plugin_paths);
+ bt_object_get_ref(initial_plugin_paths);
}
if (argc <= 1) {
}
end:
- bt_put(initial_plugin_paths);
+ bt_object_put_ref(initial_plugin_paths);
return config;
}
#include <stdlib.h>
#include <stdint.h>
#include <babeltrace/values.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/component-class.h>
#include <stdint.h>
#include <stdbool.h>
#include <babeltrace/values.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/component-class.h>
struct bt_config_component *bt_config_get_component(GPtrArray *array,
size_t index)
{
- return bt_get(g_ptr_array_index(array, index));
+ return bt_object_get_ref(g_ptr_array_index(array, index));
}
enum bt_value_status bt_config_append_plugin_paths(
static
void init_static_data(void)
{
- loaded_plugins = g_ptr_array_new_with_free_func(bt_put);
+ loaded_plugins = g_ptr_array_new_with_free_func(bt_object_put_ref);
}
static
static
void destroy_the_query_executor(void)
{
- BT_PUT(the_query_executor);
+ BT_OBJECT_PUT_REF_AND_RESET(the_query_executor);
}
static
end:
destroy_the_query_executor();
- bt_put(result);
+ bt_object_put_ref(result);
return ret;
}
}
}
- return bt_get(plugin);
+ return bt_object_get_ref(plugin);
}
static
comp_class = bt_plugin_get_component_class_by_name_and_type(plugin,
comp_class_name, comp_class_type);
- BT_PUT(plugin);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
end:
if (BT_LOG_ON_DEBUG) {
struct bt_config_component *cfg_component =
bt_config_get_component(array, i);
print_bt_config_component(cfg_component);
- BT_PUT(cfg_component);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg_component);
}
}
bt_plugin_get_name(plugin),
bt_plugin_get_path(plugin),
bt_plugin_get_path(loaded_plugin));
- bt_put(loaded_plugin);
+ bt_object_put_ref(loaded_plugin);
} else {
/* Add to global array. */
BT_LOGD("Adding plugin to loaded plugins: plugin-path=\"%s\"",
bt_plugin_get_name(plugin));
- g_ptr_array_add(loaded_plugins, bt_get(plugin));
+ g_ptr_array_add(loaded_plugins, bt_object_get_ref(plugin));
}
- bt_put(plugin);
+ bt_object_put_ref(plugin);
}
}
}
add_to_loaded_plugins(plugin_set);
- bt_put(plugin_set);
+ bt_object_put_ref(plugin_set);
}
end:
return ret;
}
add_to_loaded_plugins(plugin_set);
- bt_put(plugin_set);
+ bt_object_put_ref(plugin_set);
end:
return ret;
}
ret = -1;
end:
- bt_put(comp_cls);
- bt_put(results);
+ bt_object_put_ref(comp_cls);
+ bt_object_put_ref(results);
return ret;
}
goto end;
}
- bt_put(needed_comp_cls);
+ bt_object_put_ref(needed_comp_cls);
}
for (i = 0; i < bt_plugin_get_component_class_count(plugin); i++) {
if (strcmp(cfg->cmd_data.help.cfg_component->comp_cls_name->str,
comp_class_name) != 0 ||
type != cfg->cmd_data.help.cfg_component->type) {
- bt_put(comp_cls);
+ bt_object_put_ref(comp_cls);
continue;
}
}
printf("\n%s\n", comp_class_help);
}
- bt_put(comp_cls);
+ bt_object_put_ref(comp_cls);
}
end:
- bt_put(plugin);
+ bt_object_put_ref(plugin);
return ret;
}
}
printf("\n");
- bt_put(comp_class);
+ bt_object_put_ref(comp_class);
}
}
ret = -1;
end:
- bt_put(results);
- bt_put(params);
- bt_put(comp_cls);
+ bt_object_put_ref(results);
+ bt_object_put_ref(params);
+ bt_object_put_ref(comp_cls);
if (out_stream && out_stream != stdout) {
int fclose_ret = fclose(out_stream);
end:
destroy_the_query_executor();
- bt_put(results);
- bt_put(params);
- bt_put(comp_cls);
+ bt_object_put_ref(results);
+ bt_object_put_ref(params);
+ bt_object_put_ref(comp_cls);
if (out_stream && out_stream != stdout) {
int fclose_ret = fclose(out_stream);
/* Skip port if it's already connected. */
if (bt_port_is_connected(downstream_port)) {
- bt_put(downstream_port);
+ bt_object_put_ref(downstream_port);
BT_LOGD("Skipping downstream port: already connected: "
"port-addr=%p, port-name=\"%s\"",
downstream_port,
if (!bt_common_star_glob_match(
cfg_conn->downstream_port_glob->str, SIZE_MAX,
downstream_port_name, SIZE_MAX)) {
- bt_put(downstream_port);
+ bt_object_put_ref(downstream_port);
continue;
}
* Replace the current downstream port by the trimmer's
* upstream port.
*/
- BT_MOVE(downstream_port, trimmer_input);
+ BT_OBJECT_MOVE_REF(downstream_port, trimmer_input);
downstream_port_name = bt_port_get_name(
downstream_port);
if (!downstream_port_name) {
/* We have a winner! */
status = bt_graph_connect_ports(ctx->graph,
upstream_port, downstream_port, NULL);
- BT_PUT(downstream_port);
+ BT_OBJECT_PUT_REF_AND_RESET(downstream_port);
switch (status) {
case BT_GRAPH_STATUS_OK:
break;
end:
free(intersection_begin);
free(intersection_end);
- BT_PUT(trimmer_params);
- BT_PUT(trimmer_class);
- BT_PUT(trimmer);
- BT_PUT(trimmer_input);
- BT_PUT(trimmer_output);
+ BT_OBJECT_PUT_REF_AND_RESET(trimmer_params);
+ BT_OBJECT_PUT_REF_AND_RESET(trimmer_class);
+ BT_OBJECT_PUT_REF_AND_RESET(trimmer);
+ BT_OBJECT_PUT_REF_AND_RESET(trimmer_input);
+ BT_OBJECT_PUT_REF_AND_RESET(trimmer_output);
return ret;
}
ret = -1;
end:
- bt_put(upstream_comp);
+ bt_object_put_ref(upstream_comp);
return ret;
}
}
end:
- bt_put(comp);
+ bt_object_put_ref(comp);
return;
}
upstream_port, bt_port_get_name(upstream_port),
downstream_comp, bt_component_get_name(downstream_comp),
downstream_port, bt_port_get_name(downstream_port));
- bt_put(upstream_comp);
- bt_put(downstream_comp);
+ bt_object_put_ref(upstream_comp);
+ bt_object_put_ref(downstream_comp);
}
static
ctx->intersections = NULL;
}
- BT_PUT(ctx->graph);
+ BT_OBJECT_PUT_REF_AND_RESET(ctx->graph);
the_graph = NULL;
ctx->cfg = NULL;
}
ctx->cfg = cfg;
ctx->connect_ports = false;
ctx->components = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, bt_put);
+ NULL, bt_object_put_ref);
if (!ctx->components) {
goto error;
}
path ? path : "(unknown)",
bt_common_color_reset());
end:
- bt_put(query_params);
- bt_put(query_result);
+ bt_object_put_ref(query_params);
+ bt_object_put_ref(query_result);
g_free(port_id);
g_free(trace_range);
return ret;
g_hash_table_insert(ctx->components,
GUINT_TO_POINTER(quark), comp);
comp = NULL;
- BT_PUT(comp_cls);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_cls);
}
goto end;
ret = -1;
end:
- bt_put(comp);
- bt_put(comp_cls);
+ bt_object_put_ref(comp);
+ bt_object_put_ref(comp_cls);
return ret;
}
BT_ASSERT(upstream_port);
ret = cmd_run_ctx_connect_upstream_port(ctx, upstream_port);
- bt_put(upstream_port);
+ bt_object_put_ref(upstream_port);
if (ret) {
goto end;
}
retcode = ret ? 1 : 0;
end:
- BT_PUT(cfg);
+ BT_OBJECT_PUT_REF_AND_RESET(cfg);
fini_static_data();
return retcode;
}
babeltraceinclude_HEADERS = \
babeltrace/babeltrace.h \
babeltrace/logging.h \
- babeltrace/ref.h \
+ babeltrace/object.h \
babeltrace/types.h \
babeltrace/values.h \
babeltrace/version.h
/* Core API */
#include <babeltrace/logging.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
#include <babeltrace/version.h>
*/
#include <stdint.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#ifdef __cplusplus
static inline
void bt_ctf_clock_get(struct bt_ctf_clock *clock)
{
- bt_get(clock);
+ bt_object_get_ref(clock);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_clock_put(struct bt_ctf_clock *clock)
{
- bt_put(clock);
+ bt_object_put_ref(clock);
}
extern struct bt_ctf_clock_class *bt_ctf_clock_class_create(const char *name,
goto end;
}
- bt_put(event_class->context_field_type);
- event_class->context_field_type = bt_get(context_ft);
+ bt_object_put_ref(event_class->context_field_type);
+ event_class->context_field_type = bt_object_get_ref(context_ft);
BT_LOGV("Set event class's context field type: "
"event-class-addr=%p, event-class-name=\"%s\", "
"event-class-id=%" PRId64 ", context-ft-addr=%p",
goto end;
}
- bt_put(event_class->payload_field_type);
- event_class->payload_field_type = bt_get(payload_ft);
+ bt_object_put_ref(event_class->payload_field_type);
+ event_class->payload_field_type = bt_object_get_ref(payload_ft);
BT_LOGV("Set event class's payload field type: "
"event-class-addr=%p, event-class-name=\"%s\", "
"event-class-id=%" PRId64 ", payload-ft-addr=%p",
* http://www.efficios.com/ctf
*/
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/ctf-writer/field-types.h>
#include <babeltrace/ctf-writer/fields.h>
* bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
* field's reference count.
*
- * You may also use bt_get() and bt_put() with field objects.
+ * You may also use bt_object_get_ref() and bt_object_put_ref() with field objects.
*
* These functions ensure that the field won't be destroyed when it
* is in use. The same number of get and put (plus one extra put to
static inline
void bt_ctf_field_get(struct bt_ctf_field *field)
{
- bt_get(field);
+ bt_object_get_ref(field);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_field_put(struct bt_ctf_field *field)
{
- bt_put(field);
+ bt_object_put_ref(field);
}
#ifdef __cplusplus
* common ancestor with it to guarantee they would both have the
* same lifetime.
*/
- bt_put(event->class);
+ bt_object_put_ref(event->class);
}
}
* http://www.efficios.com/ctf
*/
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/ctf-writer/field-types.h>
#ifdef __cplusplus
* bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
* the field type's reference count.
*
- * You may also use bt_get() and bt_put() with field type objects.
+ * You may also use bt_object_get_ref() and bt_object_put_ref() with field type objects.
*
* These functions ensure that the field type won't be destroyed while it
* is in use. The same number of get and put (plus one extra put to
static inline
void bt_ctf_field_type_get(struct bt_ctf_field_type *type)
{
- bt_get(type);
+ bt_object_get_ref(type);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_field_type_put(struct bt_ctf_field_type *type)
{
- bt_put(type);
+ bt_object_put_ref(type);
}
#ifdef __cplusplus
* http://www.efficios.com/ctf
*/
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#ifdef __cplusplus
extern "C" {
static inline
void bt_ctf_event_get(struct bt_ctf_event *event)
{
- bt_get(event);
+ bt_object_get_ref(event);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_event_put(struct bt_ctf_event *event)
{
- bt_put(event);
+ bt_object_put_ref(event);
}
extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
static inline
void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class)
{
- bt_get(event_class);
+ bt_object_get_ref(event_class);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class)
{
- bt_put(event_class);
+ bt_object_put_ref(event_class);
}
#ifdef __cplusplus
BT_ASSERT(ft);
bt_object_init(&field->base, is_shared, release_func);
field->methods = methods;
- field->type = bt_get(ft);
+ field->type = bt_object_get_ref(ft);
}
static inline
{
BT_ASSERT(field);
BT_LOGD_STR("Putting field's type.");
- bt_put(field->type);
+ bt_object_put_ref(field->type);
}
static inline
goto end;
}
- bt_put(stream_class->packet_context_field_type);
- bt_get(packet_context_type);
+ bt_object_put_ref(stream_class->packet_context_field_type);
+ bt_object_get_ref(packet_context_type);
stream_class->packet_context_field_type = packet_context_type;
BT_LOGV("Set stream class's packet context field type: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
goto end;
}
- bt_put(stream_class->event_header_field_type);
- stream_class->event_header_field_type = bt_get(event_header_type);
+ bt_object_put_ref(stream_class->event_header_field_type);
+ stream_class->event_header_field_type = bt_object_get_ref(event_header_type);
BT_LOGV("Set stream class's event header field type: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
"event-header-ft-addr=%p",
goto end;
}
- bt_put(stream_class->event_context_field_type);
- stream_class->event_context_field_type = bt_get(event_context_type);
+ bt_object_put_ref(stream_class->event_context_field_type);
+ stream_class->event_context_field_type = bt_object_get_ref(event_context_type);
BT_LOGV("Set stream class's event context field type: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
"event-context-ft-addr=%p",
* http://www.efficios.com/ctf
*/
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#ifdef __cplusplus
extern "C" {
static inline
void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class)
{
- bt_get(stream_class);
+ bt_object_get_ref(stream_class);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class)
{
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
}
#ifdef __cplusplus
static inline
void bt_ctf_stream_get(struct bt_ctf_stream *stream)
{
- bt_get(stream);
+ bt_object_get_ref(stream);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_stream_put(struct bt_ctf_stream *stream)
{
- bt_put(stream);
+ bt_object_put_ref(stream);
}
#ifdef __cplusplus
CTF IR object of a CTF IR object wrapper.
A CTF IR object wrapper has <strong>no reference count</strong>: do \em
-not use bt_put() or bt_get() on it.
+not use bt_object_put_ref() or bt_object_get_ref() on it.
@sa ctfirvisitor
*/
\p object.
\p object has <strong>no reference count</strong>: do \em not use
-bt_put() or bt_get() on it.
+bt_object_put_ref() or bt_object_get_ref() on it.
@param[in] object Currently visited CTF IR object wrapper.
@param[in] data User data.
wrapper \p object.
The reference count of \p object is \em not incremented by this
-function. On success, you must call bt_get() on the return value to
+function. On success, you must call bt_object_get_ref() on the return value to
have your own reference.
@param[in] object Object wrapper of which to get the wrapped
static inline
void bt_ctf_writer_get(struct bt_ctf_writer *writer)
{
- bt_get(writer);
+ bt_object_get_ref(writer);
}
/* Pre-2.0 CTF writer compatibility */
static inline
void bt_ctf_writer_put(struct bt_ctf_writer *writer)
{
- bt_put(writer);
+ bt_object_put_ref(writer);
}
#ifdef __cplusplus
/* For bt_bool */
#include <babeltrace/types.h>
-/* For bt_get */
-#include <babeltrace/ref.h>
+/* For bt_object_get_ref */
+#include <babeltrace/object.h>
#ifdef __cplusplus
extern "C" {
static inline
struct bt_graph *bt_component_get_graph(struct bt_component *component)
{
- return bt_get(bt_component_borrow_graph(component));
+ return bt_object_get_ref(bt_component_borrow_graph(component));
}
#ifdef __cplusplus
* SOFTWARE.
*/
-/* For bt_get() */
-#include <babeltrace/ref.h>
+/* For bt_object_get_ref() */
+#include <babeltrace/object.h>
#ifdef __cplusplus
extern "C" {
* SOFTWARE.
*/
-/* For bt_get() */
-#include <babeltrace/ref.h>
+/* For bt_object_get_ref() */
+#include <babeltrace/object.h>
#include <stdint.h>
* SOFTWARE.
*/
-/* For bt_get() */
-#include <babeltrace/ref.h>
+/* For bt_object_get_ref() */
+#include <babeltrace/object.h>
#ifdef __cplusplus
extern "C" {
struct bt_packet *bt_notification_packet_begin_get_packet(
struct bt_notification *notification)
{
- return bt_get(bt_notification_packet_begin_borrow_packet(notification));
+ return bt_object_get_ref(bt_notification_packet_begin_borrow_packet(notification));
}
extern struct bt_packet *bt_notification_packet_end_borrow_packet(
struct bt_packet *bt_notification_packet_end_get_packet(
struct bt_notification *notification)
{
- return bt_get(bt_notification_packet_end_borrow_packet(notification));
+ return bt_object_get_ref(bt_notification_packet_end_borrow_packet(notification));
}
#ifdef __cplusplus
#include <stdint.h>
-/* For bt_get() */
-#include <babeltrace/ref.h>
+/* For bt_object_get_ref() */
+#include <babeltrace/object.h>
/* For bt_bool */
#include <babeltrace/types.h>
struct bt_stream *bt_notification_stream_begin_get_stream(
struct bt_notification *notification)
{
- return bt_get(bt_notification_stream_begin_borrow_stream(notification));
+ return bt_object_get_ref(bt_notification_stream_begin_borrow_stream(notification));
}
extern int bt_notification_stream_begin_set_default_clock_value(
struct bt_stream *bt_notification_stream_end_get_stream(
struct bt_notification *notification)
{
- return bt_get(bt_notification_stream_end_borrow_stream(notification));
+ return bt_object_get_ref(bt_notification_stream_end_borrow_stream(notification));
}
extern int bt_notification_stream_end_set_default_clock_value(
--- /dev/null
+#ifndef BABELTRACE_OBJECT_H
+#define BABELTRACE_OBJECT_H
+
+/*
+ * BabelTrace: common reference counting
+ *
+ * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
+ * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
+ * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace/object.h>
+@endcode
+
+The macros and functions of this module are everything that is needed
+to handle the <strong><em>reference counting</em></strong> of
+Babeltrace objects.
+
+Any Babeltrace object can be shared by multiple owners thanks to
+<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
+counting</a>.
+
+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 <strong>borrows the
+ reference</strong> for the <strong>duration of the function</strong>.
+
+ @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 <strong>never
+ transferred</strong> 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 <strong>new reference</strong>. 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
+ <strong>borrowed</strong>, or <strong>weak reference</strong>: 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 <strong>If \p _var does not contain \p NULL</strong>,
+ 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 <strong>If \p _var_dst and \p _var_src contain the same
+ value which is not \c NULL</strong>, this object's reference
+ count is greater than 1.
+@post <strong>If \c _var_dst is not \c NULL</strong>, 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 <strong>If \c obj is not \c NULL</strong>, its reference
+ count is incremented.
+
+@sa bt_object_put_ref(): Decrements the reference count of a Babeltrace object.
+*/
+void *bt_object_get_ref(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 <strong>If \c obj is not \c NULL</strong>, 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(void *obj);
+
+/**
+@}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_OBJECT_H */
/* Create empty array of component classes */
plugin->comp_classes =
- g_ptr_array_new_with_free_func((GDestroyNotify) bt_put);
+ g_ptr_array_new_with_free_func((GDestroyNotify) bt_object_put_ref);
if (!plugin->comp_classes) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
goto error;
goto end;
error:
- BT_PUT(plugin);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
end:
return plugin;
bt_object_init_shared(&plugin_set->base, bt_plugin_set_destroy);
plugin_set->plugins = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
if (!plugin_set->plugins) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
- BT_PUT(plugin_set);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
goto end;
}
{
BT_ASSERT(plugin_set);
BT_ASSERT(plugin);
- g_ptr_array_add(plugin_set->plugins, bt_get(plugin));
+ g_ptr_array_add(plugin_set->plugins, bt_object_get_ref(plugin));
BT_LOGV("Added plugin to plugin set: "
"plugin-set-addr=%p, plugin-addr=%p, plugin-name=\"%s\", "
"plugin-path=\"%s\"",
+++ /dev/null
-#ifndef BABELTRACE_REF_H
-#define BABELTRACE_REF_H
-
-/*
- * BabelTrace: common reference counting
- *
- * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
- * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <babeltrace/ref.h>
-@endcode
-
-The macros and functions of this module are everything that is needed
-to handle the <strong><em>reference counting</em></strong> of
-Babeltrace objects.
-
-Any Babeltrace object can be shared by multiple owners thanks to
-<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
-counting</a>.
-
-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 <strong>borrows the
- reference</strong> for the <strong>duration of the function</strong>.
-
- @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 <strong>never
- transferred</strong> 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_put()).
-
-2. An API function which \em returns a Babeltrace object pointer to the
- user returns a <strong>new reference</strong>. 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_put().
-
- 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
- <strong>borrowed</strong>, or <strong>weak reference</strong>: if you
- need a reference which is more persistent than the duration of the
- user function, call bt_get() on the pointer.
-
- @image html ref-count-callback.png
-
- For example, see bt_value_map_foreach_entry().
-
-The two macros BT_PUT() and BT_MOVE() operate on \em variables rather
-than pointer values. You should use BT_PUT() instead of bt_put() when
-possible to avoid "double puts". For the same reason, you should use use
-BT_MOVE() instead of performing manual reference moves between
-variables.
-
-@file
-@brief Reference counting management macros and functions.
-@sa refs
-
-@addtogroup refs
-@{
-*/
-
-/**
-@brief Calls bt_put() on a variable named \p _var, then
- sets \p _var to \c NULL.
-
-Using this macro is considered safer than calling bt_put() because it
-makes sure that the variable which used to contain a reference to a
-Babeltrace object is set to \c NULL so that a future BT_PUT() or
-bt_put() call will not cause another, unwanted reference decrementation.
-
-@param[in,out] _var Name of a variable containing a
- Babeltrace object's address (this address
- can be \c NULL).
-
-@post <strong>If \p _var does not contain \p NULL</strong>,
- its reference count is decremented.
-@post \p _var contains \c NULL.
-
-@sa BT_MOVE(): Transfers the ownership of a Babeltrace object from a
- variable to another.
-*/
-#define BT_PUT(_var) \
- do { \
- bt_put(_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_put() 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_put() 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 <strong>If \p _var_dst and \p _var_src contain the same
- value which is not \c NULL</strong>, this object's reference
- count is greater than 1.
-@post <strong>If \c _var_dst is not \c NULL</strong>, 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_PUT(): Calls bt_put() on a variable, then sets it to \c NULL.
-*/
-#define BT_MOVE(_var_dst, _var_src) \
- do { \
- bt_put(_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 <strong>If \c obj is not \c NULL</strong>, its reference
- count is incremented.
-
-@sa bt_put(): Decrements the reference count of a Babeltrace object.
-*/
-void *bt_get(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_PUT() macro instead of calling bt_put() since the
-former is generally safer.
-
-@param[in] obj Babeltrace object of which to drop a reference
- (can be \c NULL).
-
-@post <strong>If \c obj is not \c NULL</strong>, its reference
- count is decremented.
-
-@sa BT_PUT(): Calls bt_put() on a variable, then sets it to \c NULL.
-@sa BT_MOVE(): Transfers the ownership of a Babeltrace object from a
- variable to another.
-@sa bt_get(): Increments the reference count of a Babeltrace object.
-*/
-void bt_put(void *obj);
-
-/**
-@}
-*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_REF_H */
* 2. Move the event class reference to our `event_class`
* variable so that we can set the event's class member
* to NULL before recycling it. We CANNOT do this after
- * we put the event class reference because this bt_put()
+ * we put the event class reference because this bt_object_put_ref()
* could destroy the event class, also destroying its
* event pool, thus also destroying our event object (this
* would result in an invalid write access).
* http://www.efficios.com/ctf
*/
-/* For bt_get() */
-#include <babeltrace/ref.h>
+/* For bt_object_get_ref() */
+#include <babeltrace/object.h>
/* For bt_bool */
#include <babeltrace/types.h>
/* For bt_bool */
#include <babeltrace/types.h>
-/* For bt_get() */
-#include <babeltrace/ref.h>
+/* For bt_object_get_ref() */
+#include <babeltrace/object.h>
#ifdef __cplusplus
extern "C" {
singleton to check if it's the null value object, or otherwise with
bt_value_is_null().
-You can pass \ref bt_value_null to bt_get() or bt_put(): it has
+You can pass \ref bt_value_null to bt_object_get_ref() or bt_object_put_ref(): it has
<em>no effect</em>.
The null value object singleton is <em>always frozen</em> (see
/**
@brief User function type to use with bt_value_map_foreach_entry().
-\p object is a <em>weak reference</em>: you \em must pass it to bt_get()
+\p object is a <em>weak reference</em>: you \em must pass it to bt_object_get_ref()
if you need to keep a reference after this function returns.
This function \em must return #BT_TRUE to continue the map value object
map value object \p map_obj.
The value object passed to the user function is a <b>weak reference</b>:
-you \em must pass it to bt_get() if you need to keep a persistent
+you \em must pass it to bt_object_get_ref() if you need to keep a persistent
reference after the user function returns.
The key passed to the user function is only valid in the scope of
libbabeltrace_la_SOURCES = \
babeltrace.c \
values.c \
- ref.c \
+ object.c \
lib-logging.c \
logging.c \
object-pool.c
#include <babeltrace/assert-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compat/string-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/values.h>
#include <inttypes.h>
void bt_ctf_attributes_destroy(struct bt_value *attr_obj)
{
BT_LOGD("Destroying attributes object: addr=%p", attr_obj);
- bt_put(attr_obj);
+ bt_object_put_ref(attr_obj);
}
BT_HIDDEN
}
end:
- bt_put(attr_field_obj);
+ bt_object_put_ref(attr_field_obj);
return ret;
}
#include <babeltrace/compat/uuid-internal.h>
#include <babeltrace/ctf-writer/clock-class-internal.h>
#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/compat/string-internal.h>
clock_class, name);
return clock_class;
error:
- BT_PUT(clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_class);
return clock_class;
}
#include <babeltrace/ctf-writer/utils.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <inttypes.h>
static
return clock;
error:
- BT_PUT(clock);
+ BT_OBJECT_PUT_REF_AND_RESET(clock);
return clock;
}
struct bt_ctf_clock *clock;
clock = container_of(obj, struct bt_ctf_clock, base);
- bt_put(clock->clock_class);
+ bt_object_put_ref(clock->clock_class);
g_free(clock);
}
#include <babeltrace/ctf-writer/validation-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/values-internal.h>
#include <glib.h>
}
BT_LOGD_STR("Putting context field type.");
- bt_put(event_class->context_field_type);
+ bt_object_put_ref(event_class->context_field_type);
BT_LOGD_STR("Putting payload field type.");
- bt_put(event_class->payload_field_type);
+ bt_object_put_ref(event_class->payload_field_type);
}
BT_HIDDEN
goto end;
error:
- bt_put(ctf_event_class);
+ bt_object_put_ref(ctf_event_class);
end:
return ctf_event_class;
struct bt_ctf_event_class *event_class)
{
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
- return bt_get(bt_ctf_event_class_common_borrow_stream_class(
+ return bt_object_get_ref(bt_ctf_event_class_common_borrow_stream_class(
BT_CTF_TO_COMMON(event_class)));
}
struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type(
struct bt_ctf_event_class *event_class)
{
- return bt_get(bt_ctf_event_class_common_borrow_payload_field_type(
+ return bt_object_get_ref(bt_ctf_event_class_common_borrow_payload_field_type(
BT_CTF_TO_COMMON(event_class)));
}
struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type(
struct bt_ctf_event_class *event_class)
{
- return bt_get(bt_ctf_event_class_common_borrow_context_field_type(
+ return bt_object_get_ref(bt_ctf_event_class_common_borrow_context_field_type(
BT_CTF_TO_COMMON(event_class)));
}
end:
context->current_indentation_level = 0;
- BT_PUT(attr_value);
+ BT_OBJECT_PUT_REF_AND_RESET(attr_value);
return ret;
}
* No need to increment field_type's reference count since getting it
* from the structure already does.
*/
- field_type = bt_get(
+ field_type = bt_object_get_ref(
bt_ctf_field_type_common_structure_borrow_field_type_by_name(
event_class->common.payload_field_type, name));
#include <babeltrace/ctf-writer/trace.h>
#include <babeltrace/ctf-writer/utils.h>
#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <inttypes.h>
static
struct bt_ctf_field_common *event_payload = NULL;
struct bt_ctf_validation_output validation_output = { 0 };
struct bt_ctf_clock_class *expected_clock_class =
- init_expected_clock_class ? bt_get(init_expected_clock_class) :
+ init_expected_clock_class ? bt_object_get_ref(init_expected_clock_class) :
NULL;
BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
* from that point, the event and its class will share the same
* lifetime.
*/
- event->class = bt_get(event_class);
+ event->class = bt_object_get_ref(event_class);
ret = bt_ctf_event_common_create_fields(stream_class,
&validation_output,
* now because the stream class is frozen.
*/
if (expected_clock_class) {
- BT_MOVE(stream_class->clock_class, expected_clock_class);
+ BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
}
/*
error:
bt_ctf_validation_output_put_types(&validation_output);
- bt_put(expected_clock_class);
+ bt_object_put_ref(expected_clock_class);
if (event_header) {
release_header_field_func(event_header, stream_class);
void destroy_event_header_field(struct bt_ctf_field_wrapper *field_wrapper)
{
BT_ASSERT(field_wrapper);
- bt_put(field_wrapper->field);
+ bt_object_put_ref(field_wrapper->field);
bt_ctf_field_wrapper_destroy(field_wrapper);
}
goto end;
error:
- bt_put(field);
+ bt_object_put_ref(field);
if (field_wrapper) {
destroy_event_header_field(field_wrapper);
struct bt_ctf_event_common *event_common)
{
BT_ASSERT(field_wrapper);
- BT_PUT(field_wrapper->field);
+ BT_OBJECT_PUT_REF_AND_RESET(field_wrapper->field);
bt_ctf_field_wrapper_destroy(field_wrapper);
}
static
void bt_ctf_event_destroy(struct bt_object *obj)
{
- bt_ctf_event_common_finalize(obj, (void *) bt_put,
+ bt_ctf_event_common_finalize(obj, (void *) bt_object_put_ref,
(void *) release_event_header_field);
g_free(obj);
}
bt_ctf_field_type_copy,
false, map_clock_classes_func,
(create_field_func) bt_ctf_field_create,
- (release_field_func) bt_put,
+ (release_field_func) bt_object_put_ref,
(create_header_field_func) create_event_header_field,
(release_header_field_func) destroy_event_header_field);
if (ret) {
goto end;
error:
- BT_PUT(event);
+ BT_OBJECT_PUT_REF_AND_RESET(event);
end:
return event;
struct bt_ctf_event_class *bt_ctf_event_get_class(struct bt_ctf_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
- return bt_get(bt_ctf_event_common_borrow_class(BT_CTF_TO_COMMON(event)));
+ return bt_object_get_ref(bt_ctf_event_common_borrow_class(BT_CTF_TO_COMMON(event)));
}
BT_HIDDEN
struct bt_ctf_stream *bt_ctf_event_get_stream(struct bt_ctf_event *event)
{
BT_ASSERT_PRE_NON_NULL(event, "Event");
- return bt_get(bt_ctf_event_borrow_stream(event));
+ return bt_object_get_ref(bt_ctf_event_borrow_stream(event));
}
int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name,
BT_CTF_FROM_COMMON(event->common.payload_field), name);
} else {
field = BT_CTF_FROM_COMMON(event->common.payload_field);
- bt_get(field);
+ bt_object_get_ref(field);
}
return field;
struct bt_ctf_field *bt_ctf_event_get_payload_field(
struct bt_ctf_event *event)
{
- return bt_get(bt_ctf_event_common_borrow_payload(BT_CTF_TO_COMMON(event)));
+ return bt_object_get_ref(bt_ctf_event_common_borrow_payload(BT_CTF_TO_COMMON(event)));
}
struct bt_ctf_field *bt_ctf_event_get_header(struct bt_ctf_event *event)
{
- return bt_get(bt_ctf_event_common_borrow_header(BT_CTF_TO_COMMON(event)));
+ return bt_object_get_ref(bt_ctf_event_common_borrow_header(BT_CTF_TO_COMMON(event)));
}
struct bt_ctf_field *bt_ctf_event_get_context(struct bt_ctf_event *event)
{
- return bt_get(bt_ctf_event_common_borrow_context(BT_CTF_TO_COMMON(event)));
+ return bt_object_get_ref(bt_ctf_event_common_borrow_context(BT_CTF_TO_COMMON(event)));
}
struct bt_ctf_field *bt_ctf_event_get_stream_event_context(
struct bt_ctf_event *event)
{
- return bt_get(bt_ctf_event_common_borrow_stream_event_context(
+ return bt_object_get_ref(bt_ctf_event_common_borrow_stream_event_context(
BT_CTF_TO_COMMON(event)));
}
bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_header_field_type);
}
- bt_put(event->common.header_field->field);
- event->common.header_field->field = bt_get(header);
+ bt_object_put_ref(event->common.header_field->field);
+ event->common.header_field->field = bt_object_get_ref(header);
BT_LOGV("Set event's header field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"header-field-addr=%p",
event, event->common.class->payload_field_type);
}
- bt_put(event->common.payload_field);
- event->common.payload_field = bt_get(payload);
+ bt_object_put_ref(event->common.payload_field);
+ event->common.payload_field = bt_object_get_ref(payload);
BT_LOGV("Set event's payload field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"payload-field-addr=%p",
event, event->common.class->context_field_type);
}
- bt_put(event->common.context_field);
- event->common.context_field = bt_get(context);
+ bt_object_put_ref(event->common.context_field);
+ event->common.context_field = bt_object_get_ref(context);
BT_LOGV("Set event's context field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"context-field-addr=%p",
bt_ctf_event_class_common_borrow_stream_class(event->common.class)->event_context_field_type);
}
- bt_put(event->common.stream_event_context_field);
- event->common.stream_event_context_field = bt_get(stream_event_context);
+ bt_object_put_ref(event->common.stream_event_context_field);
+ event->common.stream_event_context_field = bt_object_get_ref(stream_event_context);
BT_LOGV("Set event's stream event context field: event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64 ", "
"stream-event-context-field-addr=%p",
return field_path;
error:
- BT_PUT(field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(field_path);
return NULL;
}
#include <babeltrace/ctf-writer/utils.h>
#include <babeltrace/endian-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <float.h>
#include <inttypes.h>
#include <stdlib.h>
BT_LOGD("Initializing common enumeration field type object: int-ft-addr=%p",
container_ft);
ft->id = BT_CTF_FIELD_TYPE_ID_ENUM;
- enum_ft->container_ft = bt_get(container_ft);
+ enum_ft->container_ft = bt_object_get_ref(container_ft);
enum_ft->entries = g_ptr_array_new_with_free_func(
(GDestroyNotify) destroy_enumeration_mapping);
bt_ctf_field_type_common_initialize(ft, false, release_func, methods);
BT_LOGD("Initializing common array field type object: element-ft-addr=%p, "
"length=%u", element_ft, length);
ft->id = BT_CTF_FIELD_TYPE_ID_ARRAY;
- array_ft->element_ft = bt_get(element_ft);
+ array_ft->element_ft = bt_object_get_ref(element_ft);
array_ft->length = length;
bt_ctf_field_type_common_initialize(ft, false, release_func, methods);
BT_LOGD("Initialized common array field type object: addr=%p, "
BT_LOGD("Initializing common sequence field type object: element-ft-addr=%p, "
"length-field-name=\"%s\"", element_ft, length_field_name);
ft->id = BT_CTF_FIELD_TYPE_ID_SEQUENCE;
- seq_ft->element_ft = bt_get(element_ft);
+ seq_ft->element_ft = bt_object_get_ref(element_ft);
seq_ft->length_field_name = g_string_new(length_field_name);
bt_ctf_field_type_common_initialize(ft, false, release_func, methods);
BT_LOGD("Initialized common sequence field type object: addr=%p, "
sizeof(struct bt_ctf_field_type_common_variant_choice));
if (tag_ft) {
- var_ft->tag_ft = bt_get(tag_ft);
+ var_ft->tag_ft = bt_object_get_ref(tag_ft);
}
bt_ctf_field_type_common_initialize(ft, true, release_func, methods);
BT_LOGD("Destroying integer field type object: addr=%p", ft);
BT_LOGD_STR("Putting mapped clock class.");
- bt_put(ft->mapped_clock_class);
+ bt_object_put_ref(ft->mapped_clock_class);
g_free(ft);
}
BT_LOGD("Destroying enumeration field type object: addr=%p", ft);
g_ptr_array_free(ft->entries, TRUE);
BT_LOGD_STR("Putting container field type.");
- bt_put(ft->container_ft);
+ bt_object_put_ref(ft->container_ft);
g_free(ft);
}
"addr=%p, field-ft-addr=%p, field-name=\"%s\"",
field, field->type, g_quark_to_string(field->name));
BT_LOGD_STR("Putting field type.");
- bt_put(field->type);
+ bt_object_put_ref(field->type);
}
BT_HIDDEN
BT_LOGD("Destroying array field type object: addr=%p", ft);
BT_LOGD_STR("Putting element field type.");
- bt_put(ft->element_ft);
+ bt_object_put_ref(ft->element_ft);
g_free(ft);
}
BT_LOGD("Destroying sequence field type object: addr=%p", ft);
BT_LOGD_STR("Putting element field type.");
- bt_put(ft->element_ft);
+ bt_object_put_ref(ft->element_ft);
g_string_free(ft->length_field_name, TRUE);
BT_LOGD_STR("Putting length field path.");
- bt_put(ft->length_field_path);
+ bt_object_put_ref(ft->length_field_path);
g_free(ft);
}
"addr=%p, field-ft-addr=%p, field-name=\"%s\"",
choice, choice->type, g_quark_to_string(choice->name));
BT_LOGD_STR("Putting field type.");
- bt_put(choice->type);
+ bt_object_put_ref(choice->type);
if (choice->ranges) {
g_array_free(choice->ranges, TRUE);
}
BT_LOGD_STR("Putting tag field type.");
- bt_put(ft->tag_ft);
+ bt_object_put_ref(ft->tag_ft);
BT_LOGD_STR("Putting tag field path.");
- bt_put(ft->tag_field_path);
+ bt_object_put_ref(ft->tag_field_path);
g_free(ft);
}
}
*member_name = name_quark;
- *member_ft = bt_get(field_type);
+ *member_ft = bt_object_get_ref(field_type);
g_hash_table_insert(field_name_to_index,
GUINT_TO_POINTER(name_quark),
GUINT_TO_POINTER(members->len - 1));
BT_LOGD("Destroying enumeration field type mapping iterator: addr=%p",
obj);
BT_LOGD_STR("Putting parent enumeration field type.");
- bt_put(iter->enumeration_ft);
+ bt_object_put_ref(iter->enumeration_ft);
g_free(iter);
}
}
bt_object_init_shared(&iter->base, bt_ctf_field_type_enum_iter_destroy);
- iter->enumeration_ft = bt_get(ft);
+ iter->enumeration_ft = bt_object_get_ref(ft);
iter->index = -1;
iter->type = iterator_type;
return iter;
error:
- bt_put(iter);
+ bt_object_put_ref(iter);
return NULL;
}
return iter;
error:
- bt_put(iter);
+ bt_object_put_ref(iter);
return NULL;
}
return iter;
error:
- bt_put(iter);
+ bt_object_put_ref(iter);
return NULL;
}
goto end;
}
- bt_put(int_ft->mapped_clock_class);
- int_ft->mapped_clock_class = bt_get(clock_class);
+ bt_object_put_ref(int_ft->mapped_clock_class);
+ int_ft->mapped_clock_class = bt_object_get_ref(clock_class);
BT_LOGV("Set integer field type's mapped clock class: ft-addr=%p, "
"clock-class-addr=%p, clock-class-name=\"%s\"",
ft, clock_class, bt_ctf_clock_class_get_name(clock_class));
BT_CTF_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, i);
if (field->name == name_quark) {
- bt_put(field->type);
- field->type = bt_get(field_type);
+ bt_object_put_ref(field->type);
+ field->type = bt_object_get_ref(field_type);
}
}
}
if (array_ft->element_ft) {
- BT_PUT(array_ft->element_ft);
+ BT_OBJECT_PUT_REF_AND_RESET(array_ft->element_ft);
}
- array_ft->element_ft = bt_get(element_ft);
+ array_ft->element_ft = bt_object_get_ref(element_ft);
BT_LOGV("Set array field type's element field type: array-ft-addr=%p, "
"element-ft-addr=%p", ft, element_ft);
}
if (seq_ft->element_ft) {
- BT_PUT(seq_ft->element_ft);
+ BT_OBJECT_PUT_REF_AND_RESET(seq_ft->element_ft);
}
seq_ft->element_ft = element_ft;
- bt_get(seq_ft->element_ft);
+ bt_object_get_ref(seq_ft->element_ft);
BT_LOGV("Set sequence field type's element field type: sequence-ft-addr=%p, "
"element-ft-addr=%p", ft, element_ft);
goto end;
}
- bt_get(path);
- BT_MOVE(seq_ft->length_field_path, path);
+ bt_object_get_ref(path);
+ BT_OBJECT_MOVE_REF(seq_ft->length_field_path, path);
BT_LOGV("Set sequence field type's length field path: ft-addr=%p, "
"field-path-addr=%p", ft, path);
goto end;
}
- bt_get(path);
- BT_MOVE(var_ft->tag_field_path, path);
+ bt_object_get_ref(path);
+ BT_OBJECT_MOVE_REF(var_ft->tag_field_path, path);
BT_LOGV("Set variant field type's tag field path: ft-addr=%p, "
"field-path-addr=%p", ft, path);
goto end;
}
- bt_put(var_ft->tag_ft);
- var_ft->tag_ft = bt_get(tag_ft);
+ bt_object_put_ref(var_ft->tag_ft);
+ var_ft->tag_ft = bt_object_get_ref(tag_ft);
BT_LOGV("Set variant field type's tag field type: variant-ft-addr=%p, "
"tag-ft-addr=%p", ft, tag_ft);
g_array_append_val(choice->ranges, range);
}
- bt_put(iter);
+ bt_object_put_ref(iter);
}
var_ft->choices_up_to_date = true;
if (!*expected_clock_class) {
/* Move reference to output parameter */
- *expected_clock_class = bt_get(mapped_clock_class);
+ *expected_clock_class = bt_object_get_ref(mapped_clock_class);
mapped_clock_class = NULL;
BT_LOGV("Setting expected clock class: "
"expected-clock-class-addr=%p",
bt_ctf_clock_class_get_name(mapped_clock_class),
*expected_clock_class,
bt_ctf_clock_class_get_name(*expected_clock_class));
- bt_put(mapped_clock_class);
+ bt_object_put_ref(mapped_clock_class);
ret = -1;
goto end;
}
goto end;
error:
- BT_PUT(integer);
+ BT_OBJECT_PUT_REF_AND_RESET(integer);
end:
return (void *) integer;
struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
struct bt_ctf_field_type *ft)
{
- return bt_get(bt_ctf_field_type_common_integer_borrow_mapped_clock_class(
+ return bt_object_get_ref(bt_ctf_field_type_common_integer_borrow_mapped_clock_class(
(void *) ft));
}
goto end;
error:
- BT_PUT(enumeration);
+ BT_OBJECT_PUT_REF_AND_RESET(enumeration);
end:
return (void *) enumeration;
struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_field_type_common_enumeration_borrow_container_field_type(
(void *) ft));
}
goto end;
error:
- BT_PUT(structure);
+ BT_OBJECT_PUT_REF_AND_RESET(structure);
end:
return (void *) structure;
(void *) ft, field_name, (void *) field_type, index);
if (ret == 0 && field_type) {
- bt_get(*field_type);
+ bt_object_get_ref(*field_type);
}
return ret;
struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
struct bt_ctf_field_type *ft, const char *name)
{
- return bt_get(bt_ctf_field_type_common_structure_borrow_field_type_by_name(
+ return bt_object_get_ref(bt_ctf_field_type_common_structure_borrow_field_type_by_name(
(void *) ft, name));
}
goto end;
error:
- BT_PUT(var_ft);
+ BT_OBJECT_PUT_REF_AND_RESET(var_ft);
end:
return (void *) var_ft;
struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_get(bt_ctf_field_type_common_variant_borrow_tag_field_type(
+ return bt_object_get_ref(bt_ctf_field_type_common_variant_borrow_tag_field_type(
(void *) ft));
}
struct bt_ctf_field_type *ft,
const char *field_name)
{
- return bt_get(bt_ctf_field_type_common_variant_borrow_field_type_by_name(
+ return bt_object_get_ref(bt_ctf_field_type_common_variant_borrow_field_type_by_name(
(void *) ft, field_name));
}
(void *) ft, field_name, (void *) field_type, index);
if (ret == 0 && field_type) {
- bt_get(*field_type);
+ bt_object_get_ref(*field_type);
}
return ret;
goto end;
error:
- BT_PUT(array);
+ BT_OBJECT_PUT_REF_AND_RESET(array);
end:
return (void *) array;
struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_get(bt_ctf_field_type_common_array_borrow_element_field_type(
+ return bt_object_get_ref(bt_ctf_field_type_common_array_borrow_element_field_type(
(void *) ft));
}
goto end;
error:
- BT_PUT(sequence);
+ BT_OBJECT_PUT_REF_AND_RESET(sequence);
end:
return (void *) sequence;
struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type(
struct bt_ctf_field_type *ft)
{
- return bt_get(bt_ctf_field_type_common_sequence_borrow_element_field_type(
+ return bt_object_get_ref(bt_ctf_field_type_common_sequence_borrow_element_field_type(
(void *) ft));
}
goto end;
}
- copy_ft->mapped_clock_class = bt_get(int_ft->mapped_clock_class);
+ copy_ft->mapped_clock_class = bt_object_get_ref(int_ft->mapped_clock_class);
copy_ft->user_byte_order = int_ft->user_byte_order;
copy_ft->is_signed = int_ft->is_signed;
copy_ft->size = int_ft->size;
ft, copy_ft);
end:
- bt_put(container_copy_ft);
+ bt_object_put_ref(container_copy_ft);
return (void *) copy_ft;
error:
- bt_put(container_copy_ft);
- BT_PUT(copy_ft);
+ bt_object_put_ref(container_copy_ft);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
return (void *) copy_ft;
}
return (void *) copy_ft;
error:
- BT_PUT(copy_ft);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
return NULL;
}
ft, copy_ft);
end:
- bt_put(tag_ft_copy);
+ bt_object_put_ref(tag_ft_copy);
return (void *) copy_ft;
error:
- bt_put(tag_ft_copy);
- BT_PUT(copy_ft);
+ bt_object_put_ref(tag_ft_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
return NULL;
}
ft, copy_ft);
end:
- bt_put(container_ft_copy);
+ bt_object_put_ref(container_ft_copy);
return (void *) copy_ft;
}
ft, copy_ft);
end:
- bt_put(container_ft_copy);
+ bt_object_put_ref(container_ft_copy);
return (void *) copy_ft;
error:
- bt_put(container_ft_copy);
- BT_PUT(copy_ft);
+ bt_object_put_ref(container_ft_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_ft);
return NULL;
}
#include <babeltrace/ctf-writer/serialize-internal.h>
#include <babeltrace/endian-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <float.h>
#include <inttypes.h>
#include <inttypes.h>
BT_LOGD("Destroying CTF writer enumeration field object: addr=%p",
field);
BT_LOGD_STR("Putting container field.");
- bt_put(enumeration->container);
+ bt_object_put_ref(enumeration->container);
bt_ctf_field_common_finalize((void *) field);
g_free(field);
}
BT_LOGD("Destroying CTF writer variant field object: addr=%p", field);
BT_LOGD_STR("Putting tag field.");
- bt_put(variant->tag);
+ bt_object_put_ref(variant->tag);
bt_ctf_field_common_variant_finalize_recursive((void *) field);
g_free(field);
}
}
end:
- bt_put(character);
- bt_put(character_type);
+ bt_object_put_ref(character);
+ bt_object_put_ref(character_type);
return ret;
}
struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field)
{
- return bt_get(bt_ctf_field_common_borrow_type((void *) field));
+ return bt_object_get_ref(bt_ctf_field_common_borrow_type((void *) field));
}
enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field)
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_get(bt_ctf_field_common_structure_borrow_field_by_index(
+ return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_index(
(void *) field, index));
}
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name(
struct bt_ctf_field *field, const char *name)
{
- return bt_get(bt_ctf_field_common_structure_borrow_field_by_name(
+ return bt_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_name(
(void *) field, name));
}
struct bt_ctf_field *bt_ctf_field_array_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_field_common_array_borrow_field((void *) field, index));
}
struct bt_ctf_field *bt_ctf_field_sequence_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_field_common_sequence_borrow_field((void *) field, index));
}
goto end;
}
- bt_put(variant_field->tag);
- variant_field->tag = bt_get(tag_field);
+ bt_object_put_ref(variant_field->tag);
+ variant_field->tag = bt_object_get_ref(tag_field);
current_field = bt_ctf_field_variant_get_current_field(field);
BT_ASSERT(current_field);
struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
struct bt_ctf_field *variant_field)
{
- return bt_get(bt_ctf_field_common_variant_borrow_current_field(
+ return bt_object_get_ref(bt_ctf_field_common_variant_borrow_current_field(
(void *) variant_field));
}
struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
struct bt_ctf_field *field)
{
- return bt_get(bt_ctf_field_enumeration_borrow_container(field));
+ return bt_object_get_ref(bt_ctf_field_enumeration_borrow_container(field));
}
int bt_ctf_field_integer_signed_get_value(struct bt_ctf_field *field,
enumeration->container = (void *) bt_ctf_field_create(
BT_CTF_FROM_COMMON(enum_ft->container_ft));
if (!enumeration->container) {
- BT_PUT(enumeration);
+ BT_OBJECT_PUT_REF_AND_RESET(enumeration);
goto end;
}
bt_ctf_field_structure_destroy_recursive,
&bt_ctf_field_structure_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
structure->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_structure_serialize_recursive;
if (iret) {
- BT_PUT(structure);
+ BT_OBJECT_PUT_REF_AND_RESET(structure);
goto end;
}
bt_ctf_field_variant_destroy_recursive,
&bt_ctf_field_variant_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
variant->tag = (void *) bt_ctf_field_create(
BT_CTF_FROM_COMMON(var_ft->tag_ft));
variant->common.common.spec.writer.serialize_func =
bt_ctf_field_array_destroy_recursive,
&bt_ctf_field_array_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
array->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_array_serialize_recursive;
if (ret) {
- BT_PUT(array);
+ BT_OBJECT_PUT_REF_AND_RESET(array);
goto end;
}
true, (bt_object_release_func)
bt_ctf_field_sequence_destroy_recursive,
&bt_ctf_field_sequence_methods,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
sequence->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_sequence_serialize_recursive;
BT_LOGD("Created CTF writer sequence field object: addr=%p, ft-addr=%p",
ret = -1;
goto end;
}
- bt_get(value);
- BT_MOVE(structure->fields->pdata[index], value);
+ bt_object_get_ref(value);
+ BT_OBJECT_MOVE_REF(structure->fields->pdata[index], value);
end:
return ret;
#include <babeltrace/ctf-writer/resolve-internal.h>
#include <babeltrace/ctf-writer/stream-class.h>
#include <babeltrace/ctf-writer/utils-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
#include <glib.h>
{
struct type_stack_frame *frame = data;
- BT_PUT(frame->type);
+ BT_OBJECT_PUT_REF_AND_RESET(frame->type);
g_free(frame);
}
BT_LOGV("Pushing field type on context's stack: "
"ft-addr=%p, stack-size-before=%u", type, stack->len);
- frame->type = bt_get(type);
+ frame->type = bt_object_get_ref(type);
g_ptr_array_add(stack, frame);
end:
bt_bool first_level_done = BT_FALSE;
/* Get our own reference */
- bt_get(type);
+ bt_object_get_ref(type);
/* Locate target */
while (cur_ptoken) {
}
/* Move child type to current type */
- bt_get(child_type);
- BT_MOVE(type, child_type);
+ bt_object_get_ref(child_type);
+ BT_OBJECT_MOVE_REF(type, child_type);
}
end:
- bt_put(type);
+ bt_object_put_ref(type);
return ret;
}
}
end:
- BT_PUT(tail_field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(tail_field_path);
return ret;
}
end:
if (ret) {
- BT_PUT(field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(field_path);
}
ptokens_destroy(ptokens);
/* Start with root type */
type = get_type_from_ctx(ctx, field_path->root);
- bt_get(type);
+ bt_object_get_ref(type);
if (!type) {
/* Error: root type is not available */
BT_LOGW("Root field type is not available: root-scope=%s",
}
/* Move child type to current type */
- bt_get(child_type);
- BT_MOVE(type, child_type);
+ bt_object_get_ref(child_type);
+ BT_OBJECT_MOVE_REF(type, child_type);
}
return type;
error:
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
return type;
}
return field_path;
error:
- BT_PUT(field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(field_path);
return field_path;
}
}
end:
- BT_PUT(ctx_field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(ctx_field_path);
return ret;
}
g_string_free(target_field_path_pretty, TRUE);
}
- BT_PUT(target_field_path);
- BT_PUT(target_type);
+ BT_OBJECT_PUT_REF_AND_RESET(target_field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(target_type);
return ret;
}
#include <babeltrace/ctf-writer/visitor-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
BT_LOGD("Finalizing common stream class: addr=%p, name=\"%s\", id=%" PRId64,
stream_class, bt_ctf_stream_class_common_get_name(stream_class),
bt_ctf_stream_class_common_get_id(stream_class));
- bt_put(stream_class->clock_class);
+ bt_object_put_ref(stream_class->clock_class);
if (stream_class->event_classes_ht) {
g_hash_table_destroy(stream_class->event_classes_ht);
}
BT_LOGD_STR("Putting event header field type.");
- bt_put(stream_class->event_header_field_type);
+ bt_object_put_ref(stream_class->event_header_field_type);
BT_LOGD_STR("Putting packet context field type.");
- bt_put(stream_class->packet_context_field_type);
+ bt_object_put_ref(stream_class->packet_context_field_type);
BT_LOGD_STR("Putting event context field type.");
- bt_put(stream_class->event_context_field_type);
+ bt_object_put_ref(stream_class->event_context_field_type);
}
static
* context) could change before the next call to one of
* those two functions.
*/
- expected_clock_class = bt_get(stream_class->clock_class);
+ expected_clock_class = bt_object_get_ref(stream_class->clock_class);
/*
* At this point, `expected_clock_class` can be NULL,
if (stream_class->frozen && expected_clock_class) {
BT_ASSERT(!stream_class->clock_class ||
stream_class->clock_class == expected_clock_class);
- BT_MOVE(stream_class->clock_class, expected_clock_class);
+ BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
}
BT_LOGD("Added event class to stream class: "
end:
bt_ctf_validation_output_put_types(&validation_output);
- bt_put(expected_clock_class);
+ bt_object_put_ref(expected_clock_class);
g_free(event_id);
return ret;
}
goto end;
}
- bt_put(stream_class->common.event_header_field_type);
+ bt_object_put_ref(stream_class->common.event_header_field_type);
stream_class->common.event_header_field_type =
(void *) event_header_type;
event_header_type = NULL;
end:
if (ret) {
- bt_put(event_header_type);
+ bt_object_put_ref(event_header_type);
}
- bt_put(_uint32_t);
- bt_put(_uint64_t);
+ bt_object_put_ref(_uint32_t);
+ bt_object_put_ref(_uint64_t);
return ret;
}
goto end;
}
- bt_put(stream_class->common.packet_context_field_type);
+ bt_object_put_ref(stream_class->common.packet_context_field_type);
stream_class->common.packet_context_field_type =
(void *) packet_context_type;
packet_context_type = NULL;
end:
if (ret) {
- bt_put(packet_context_type);
+ bt_object_put_ref(packet_context_type);
goto end;
}
- bt_put(_uint64_t);
- bt_put(ts_begin_end_uint64_t);
+ bt_object_put_ref(_uint64_t);
+ bt_object_put_ref(ts_begin_end_uint64_t);
return ret;
}
stream_class, bt_ctf_stream_class_get_name(stream_class),
bt_ctf_stream_class_get_id(stream_class));
bt_ctf_stream_class_common_finalize(BT_CTF_TO_COMMON(stream_class));
- bt_put(stream_class->clock);
+ bt_object_put_ref(stream_class->clock);
g_free(stream_class);
}
return stream_class;
error:
- BT_PUT(stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class);
return stream_class;
}
ret = bt_ctf_field_type_common_structure_replace_field(
(void *) parent_ft, field_name, (void *) ft_copy);
- bt_put(ft_copy);
+ bt_object_put_ref(ft_copy);
BT_LOGV("Automatically mapped field type to stream class's clock class: "
"stream-class-addr=%p, stream-class-name=\"%s\", "
"stream-class-id=%" PRId64 ", ft-addr=%p, "
}
end:
- bt_put(ft);
- bt_put(mapped_clock_class);
+ bt_object_put_ref(ft);
+ bt_object_put_ref(mapped_clock_class);
return ret;
}
goto end;
}
- clock = bt_get(stream_class->clock);
+ clock = bt_object_get_ref(stream_class->clock);
end:
return clock;
}
/* Replace the current clock of this stream class. */
- bt_put(stream_class->clock);
- stream_class->clock = bt_get(clock);
+ bt_object_put_ref(stream_class->clock);
+ stream_class->clock = bt_object_get_ref(clock);
BT_LOGV("Set stream class's clock: "
"addr=%p, name=\"%s\", id=%" PRId64 ", "
"clock-addr=%p, clock-name=\"%s\"",
"\tid = %" PRId64 ";\n",
stream_class->common.id);
}
- bt_put(stream_id_type);
+ bt_object_put_ref(stream_id_type);
}
if (stream_class->common.event_header_field_type) {
BT_LOGD_STR("Serializing stream class's event header field type's metadata.");
}
end:
- bt_put(packet_header_type);
+ bt_object_put_ref(packet_header_type);
context->current_indentation_level = 0;
return ret;
}
struct bt_ctf_trace *bt_ctf_stream_class_get_trace(
struct bt_ctf_stream_class *stream_class)
{
- return bt_get(bt_ctf_stream_class_common_borrow_trace(
+ return bt_object_get_ref(bt_ctf_stream_class_common_borrow_trace(
BT_CTF_TO_COMMON(stream_class)));
}
struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
struct bt_ctf_stream_class *stream_class)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_stream_class_common_borrow_packet_context_field_type(
BT_CTF_TO_COMMON(stream_class)));
}
bt_ctf_stream_class_get_event_header_type(
struct bt_ctf_stream_class *stream_class)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_stream_class_common_borrow_event_header_field_type(
BT_CTF_TO_COMMON(stream_class)));
}
bt_ctf_stream_class_get_event_context_type(
struct bt_ctf_stream_class *stream_class)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_stream_class_common_borrow_event_context_field_type(
BT_CTF_TO_COMMON(stream_class)));
}
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
struct bt_ctf_stream_class *stream_class, uint64_t index)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_stream_class_common_borrow_event_class_by_index(
BT_CTF_TO_COMMON(stream_class), index));
}
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
struct bt_ctf_stream_class *stream_class, uint64_t id)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_stream_class_common_borrow_event_class_by_id(
BT_CTF_TO_COMMON(stream_class), id));
}
#include <babeltrace/ctf-writer/trace-internal.h>
#include <babeltrace/ctf-writer/trace.h>
#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <inttypes.h>
#include <stdint.h>
#include <unistd.h>
}
}
end:
- bt_put(field_type);
+ bt_object_put_ref(field_type);
return ret;
}
magic_field, (uint64_t) magic_value);
}
end:
- bt_put(magic_field);
+ bt_object_put_ref(magic_field);
return ret;
}
ret = bt_ctf_field_integer_unsigned_set_value(
uuid_element, (uint64_t) trace->common.uuid[i]);
- bt_put(uuid_element);
+ bt_object_put_ref(uuid_element);
if (ret) {
BT_LOGW("Cannot set integer field's value (for `uuid` packet header field): "
"stream-addr=%p, stream-name=\"%s\", field-addr=%p, "
stream, bt_ctf_stream_get_name(stream), uuid_field);
end:
- bt_put(uuid_field);
- BT_PUT(trace);
+ bt_object_put_ref(uuid_field);
+ BT_OBJECT_PUT_REF_AND_RESET(trace);
return ret;
}
static
}
end:
- bt_put(stream_id_field);
+ bt_object_put_ref(stream_id_field);
return ret;
}
}
end:
- bt_put(field);
+ bt_object_put_ref(field);
return ret;
}
}
end:
- bt_put(field);
+ bt_object_put_ref(field);
return ret;
}
}
end:
- bt_put(field);
+ bt_object_put_ref(field);
return ret;
}
goto end;
}
- bt_put(cc);
+ bt_object_put_ref(cc);
val_size = bt_ctf_field_type_integer_get_size(
(void *) field_common->type);
BT_ASSERT(val_size >= 1);
BT_ASSERT(int_field);
ret = visit_field_update_clock_value(int_field, val);
- bt_put(int_field);
+ bt_object_put_ref(int_field);
break;
}
case BT_CTF_FIELD_TYPE_ID_ARRAY:
BT_ASSERT(elem_field);
ret = visit_field_update_clock_value(elem_field, val);
- bt_put(elem_field);
+ bt_object_put_ref(elem_field);
if (ret) {
goto end;
}
BT_ASSERT(elem_field);
ret = visit_field_update_clock_value(elem_field, val);
- bt_put(elem_field);
+ bt_object_put_ref(elem_field);
if (ret) {
goto end;
}
BT_ASSERT(member_field);
ret = visit_field_update_clock_value(member_field, val);
- bt_put(member_field);
+ bt_object_put_ref(member_field);
if (ret) {
goto end;
}
}
ret = visit_field_update_clock_value(cur_field, val);
- bt_put(cur_field);
+ bt_object_put_ref(cur_field);
break;
}
default:
field = bt_ctf_event_get_header(event);
ret = visit_field_update_clock_value(field, val);
- bt_put(field);
+ bt_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's header.");
field = bt_ctf_event_get_stream_event_context(event);
ret = visit_field_update_clock_value(field, val);
- bt_put(field);
+ bt_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's stream event context.");
field = bt_ctf_event_get_context(event);
ret = visit_field_update_clock_value(field, val);
- bt_put(field);
+ bt_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's context.");
field = bt_ctf_event_get_payload_field(event);
ret = visit_field_update_clock_value(field, val);
- bt_put(field);
+ bt_object_put_ref(field);
if (ret) {
BT_LOGW_STR("Cannot automatically update clock value in "
"event's payload.");
if (strcmp(member_name, "packet_size") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_put(member_field);
+ bt_object_put_ref(member_field);
continue;
}
if (strcmp(member_name, "content_size") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_put(member_field);
+ bt_object_put_ref(member_field);
continue;
}
if (strcmp(member_name, "events_discarded") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_put(member_field);
+ bt_object_put_ref(member_field);
continue;
}
if (strcmp(member_name, "packet_seq_num") == 0 &&
!bt_ctf_field_is_set_recursive(member_field)) {
- bt_put(member_field);
+ bt_object_put_ref(member_field);
continue;
}
ret = visit_field_update_clock_value(member_field,
&cur_clock_value);
- bt_put(member_field);
+ bt_object_put_ref(member_field);
if (ret) {
BT_LOGW("Cannot automatically update clock value "
"in stream's packet context: "
}
end:
- bt_put(ts_begin_field);
- bt_put(ts_end_field);
+ bt_object_put_ref(ts_begin_field);
+ bt_object_put_ref(ts_end_field);
return ret;
}
* existence of its event class for the duration of its
* lifetime.
*/
- bt_get(event->common.class);
- BT_PUT(event->common.base.parent);
+ bt_object_get_ref(event->common.class);
+ BT_OBJECT_PUT_REF_AND_RESET(event->common.base.parent);
} else {
bt_object_try_spec_release(&event->common.base);
}
goto end;
error:
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
end:
- bt_put(writer);
+ bt_object_put_ref(writer);
return stream;
}
}
end:
- bt_put(events_discarded_field);
+ bt_object_put_ref(events_discarded_field);
return ret;
}
stream, bt_ctf_stream_get_name(stream), event_count);
end:
- bt_put(events_discarded_field);
+ bt_object_put_ref(events_discarded_field);
}
static int auto_populate_event_header(struct bt_ctf_stream *stream,
stream, bt_ctf_stream_get_name(stream), event);
end:
- bt_put(id_field);
- bt_put(timestamp_field);
- bt_put(mapped_clock_class);
+ bt_object_put_ref(id_field);
+ bt_object_put_ref(timestamp_field);
+ bt_object_put_ref(mapped_clock_class);
return ret;
}
* longer needed.
*/
BT_LOGV_STR("Putting the event's class.");
- bt_put(event->common.class);
+ bt_object_put_ref(event->common.class);
BT_LOGV("Appended event to stream: "
"stream-addr=%p, stream-name=\"%s\", event-addr=%p, "
"event-class-name=\"%s\", event-class-id=%" PRId64,
packet_context = stream->packet_context;
if (packet_context) {
- bt_get(packet_context);
+ bt_object_get_ref(packet_context);
}
end:
return packet_context;
goto end;
}
- bt_put(field_type);
- bt_put(stream->packet_context);
- stream->packet_context = bt_get(field);
+ bt_object_put_ref(field_type);
+ bt_object_put_ref(stream->packet_context);
+ stream->packet_context = bt_object_get_ref(field);
BT_LOGV("Set stream's packet context field: "
"stream-addr=%p, stream-name=\"%s\", "
"packet-context-field-addr=%p",
packet_header = stream->packet_header;
if (packet_header) {
- bt_get(packet_header);
+ bt_object_get_ref(packet_header);
}
end:
return packet_header;
}
skip_validation:
- bt_put(stream->packet_header);
- stream->packet_header = bt_get(field);
+ bt_object_put_ref(stream->packet_header);
+ stream->packet_header = bt_object_get_ref(field);
BT_LOGV("Set stream's packet header field: "
"stream-addr=%p, stream-name=\"%s\", "
"packet-header-field-addr=%p",
stream, bt_ctf_stream_get_name(stream), field);
end:
- BT_PUT(trace);
- bt_put(field_type);
+ BT_OBJECT_PUT_REF_AND_RESET(trace);
+ bt_object_put_ref(field_type);
return ret;
}
member = bt_ctf_field_structure_get_field_by_name(structure, name);
if (member) {
bt_ctf_field_common_reset_recursive((void *) member);
- bt_put(member);
+ bt_object_put_ref(member);
}
}
packet_size_field = bt_ctf_field_structure_get_field_by_name(
stream->packet_context, "packet_size");
has_packet_size = (packet_size_field != NULL);
- bt_put(packet_size_field);
+ bt_object_put_ref(packet_size_field);
}
if (stream->flushed_packet_count == 1) {
struct bt_ctf_field *field = bt_ctf_field_structure_get_field_by_name(
stream->packet_context, "content_size");
- bt_put(field);
+ bt_object_put_ref(field);
if (!field) {
if (stream->pos.offset != stream->pos.packet_size) {
BT_LOGW("Stream's packet context's `content_size` field is missing, "
}
BT_LOGD_STR("Putting packet header field.");
- bt_put(stream->packet_header);
+ bt_object_put_ref(stream->packet_header);
BT_LOGD_STR("Putting packet context field.");
- bt_put(stream->packet_context);
+ bt_object_put_ref(stream->packet_context);
g_free(stream);
}
}
ret = !ret ? 1 : ret;
end:
- bt_put(integer);
- bt_put(field_type);
+ bt_object_put_ref(integer);
+ bt_object_put_ref(field_type);
return ret;
}
struct bt_ctf_stream_class *bt_ctf_stream_get_class(
struct bt_ctf_stream *stream)
{
- return bt_get(bt_ctf_stream_common_borrow_class(BT_CTF_TO_COMMON(stream)));
+ return bt_object_get_ref(bt_ctf_stream_common_borrow_class(BT_CTF_TO_COMMON(stream)));
}
const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream)
#include <babeltrace/ctf-writer/visitor-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/values-internal.h>
#include <babeltrace/values.h>
trace->native_byte_order = BT_CTF_BYTE_ORDER_UNSPECIFIED;
bt_object_init_shared_with_parent(&trace->base, release_func);
trace->clock_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
if (!trace->clock_classes) {
BT_LOGE_STR("Failed to allocate one GPtrArray.");
goto error;
}
BT_LOGD_STR("Putting packet header field type.");
- bt_put(trace->packet_header_field_type);
+ bt_object_put_ref(trace->packet_header_field_type);
}
BT_HIDDEN
env_value_string_obj);
end:
- bt_put(env_value_string_obj);
+ bt_object_put_ref(env_value_string_obj);
return ret;
}
env_value_integer_obj);
end:
- bt_put(env_value_integer_obj);
+ bt_object_put_ref(env_value_integer_obj);
return ret;
}
goto end;
}
- bt_get(clock_class);
+ bt_object_get_ref(clock_class);
g_ptr_array_add(trace->clock_classes, clock_class);
if (trace->frozen) {
ret = bt_ctf_field_type_common_validate_single_clock_class(
trace->packet_header_field_type,
&clock_class);
- bt_put(clock_class);
+ bt_object_put_ref(clock_class);
if (ret || clock_class) {
BT_LOGW("Trace's packet header field type cannot "
"contain a field type which is mapped to "
int64_t event_class_count;
struct bt_ctf_trace_common *current_parent_trace = NULL;
struct bt_ctf_clock_class *expected_clock_class =
- bt_get(init_expected_clock_class);
+ bt_object_get_ref(init_expected_clock_class);
BT_ASSERT(copy_field_type_func);
* now because the stream class is frozen.
*/
if (expected_clock_class) {
- BT_MOVE(stream_class->clock_class, expected_clock_class);
+ BT_OBJECT_MOVE_REF(stream_class->clock_class, expected_clock_class);
}
BT_LOGD("Added stream class to trace: "
g_free(ec_validation_outputs);
bt_ctf_validation_output_put_types(&trace_sc_validation_output);
- bt_put(expected_clock_class);
+ bt_object_put_ref(expected_clock_class);
return ret;
}
goto end;
}
- bt_put(trace->packet_header_field_type);
- trace->packet_header_field_type = bt_get(packet_header_type);
+ bt_object_put_ref(trace->packet_header_field_type);
+ trace->packet_header_field_type = bt_object_get_ref(packet_header_type);
BT_LOGV("Set trace's packet header field type: "
"addr=%p, name=\"%s\", packet-context-ft-addr=%p",
trace, bt_ctf_trace_common_get_name(trace), packet_header_type);
return trace;
error:
- BT_PUT(trace);
+ BT_OBJECT_PUT_REF_AND_RESET(trace);
return trace;
}
struct bt_value *bt_ctf_trace_get_environment_field_value_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_get(bt_ctf_trace_common_borrow_environment_field_value_by_index(
+ return bt_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_index(
BT_CTF_TO_COMMON(trace), index));
}
struct bt_value *bt_ctf_trace_get_environment_field_value_by_name(
struct bt_ctf_trace *trace, const char *name)
{
- return bt_get(bt_ctf_trace_common_borrow_environment_field_value_by_name(
+ return bt_object_get_ref(bt_ctf_trace_common_borrow_environment_field_value_by_name(
BT_CTF_TO_COMMON(trace), name));
}
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_get(bt_ctf_trace_common_borrow_clock_class_by_index(
+ return bt_object_get_ref(bt_ctf_trace_common_borrow_clock_class_by_index(
BT_CTF_TO_COMMON(trace), index));
}
struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_get(bt_ctf_trace_common_borrow_stream_by_index(
+ return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_by_index(
BT_CTF_TO_COMMON(trace), index));
}
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index(
struct bt_ctf_trace *trace, uint64_t index)
{
- return bt_get(bt_ctf_trace_common_borrow_stream_class_by_index(
+ return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_index(
BT_CTF_TO_COMMON(trace), index));
}
struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
struct bt_ctf_trace *trace, uint64_t id)
{
- return bt_get(bt_ctf_trace_common_borrow_stream_class_by_id(
+ return bt_object_get_ref(bt_ctf_trace_common_borrow_stream_class_by_id(
BT_CTF_TO_COMMON(trace), id));
}
struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name(
struct bt_ctf_trace *trace, const char *name)
{
- return bt_get(
+ return bt_object_get_ref(
bt_ctf_trace_common_borrow_clock_class_by_name(BT_CTF_TO_COMMON(trace),
name));
}
struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_field_type(
struct bt_ctf_trace *trace)
{
- return bt_get(bt_ctf_trace_common_borrow_packet_header_field_type(
+ return bt_object_get_ref(bt_ctf_trace_common_borrow_packet_header_field_type(
BT_CTF_TO_COMMON(trace)));
}
#include <babeltrace/ctf-writer/clock-class-internal.h>
#include <babeltrace/ctf-writer/field-types-internal.h>
#include <babeltrace/ctf-writer/utils.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <glib.h>
#include <stdlib.h>
#include <babeltrace/ctf-writer/stream-class-internal.h>
#include <babeltrace/ctf-writer/trace-internal.h>
#include <babeltrace/ctf-writer/validation-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/values.h>
/*
}
/* Own the type parameters */
- bt_get(packet_header_type);
- bt_get(packet_context_type);
- bt_get(event_header_type);
- bt_get(stream_event_ctx_type);
- bt_get(event_context_type);
- bt_get(event_payload_type);
+ bt_object_get_ref(packet_header_type);
+ bt_object_get_ref(packet_context_type);
+ bt_object_get_ref(event_header_type);
+ bt_object_get_ref(stream_event_ctx_type);
+ bt_object_get_ref(event_context_type);
+ bt_object_get_ref(event_payload_type);
/* Validate trace */
if ((validate_flags & BT_CTF_VALIDATION_FLAG_TRACE) && !trace_valid) {
} else if (!contains_seq_var) {
/* No copy is needed */
packet_header_type_copy = packet_header_type;
- bt_get(packet_header_type_copy);
+ bt_object_get_ref(packet_header_type_copy);
goto skip_packet_header_type_copy;
}
skip_packet_header_type_copy:
/* Put original reference and move copy */
- BT_MOVE(packet_header_type, packet_header_type_copy);
+ BT_OBJECT_MOVE_REF(packet_header_type, packet_header_type_copy);
/* Validate trace field types */
valid_ret = validate_trace_types(environment,
} else if (!contains_seq_var) {
/* No copy is needed */
packet_context_type_copy = packet_context_type;
- bt_get(packet_context_type_copy);
+ bt_object_get_ref(packet_context_type_copy);
goto skip_packet_context_type_copy;
}
} else if (!contains_seq_var) {
/* No copy is needed */
event_header_type_copy = event_header_type;
- bt_get(event_header_type_copy);
+ bt_object_get_ref(event_header_type_copy);
goto skip_event_header_type_copy;
}
/* No copy is needed */
stream_event_ctx_type_copy =
stream_event_ctx_type;
- bt_get(stream_event_ctx_type_copy);
+ bt_object_get_ref(stream_event_ctx_type_copy);
goto skip_stream_event_ctx_type_copy;
}
skip_stream_event_ctx_type_copy:
/* Put original references and move copies */
- BT_MOVE(packet_context_type, packet_context_type_copy);
- BT_MOVE(event_header_type, event_header_type_copy);
- BT_MOVE(stream_event_ctx_type, stream_event_ctx_type_copy);
+ BT_OBJECT_MOVE_REF(packet_context_type, packet_context_type_copy);
+ BT_OBJECT_MOVE_REF(event_header_type, event_header_type_copy);
+ BT_OBJECT_MOVE_REF(stream_event_ctx_type, stream_event_ctx_type_copy);
/* Validate stream class field types */
valid_ret = validate_stream_class_types(environment,
goto sc_validation_done;
sc_validation_error:
- BT_PUT(packet_context_type_copy);
- BT_PUT(event_header_type_copy);
- BT_PUT(stream_event_ctx_type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_context_type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(event_header_type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type_copy);
ret = -1;
goto error;
}
} else if (!contains_seq_var) {
/* No copy is needed */
event_context_type_copy = event_context_type;
- bt_get(event_context_type_copy);
+ bt_object_get_ref(event_context_type_copy);
goto skip_event_context_type_copy;
}
} else if (!contains_seq_var) {
/* No copy is needed */
event_payload_type_copy = event_payload_type;
- bt_get(event_payload_type_copy);
+ bt_object_get_ref(event_payload_type_copy);
goto skip_event_payload_type_copy;
}
skip_event_payload_type_copy:
/* Put original references and move copies */
- BT_MOVE(event_context_type, event_context_type_copy);
- BT_MOVE(event_payload_type, event_payload_type_copy);
+ BT_OBJECT_MOVE_REF(event_context_type, event_context_type_copy);
+ BT_OBJECT_MOVE_REF(event_payload_type, event_payload_type_copy);
/* Validate event class field types */
valid_ret = validate_event_class_types(environment,
goto ec_validation_done;
ec_validation_error:
- BT_PUT(event_context_type_copy);
- BT_PUT(event_payload_type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(event_context_type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(event_payload_type_copy);
ret = -1;
goto error;
}
* to validate (and that were possibly altered by the validation
* process) to the output values.
*/
- BT_MOVE(output->packet_header_type, packet_header_type);
- BT_MOVE(output->packet_context_type, packet_context_type);
- BT_MOVE(output->event_header_type, event_header_type);
- BT_MOVE(output->stream_event_ctx_type, stream_event_ctx_type);
- BT_MOVE(output->event_context_type, event_context_type);
- BT_MOVE(output->event_payload_type, event_payload_type);
+ BT_OBJECT_MOVE_REF(output->packet_header_type, packet_header_type);
+ BT_OBJECT_MOVE_REF(output->packet_context_type, packet_context_type);
+ BT_OBJECT_MOVE_REF(output->event_header_type, event_header_type);
+ BT_OBJECT_MOVE_REF(output->stream_event_ctx_type, stream_event_ctx_type);
+ BT_OBJECT_MOVE_REF(output->event_context_type, event_context_type);
+ BT_OBJECT_MOVE_REF(output->event_payload_type, event_payload_type);
return ret;
error:
- BT_PUT(packet_header_type);
- BT_PUT(packet_context_type);
- BT_PUT(event_header_type);
- BT_PUT(stream_event_ctx_type);
- BT_PUT(event_context_type);
- BT_PUT(event_payload_type);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_header_type);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_context_type);
+ BT_OBJECT_PUT_REF_AND_RESET(event_header_type);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_type);
+ BT_OBJECT_PUT_REF_AND_RESET(event_context_type);
+ BT_OBJECT_PUT_REF_AND_RESET(event_payload_type);
return ret;
}
{
if ((replace_flags & BT_CTF_VALIDATION_FLAG_TRACE) && trace) {
bt_ctf_field_type_common_freeze(trace->packet_header_field_type);
- BT_MOVE(trace->packet_header_field_type,
+ BT_OBJECT_MOVE_REF(trace->packet_header_field_type,
output->packet_header_type);
}
bt_ctf_field_type_common_freeze(stream_class->packet_context_field_type);
bt_ctf_field_type_common_freeze(stream_class->event_header_field_type);
bt_ctf_field_type_common_freeze(stream_class->event_context_field_type);
- BT_MOVE(stream_class->packet_context_field_type,
+ BT_OBJECT_MOVE_REF(stream_class->packet_context_field_type,
output->packet_context_type);
- BT_MOVE(stream_class->event_header_field_type,
+ BT_OBJECT_MOVE_REF(stream_class->event_header_field_type,
output->event_header_type);
- BT_MOVE(stream_class->event_context_field_type,
+ BT_OBJECT_MOVE_REF(stream_class->event_context_field_type,
output->stream_event_ctx_type);
}
if ((replace_flags & BT_CTF_VALIDATION_FLAG_EVENT) && event_class) {
bt_ctf_field_type_common_freeze(event_class->context_field_type);
bt_ctf_field_type_common_freeze(event_class->payload_field_type);
- BT_MOVE(event_class->context_field_type, output->event_context_type);
- BT_MOVE(event_class->payload_field_type, output->event_payload_type);
+ BT_OBJECT_MOVE_REF(event_class->context_field_type, output->event_context_type);
+ BT_OBJECT_MOVE_REF(event_class->payload_field_type, output->event_payload_type);
}
}
void bt_ctf_validation_output_put_types(
struct bt_ctf_validation_output *output)
{
- BT_PUT(output->packet_header_type);
- BT_PUT(output->packet_context_type);
- BT_PUT(output->event_header_type);
- BT_PUT(output->stream_event_ctx_type);
- BT_PUT(output->event_context_type);
- BT_PUT(output->event_payload_type);
+ BT_OBJECT_PUT_REF_AND_RESET(output->packet_header_type);
+ BT_OBJECT_PUT_REF_AND_RESET(output->packet_context_type);
+ BT_OBJECT_PUT_REF_AND_RESET(output->event_header_type);
+ BT_OBJECT_PUT_REF_AND_RESET(output->stream_event_ctx_type);
+ BT_OBJECT_PUT_REF_AND_RESET(output->event_context_type);
+ BT_OBJECT_PUT_REF_AND_RESET(output->event_payload_type);
}
*/
#include <babeltrace/ctf-writer/visitor-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
BT_HIDDEN
int bt_ctf_visitor_helper(struct bt_ctf_visitor_object *root,
goto end;
}
ret = child_visitor(child, visitor, data);
- BT_PUT(child);
+ BT_OBJECT_PUT_REF_AND_RESET(child);
if (ret) {
goto end;
}
#include <babeltrace/ctf-writer/trace-internal.h>
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/endian-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
goto end;
}
end:
- bt_put(uuid_array_type);
- bt_put(_uint32_t);
- bt_put(_uint8_t);
- bt_put(trace_packet_header_type);
+ bt_object_put_ref(uuid_array_type);
+ bt_object_put_ref(_uint32_t);
+ bt_object_put_ref(_uint8_t);
+ bt_object_put_ref(trace_packet_header_type);
return ret;
}
}
bt_object_set_parent(&writer->trace->common.base, &writer->base);
- bt_put(writer->trace);
+ bt_object_put_ref(writer->trace);
/* Default to little-endian */
ret = bt_ctf_writer_set_byte_order(writer, BT_CTF_BYTE_ORDER_NATIVE);
return writer;
error_destroy:
- BT_PUT(writer);
+ BT_OBJECT_PUT_REF_AND_RESET(writer);
error:
g_free(metadata_path);
return writer;
}
trace = writer->trace;
- bt_get(trace);
+ bt_object_get_ref(trace);
end:
return trace;
}
stream_class_found = BT_TRUE;
}
- BT_PUT(existing_stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(existing_stream_class);
if (stream_class_found) {
break;
return stream;
error:
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
return stream;
}
field_type = bt_ctf_field_type_integer_create(size);
ret = bt_ctf_field_type_set_alignment(field_type, alignment);
if (ret) {
- BT_PUT(field_type);
+ BT_OBJECT_PUT_REF_AND_RESET(field_type);
}
end:
return field_type;
#define BT_LOG_TAG "COLANDER"
#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/graph/connection.h>
#include <babeltrace/graph/component-class-sink.h>
#include <babeltrace/graph/private-component-sink.h>
}
if (colander_data->notif_iter) {
- bt_put(colander_data->notif_iter);
+ bt_object_put_ref(colander_data->notif_iter);
}
g_free(colander_data);
BT_ASSERT(priv_conn);
BT_ASSERT(colander_data);
- BT_PUT(colander_data->notif_iter);
+ BT_OBJECT_PUT_REF_AND_RESET(colander_data->notif_iter);
conn_status = bt_private_connection_create_notification_iterator(
priv_conn, &colander_data->notif_iter);
if (conn_status) {
}
end:
- bt_put(priv_conn);
+ bt_object_put_ref(priv_conn);
return status;
}
(void) bt_component_class_freeze(colander_comp_cls);
end:
- return bt_get(colander_comp_cls);
+ return bt_object_get_ref(colander_comp_cls);
}
__attribute__((destructor)) static
void put_colander(void) {
- BT_PUT(colander_comp_cls);
+ BT_OBJECT_PUT_REF_AND_RESET(colander_comp_cls);
}
#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/assert-internal.h>
#include <glib.h>
goto end;
error:
- BT_PUT(class);
+ BT_OBJECT_PUT_REF_AND_RESET(class);
ret = -1;
end:
#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/values.h>
#include <babeltrace/values-internal.h>
* The component's reference count is 0 if we're here. Increment
* it to avoid a double-destroy (possibly infinitely recursive).
* This could happen for example if the component's finalization
- * function does bt_get() (or anything that causes bt_get() to
+ * function does bt_object_get_ref() (or anything that causes bt_object_get_ref() to
* be called) on itself (ref. count goes from 0 to 1), and then
- * bt_put(): the reference count would go from 1 to 0 again and
+ * bt_object_put_ref(): the reference count would go from 1 to 0 again and
* this function would be called again.
*/
obj->ref_count++;
}
BT_LOGD("Putting component class.");
- bt_put(component_class);
+ bt_object_put_ref(component_class);
g_free(component);
}
graph = bt_component_get_graph(component);
if (graph) {
bt_graph_notify_port_added(graph, new_port);
- BT_PUT(graph);
+ BT_OBJECT_PUT_REF_AND_RESET(graph);
}
BT_LOGD("Created and added port to component: comp-addr=%p, comp-name=\"%s\", "
bt_object_init_shared_with_parent(&component->base,
bt_component_destroy);
- component->class = bt_get(component_class);
+ component->class = bt_object_get_ref(component_class);
component->destroy = component_destroy_funcs[type];
component->name = g_string_new(name);
if (!component->name) {
"comp-cls-addr=%p, comp-cls-type=%s, name=\"%s\", comp-addr=%p",
component_class, bt_component_class_type_string(type), name,
component);
- BT_MOVE(*user_component, component);
+ BT_OBJECT_MOVE_REF(*user_component, component);
end:
- bt_put(component);
+ bt_object_put_ref(component);
return status;
}
struct bt_component_class *bt_component_get_class(
struct bt_component *component)
{
- return component ? bt_get(component->class) : NULL;
+ return component ? bt_object_get_ref(component->class) : NULL;
}
void *bt_private_component_get_user_data(
}
if (!strcmp(name, port_name)) {
- ret_port = bt_get(port);
+ ret_port = bt_object_get_ref(port);
break;
}
}
goto end;
}
- port = bt_get(g_ptr_array_index(ports, index));
+ port = bt_object_get_ref(g_ptr_array_index(ports, index));
end:
return port;
}
g_ptr_array_remove_index(ports, index);
/* Detach port from its component parent */
- BT_PUT(port->base.parent);
+ BT_OBJECT_PUT_REF_AND_RESET(port->base.parent);
/*
* Notify the graph's creator that a port is removed.
graph = bt_component_get_graph(component);
if (graph) {
bt_graph_notify_port_removed(graph, component, port);
- BT_PUT(graph);
+ BT_OBJECT_PUT_REF_AND_RESET(graph);
}
BT_LOGD("Removed port from component: "
g_ptr_array_free(connection->iterators, TRUE);
/*
- * No bt_put on ports as a connection only holds _weak_
+ * No bt_object_put_ref on ports as a connection only holds _weak_
* references to them.
*/
g_free(connection);
connection->iterators = g_ptr_array_new();
if (!connection->iterators) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
- BT_PUT(connection);
+ BT_OBJECT_PUT_REF_AND_RESET(connection);
goto end;
}
downstream_comp, upstream_port, downstream_port);
}
- bt_put(downstream_comp);
- bt_put(upstream_comp);
+ bt_object_put_ref(downstream_comp);
+ bt_object_put_ref(upstream_comp);
/*
* Because this connection is ended, finalize (cancel) each
struct bt_port *bt_connection_get_upstream_port(
struct bt_connection *connection)
{
- return connection ? bt_get(connection->upstream_port) : NULL;
+ return connection ? bt_object_get_ref(connection->upstream_port) : NULL;
}
struct bt_port *bt_connection_get_downstream_port(
struct bt_connection *connection)
{
- return connection ? bt_get(connection->downstream_port) : NULL;
+ return connection ? bt_object_get_ref(connection->downstream_port) : NULL;
}
enum bt_connection_status
iterator = NULL;
end:
- bt_put(upstream_component);
- bt_put(iterator);
+ bt_object_put_ref(upstream_component);
+ bt_object_put_ref(iterator);
return status;
}
}
end:
- bt_put(port);
+ bt_object_put_ref(port);
return status;
}
}
end:
- bt_put(port);
+ bt_object_put_ref(port);
return status;
}
end:
return graph;
error:
- BT_PUT(graph);
+ BT_OBJECT_PUT_REF_AND_RESET(graph);
goto end;
}
}
end:
- bt_put(upstream_graph);
- bt_put(downstream_graph);
- bt_put(upstream_component);
- bt_put(downstream_component);
- bt_put(connection);
+ bt_object_put_ref(upstream_graph);
+ bt_object_put_ref(downstream_graph);
+ bt_object_put_ref(upstream_component);
+ bt_object_put_ref(downstream_component);
+ bt_object_put_ref(connection);
if (graph) {
(void) init_can_consume;
bt_graph_set_can_consume(graph, init_can_consume);
size_t i;
bt_bool init_can_consume;
- bt_get(params);
+ bt_object_get_ref(params);
if (!graph) {
BT_LOGW_STR("Invalid parameter: graph is NULL.");
}
end:
- bt_put(component);
- bt_put(params);
+ bt_object_put_ref(component);
+ bt_object_put_ref(params);
if (graph) {
graph->can_consume = init_can_consume;
}
bt_component_get_input_port_by_index(component, i);
BT_ASSERT(port);
- bt_put(port);
+ bt_object_put_ref(port);
if (bt_port_is_connected(port)) {
BT_LOGW("Cannot remove component from graph: "
bt_component_get_output_port_by_index(component, i);
BT_ASSERT(port);
- bt_put(port);
+ bt_object_put_ref(port);
if (bt_port_is_connected(port)) {
BT_LOGW("Cannot remove component from graph: "
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/trace-ir/event-internal.h>
#include <babeltrace/trace-ir/packet-internal.h>
BT_LOGV("Destroying stream state: stream-state-addr=%p", stream_state);
BT_LOGV_STR("Putting stream state's current packet.");
- bt_put(stream_state->cur_packet);
+ bt_object_put_ref(stream_state->cur_packet);
BT_LOGV_STR("Putting stream state's stream.");
- bt_put(stream_state->stream);
+ bt_object_put_ref(stream_state->stream);
g_free(stream_state);
}
/*
* We keep a reference to the stream until we know it's ended.
*/
- stream_state->stream = bt_get(stream);
+ stream_state->stream = bt_object_get_ref(stream);
BT_LOGV("Created stream state: stream-addr=%p, stream-name=\"%s\", "
"stream-state-addr=%p",
stream, bt_stream_get_name(stream), stream_state);
* The notification iterator's reference count is 0 if we're
* here. Increment it to avoid a double-destroy (possibly
* infinitely recursive). This could happen for example if the
- * notification iterator's finalization function does bt_get()
- * (or anything that causes bt_get() to be called) on itself
- * (ref. count goes from 0 to 1), and then bt_put(): the
+ * notification iterator's finalization function does bt_object_get_ref()
+ * (or anything that causes bt_object_get_ref() to be called) on itself
+ * (ref. count goes from 0 to 1), and then bt_object_put_ref(): the
* reference count would go from 1 to 0 again and this function
* would be called again.
*/
iterator = NULL;
end:
- bt_put(iterator);
+ bt_object_put_ref(iterator);
return status;
}
goto end;
}
stream_state->expected_notif_seq_num++;
- stream_state->cur_packet = bt_get(packet);
+ stream_state->cur_packet = bt_object_get_ref(packet);
goto end;
case BT_NOTIFICATION_TYPE_PACKET_END:
if (!stream_state->cur_packet) {
goto end;
}
stream_state->expected_notif_seq_num++;
- BT_PUT(stream_state->cur_packet);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_state->cur_packet);
goto end;
case BT_NOTIFICATION_TYPE_EVENT:
if (packet != stream_state->cur_packet) {
* created. In this case, said connection is ended, and
* all its notification iterators are finalized.
*
- * Only bt_put() the returned notification if
+ * Only bt_object_put_ref() the returned notification if
* the status is
* BT_NOTIFICATION_ITERATOR_STATUS_OK because
* otherwise this field could be garbage.
(void *) user_iterator->notifs->pdata;
for (i = 0; i < *user_count; i++) {
- bt_put(notifs[i]);
+ bt_object_put_ref(notifs[i]);
}
}
"Notification iterator was not created from a private connection: "
"%!+i", iterator);
iter_priv_conn = (void *) iterator;
- return bt_get(iter_priv_conn->upstream_component);
+ return bt_object_get_ref(iter_priv_conn->upstream_component);
}
struct bt_private_component *
BT_LOGD("Destroying output port notification iterator object: addr=%p",
iterator);
BT_LOGD_STR("Putting graph.");
- bt_put(iterator->graph);
+ bt_object_put_ref(iterator->graph);
BT_LOGD_STR("Putting colander sink component.");
- bt_put(iterator->colander);
+ bt_object_put_ref(iterator->colander);
destroy_base_notification_iterator(obj);
}
bt_output_port_notification_iterator_destroy);
if (ret) {
/* init_notification_iterator() logs errors */
- BT_PUT(iterator);
+ BT_OBJECT_PUT_REF_AND_RESET(iterator);
goto end;
}
goto error;
}
- BT_MOVE(iterator->graph, graph);
+ BT_OBJECT_MOVE_REF(iterator->graph, graph);
colander_comp_name =
colander_component_name ? colander_component_name : "colander";
colander_data.notifs = (void *) iterator->base.notifs->pdata;
/* Remove created colander component from graph if any */
colander_comp = iterator->colander;
- BT_PUT(iterator->colander);
+ BT_OBJECT_PUT_REF_AND_RESET(iterator->colander);
/*
* At this point the colander component's reference
BT_ASSERT(ret == 0);
}
- BT_PUT(iterator);
+ BT_OBJECT_PUT_REF_AND_RESET(iterator);
end:
- bt_put(colander_in_port);
- bt_put(colander_comp_cls);
- bt_put(output_port_comp);
- bt_put(graph);
+ bt_object_put_ref(colander_in_port);
+ bt_object_put_ref(colander_comp_cls);
+ bt_object_put_ref(output_port_comp);
+ bt_object_put_ref(graph);
return (void *) iterator;
}
goto end;
error:
- BT_PUT(notification);
+ BT_OBJECT_PUT_REF_AND_RESET(notification);
end:
return (void *) notification;
goto end;
error:
- BT_PUT(ret_notif);
+ BT_OBJECT_PUT_REF_AND_RESET(ret_notif);
end:
return ret_notif;
goto end;
error:
- BT_PUT(notification);
+ BT_OBJECT_PUT_REF_AND_RESET(notification);
end:
return (void *) notification;
BT_LOGD("Destroying packet beginning notification: addr=%p", notif);
BT_LOGD_STR("Putting packet.");
- BT_PUT(packet_begin_notif->packet);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_begin_notif->packet);
g_free(notif);
}
goto end;
error:
- BT_PUT(notification);
+ BT_OBJECT_PUT_REF_AND_RESET(notification);
end:
return (void *) notification;
BT_LOGD("Destroying packet end notification: addr=%p", notif);
BT_LOGD_STR("Putting packet.");
- BT_PUT(packet_end_notif->packet);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet);
g_free(notif);
}
BT_LOGD("Recycling packet end notification: addr=%p", notif);
bt_notification_reset(notif);
- BT_PUT(packet_end_notif->packet);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_end_notif->packet);
graph = notif->graph;
notif->graph = NULL;
bt_object_pool_recycle_object(&graph->packet_end_notif_pool, notif);
BT_LOGD("Destroying stream end notification: addr=%p",
notification);
BT_LOGD_STR("Putting stream.");
- BT_PUT(notification->stream);
+ BT_OBJECT_PUT_REF_AND_RESET(notification->stream);
if (notification->default_cv) {
bt_clock_value_recycle(notification->default_cv);
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_STREAM_END,
bt_notification_stream_end_destroy, NULL);
- notification->stream = bt_get(stream);
+ notification->stream = bt_object_get_ref(stream);
BT_LOGD("Created stream end notification object: "
"stream-addr=%p, stream-name=\"%s\", "
"stream-class-addr=%p, stream-class-name=\"%s\", "
BT_LOGD("Destroying stream beginning notification: addr=%p",
notification);
BT_LOGD_STR("Putting stream.");
- BT_PUT(notification->stream);
+ BT_OBJECT_PUT_REF_AND_RESET(notification->stream);
if (notification->default_cv) {
bt_clock_value_recycle(notification->default_cv);
bt_notification_init(¬ification->parent,
BT_NOTIFICATION_TYPE_STREAM_BEGIN,
bt_notification_stream_begin_destroy, NULL);
- notification->stream = bt_get(stream);
+ notification->stream = bt_object_get_ref(stream);
BT_LOGD("Created stream beginning notification object: "
"stream-addr=%p, stream-name=\"%s\", "
"stream-class-addr=%p, stream-class-name=\"%s\", "
port->name = g_string_new(name);
if (!port->name) {
BT_LOGE_STR("Failed to allocate one GString.");
- BT_PUT(port);
+ BT_OBJECT_PUT_REF_AND_RESET(port);
goto end;
}
goto end;
}
- connection = bt_get(port->connection);
+ connection = bt_object_get_ref(port->connection);
end:
return connection;
}
end:
- bt_put(comp);
+ bt_object_put_ref(comp);
return status;
}
BT_LOGD("User method returned: status=%s, result-addr=%p",
bt_query_status_string(ret.status), ret.result);
if (query_exec->canceled) {
- BT_PUT(ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(ret.result);
ret.status = BT_QUERY_STATUS_EXECUTOR_CANCELED;
goto end;
} else {
* The user cannot decide that the executor is
* canceled if it's not.
*/
- BT_PUT(ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(ret.result);
ret.status = BT_QUERY_STATUS_ERROR;
goto end;
}
* This is reserved for invalid parameters passed to
* this function.
*/
- BT_PUT(ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(ret.result);
ret.status = BT_QUERY_STATUS_ERROR;
break;
case BT_QUERY_STATUS_OK:
BT_LOGW("User method did not return BT_QUERY_STATUS_OK, but result is not NULL: "
"status=%s, result-addr=%p",
bt_query_status_string(ret.status), ret.result);
- BT_PUT(ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(ret.result);
}
}
ret.result = NULL;
}
- bt_put(ret.result);
+ bt_object_put_ref(ret.result);
return ret.status;
}
}
end:
- bt_put(port);
+ bt_object_put_ref(port);
return status;
}
#define BT_LOG_TAG "COMP-SOURCE"
#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/private-component.h>
#include <babeltrace/graph/component-source-internal.h>
}
end:
- bt_put(port);
+ bt_object_put_ref(port);
return status;
}
--- /dev/null
+/*
+ * ref.c: reference counting
+ *
+ * Babeltrace Library
+ *
+ * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace/lib-logging-internal.h>
+
+#include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/object-internal.h>
+
+void *bt_object_get_ref(void *ptr)
+{
+ struct bt_object *obj = 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 ptr;
+}
+
+void bt_object_put_ref(void *ptr)
+{
+ struct bt_object *obj = 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);
+}
#include <babeltrace/lib-logging-internal.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/plugin/plugin-so-internal.h>
#include <babeltrace/plugin/plugin-dev.h>
bt_list_for_each_entry_safe(comp_class, tmp, &component_class_list, node) {
bt_list_del(&comp_class->node);
- BT_PUT(comp_class->so_handle);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle);
}
BT_LOGD_STR("Released references from all component classes to shared library handles.");
}
goto end;
error:
- BT_PUT(shared_lib_handle);
+ BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
end:
if (shared_lib_handle) {
BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO);
BT_ASSERT(spec);
- BT_PUT(spec->shared_lib_handle);
+ BT_OBJECT_PUT_REF_AND_RESET(spec->shared_lib_handle);
g_free(plugin->spec_data);
plugin->spec_data = NULL;
}
if (ret) {
BT_LOGE_STR("Cannot set component class's description.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's help string.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's initialization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's finalization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's query method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's \"accept port connection\" method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's \"port connected\" method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's \"port disconnected\" method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set component class's notification iterator initialization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set source component class's notification iterator finalization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set filter component class's notification iterator initialization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
if (ret) {
BT_LOGE_STR("Cannot set filter component class's notification iterator finalization method.");
status = BT_PLUGIN_STATUS_ERROR;
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
goto end;
}
}
*/
status = bt_plugin_add_component_class(plugin,
comp_class);
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
if (status < 0) {
BT_LOGE("Cannot add component class to plugin.");
goto end;
}
spec = plugin->spec_data;
- spec->shared_lib_handle = bt_get(shared_lib_handle);
+ spec->shared_lib_handle = bt_object_get_ref(shared_lib_handle);
goto end;
error:
- BT_PUT(plugin);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
end:
return plugin;
* even a warning.
*/
BT_LOGD_STR("Cannot initialize SO plugin object from sections.");
- BT_PUT(plugin);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
goto error;
}
/* Add to plugin set */
bt_plugin_set_add_plugin(plugin_set, plugin);
- bt_put(plugin);
+ bt_object_put_ref(plugin);
}
goto end;
error:
- BT_PUT(plugin_set);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
end:
return plugin_set;
__bt_get_end_section_component_class_descriptor_attributes());
end:
- BT_PUT(shared_lib_handle);
+ BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
return plugin_set;
}
cc_descr_attrs_begin, cc_descr_attrs_end);
end:
- BT_PUT(shared_lib_handle);
+ BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
return plugin_set;
}
void *data)
{
bt_list_del(&comp_class->node);
- BT_PUT(comp_class->so_handle);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle);
BT_LOGV("Component class destroyed: removed entry from list: "
"comp-cls-addr=%p", comp_class);
}
BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO);
bt_list_add(&comp_class->node, &component_class_list);
- comp_class->so_handle = bt_get(spec->shared_lib_handle);
+ comp_class->so_handle = bt_object_get_ref(spec->shared_lib_handle);
/* Add our custom destroy listener */
bt_component_class_add_destroy_listener(comp_class,
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/common-internal.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/plugin/plugin-so-internal.h>
goto end;
}
- plugin = bt_get(g_ptr_array_index(plugin_set->plugins, index));
+ plugin = bt_object_get_ref(g_ptr_array_index(plugin_set->plugins, index));
end:
return plugin;
for (i = 0; i < dirs->len; i++) {
GString *dir = g_ptr_array_index(dirs, i);
- BT_PUT(plugin_set);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
/*
* Skip this if the directory does not exist because
plugin_name) == 0) {
BT_LOGD("Plugin found in directory: name=\"%s\", path=\"%s\"",
plugin_name, dir->str);
- plugin = bt_get(candidate_plugin);
+ plugin = bt_object_get_ref(candidate_plugin);
goto end;
}
}
plugin_name, dir->str);
}
- bt_put(plugin_set);
+ bt_object_put_ref(plugin_set);
plugin_set = bt_plugin_create_all_from_static();
if (plugin_set) {
for (j = 0; j < plugin_set->plugins->len; j++) {
plugin_name) == 0) {
BT_LOGD("Plugin found in built-in plugins: "
"name=\"%s\"", plugin_name);
- plugin = bt_get(candidate_plugin);
+ plugin = bt_object_get_ref(candidate_plugin);
goto end;
}
}
end:
free(home_plugin_dir);
- bt_put(plugin_set);
+ bt_object_put_ref(plugin_set);
if (dirs) {
g_ptr_array_free(dirs, TRUE);
}
end:
- bt_put(plugin);
+ bt_object_put_ref(plugin);
return comp_cls;
}
bt_plugin_set_add_plugin(append_all_from_dir_info.plugin_set, plugin);
}
- bt_put(plugins_from_file);
+ bt_object_put_ref(plugins_from_file);
}
break;
}
goto end;
error:
- BT_PUT(plugin_set);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
end:
return plugin_set;
}
comp_class = g_ptr_array_index(plugin->comp_classes, index);
- bt_get(comp_class);
+ bt_object_get_ref(comp_class);
goto end;
error:
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
end:
return comp_class;
if (strcmp(name, comp_class_cand_name) == 0 &&
comp_class_cand_type == type) {
- comp_class = bt_get(comp_class_candidate);
+ comp_class = bt_object_get_ref(comp_class_candidate);
break;
}
}
goto end;
error:
- BT_PUT(comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_class);
end:
return comp_class;
/* Add new component class */
comp_class_index = plugin->comp_classes->len;
- g_ptr_array_add(plugin->comp_classes, bt_get(comp_class));
+ g_ptr_array_add(plugin->comp_classes, bt_object_get_ref(comp_class));
/* Special case for a shared object plugin */
if (plugin->type == BT_PLUGIN_TYPE_SO) {
status = BT_PLUGIN_STATUS_ERROR;
end:
- bt_put(comp_class_dup);
+ bt_object_put_ref(comp_class_dup);
return status;
}
+++ /dev/null
-/*
- * ref.c: reference counting
- *
- * Babeltrace Library
- *
- * Copyright (c) 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 "REF"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/object-internal.h>
-
-void *bt_get(void *ptr)
-{
- struct bt_object *obj = 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 ptr;
-}
-
-void bt_put(void *ptr)
-{
- struct bt_object *obj = 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);
-}
#define BT_LOG_TAG "ATTRS"
#include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/values-internal.h>
void bt_attributes_destroy(struct bt_value *attr_obj)
{
BT_LOGD("Destroying attributes object: addr=%p", attr_obj);
- bt_put(attr_obj);
+ bt_object_put_ref(attr_obj);
}
BT_HIDDEN
}
end:
- bt_put(attr_field_obj);
+ bt_object_put_ref(attr_field_obj);
return ret;
}
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <babeltrace/trace-ir/clock-value-internal.h>
#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/compat/string-internal.h>
goto end;
error:
- BT_PUT(clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_class);
end:
return clock_class;
#include <babeltrace/compat/uuid-internal.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <babeltrace/trace-ir/clock-value-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/types.h>
#include <babeltrace/compat/string-internal.h>
void bt_clock_value_destroy(struct bt_clock_value *clock_value)
{
BT_LIB_LOGD("Destroying clock value: %!+k", clock_value);
- bt_put(clock_value->clock_class);
+ bt_object_put_ref(clock_value->clock_class);
g_free(clock_value);
}
}
bt_object_init_unique(&ret->base);
- ret->clock_class = bt_get(clock_class);
+ ret->clock_class = bt_object_get_ref(clock_class);
bt_clock_class_freeze(clock_class);
BT_LIB_LOGD("Created clock value object: %!+k", ret);
}
if (likely(!clock_value->clock_class)) {
- clock_value->clock_class = bt_get(clock_class);
+ clock_value->clock_class = bt_object_get_ref(clock_class);
}
goto end;
* variable so that we can set the clock value's clock class
* member to NULL before recycling it. We CANNOT do this
* after we put the clock class reference because this
- * bt_put() could destroy the clock class, also destroying
+ * bt_object_put_ref() could destroy the clock class, also destroying
* its clock value pool, thus also destroying our clock value
* object (this would result in an invalid write access).
*
BT_ASSERT(clock_class);
clock_value->clock_class = NULL;
bt_object_pool_recycle_object(&clock_class->cv_pool, clock_value);
- bt_put(clock_class);
+ bt_object_put_ref(clock_class);
}
uint64_t bt_clock_value_get_value(struct bt_clock_value *clock_value)
#include <babeltrace/trace-ir/trace-internal.h>
#include <babeltrace/trace-ir/utils-internal.h>
#include <babeltrace/trace-ir/resolve-field-path-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/trace-ir/attributes-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/endian-internal.h>
}
BT_LOGD_STR("Putting context field classe.");
- bt_put(event_class->specific_context_fc);
+ bt_object_put_ref(event_class->specific_context_fc);
BT_LOGD_STR("Putting payload field classe.");
- bt_put(event_class->payload_fc);
+ bt_object_put_ref(event_class->payload_fc);
bt_object_pool_finalize(&event_class->event_pool);
g_free(obj);
}
goto end;
error:
- BT_PUT(event_class);
+ BT_OBJECT_PUT_REF_AND_RESET(event_class);
end:
return event_class;
}
bt_field_class_make_part_of_trace(field_class);
- bt_put(event_class->specific_context_fc);
- event_class->specific_context_fc = bt_get(field_class);
+ bt_object_put_ref(event_class->specific_context_fc);
+ event_class->specific_context_fc = bt_object_get_ref(field_class);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set event class's specific context field classe: %!+E",
event_class);
}
bt_field_class_make_part_of_trace(field_class);
- bt_put(event_class->payload_fc);
- event_class->payload_fc = bt_get(field_class);
+ bt_object_put_ref(event_class->payload_fc);
+ event_class->payload_fc = bt_object_get_ref(field_class);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set event class's payload field classe: %!+E", event_class);
#include <babeltrace/trace-ir/trace.h>
#include <babeltrace/trace-ir/trace-internal.h>
#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/trace-ir/attributes-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/assert-internal.h>
}
BT_LOGD_STR("Putting event's class.");
- bt_put(event->class);
+ bt_object_put_ref(event->class);
if (event->default_cv) {
bt_clock_value_recycle(event->default_cv);
}
BT_LOGD_STR("Putting event's packet.");
- bt_put(event->packet);
+ bt_object_put_ref(event->packet);
g_free(event);
}
#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/trace-ir/clock-class.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/endian-internal.h>
#include <babeltrace/assert-internal.h>
goto end;
error:
- BT_PUT(int_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(int_fc);
end:
return (void *) int_fc;
goto end;
error:
- BT_PUT(enum_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(enum_fc);
end:
return (void *) enum_fc;
goto end;
error:
- BT_PUT(real_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(real_fc);
end:
return (void *) real_fc;
}
BT_LOGD_STR("Putting named field classe's field classe.");
- bt_put(named_fc->fc);
+ bt_object_put_ref(named_fc->fc);
}
static
goto end;
error:
- BT_PUT(struct_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(struct_fc);
end:
return (void *) struct_fc;
named_fc = &g_array_index(container_fc->named_fcs,
struct bt_named_field_class, container_fc->named_fcs->len - 1);
named_fc->name = name_str;
- named_fc->fc = bt_get(fc);
+ named_fc->fc = bt_object_get_ref(fc);
g_hash_table_insert(container_fc->name_to_index, named_fc->name->str,
GUINT_TO_POINTER(container_fc->named_fcs->len - 1));
bt_field_class_freeze(fc);
BT_LIB_LOGD("Destroying variant field classe object: %!+F", fc);
finalize_named_field_classes_container((void *) fc);
BT_LOGD_STR("Putting selector field path.");
- bt_put(fc->selector_field_path);
+ bt_object_put_ref(fc->selector_field_path);
g_free(fc);
}
goto end;
error:
- BT_PUT(var_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(var_fc);
end:
return (void *) var_fc;
{
BT_ASSERT(element_fc);
init_field_class((void *) fc, type, release_func);
- fc->element_fc = bt_get(element_fc);
+ fc->element_fc = bt_object_get_ref(element_fc);
bt_field_class_freeze(element_fc);
}
{
BT_ASSERT(array_fc);
BT_LOGD_STR("Putting element field classe.");
- bt_put(array_fc->element_fc);
+ bt_object_put_ref(array_fc->element_fc);
}
static
goto end;
error:
- BT_PUT(array_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(array_fc);
end:
return (void *) array_fc;
BT_LIB_LOGD("Destroying dynamic array field classe object: %!+F", fc);
finalize_array_field_class((void *) fc);
BT_LOGD_STR("Putting length field path.");
- bt_put(fc->length_field_path);
+ bt_object_put_ref(fc->length_field_path);
g_free(fc);
}
goto end;
error:
- BT_PUT(array_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(array_fc);
end:
return (void *) array_fc;
goto end;
error:
- BT_PUT(string_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(string_fc);
end:
return (void *) string_fc;
goto end;
error:
- BT_PUT(field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(field_path);
end:
return field_path;
#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/compat/fcntl-internal.h>
#include <babeltrace/align-internal.h>
BT_ASSERT(fc);
bt_object_init_unique(&field->base);
field->methods = methods;
- field->class = bt_get(fc);
+ field->class = bt_object_get_ref(fc);
}
static
sizeof(char), 1);
if (!string_field->buf) {
BT_LOGE_STR("Failed to allocate a GArray.");
- BT_PUT(string_field);
+ BT_OBJECT_PUT_REF_AND_RESET(string_field);
goto end;
}
&struct_field->fields)) {
BT_LIB_LOGE("Cannot create structure member fields: "
"%![fc-]+F", fc);
- BT_PUT(struct_field);
+ BT_OBJECT_PUT_REF_AND_RESET(struct_field);
goto end;
}
&var_field->fields)) {
BT_LIB_LOGE("Cannot create variant member fields: "
"%![fc-]+F", fc);
- BT_PUT(var_field);
+ BT_OBJECT_PUT_REF_AND_RESET(var_field);
goto end;
}
if (init_array_field_fields(array_field)) {
BT_LIB_LOGE("Cannot create static array fields: "
"%![fc-]+F", fc);
- BT_PUT(array_field);
+ BT_OBJECT_PUT_REF_AND_RESET(array_field);
goto end;
}
if (init_array_field_fields(array_field)) {
BT_LIB_LOGE("Cannot create dynamic array fields: "
"%![fc-]+F", fc);
- BT_PUT(array_field);
+ BT_OBJECT_PUT_REF_AND_RESET(array_field);
goto end;
}
{
BT_ASSERT(field);
BT_LOGD_STR("Putting field's class.");
- bt_put(field->class);
+ bt_object_put_ref(field->class);
}
static
#include <babeltrace/trace-ir/clock-value-internal.h>
#include <babeltrace/trace-ir/trace-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
#include <inttypes.h>
* 2. Move the stream reference to our `stream`
* variable so that we can set the packet's stream member
* to NULL before recycling it. We CANNOT do this after
- * we put the stream reference because this bt_put()
+ * we put the stream reference because this bt_object_put_ref()
* could destroy the stream, also destroying its
* packet pool, thus also destroying our packet object (this
* would result in an invalid write access).
}
BT_LOGD_STR("Putting packet's stream.");
- bt_put(packet->stream);
+ bt_object_put_ref(packet->stream);
g_free(packet);
}
bt_object_init_shared(&packet->base,
(bt_object_release_func) bt_packet_recycle);
- packet->stream = bt_get(stream);
+ packet->stream = bt_object_get_ref(stream);
trace = bt_stream_class_borrow_trace_inline(stream->class);
BT_ASSERT(trace);
goto end;
error:
- BT_PUT(packet);
+ BT_OBJECT_PUT_REF_AND_RESET(packet);
end:
return packet;
field_path->root = root_scope;
if (!find_field_class_recursive(root_fc, tgt_fc, field_path)) {
/* Not found here */
- BT_PUT(field_path);
+ BT_OBJECT_PUT_REF_AND_RESET(field_path);
}
end:
}
end:
- bt_put(src_field_path);
- bt_put(tgt_field_path);
+ bt_object_put_ref(src_field_path);
+ bt_object_put_ref(tgt_field_path);
return is_valid;
}
#include <babeltrace/trace-ir/utils-internal.h>
#include <babeltrace/trace-ir/field-wrapper-internal.h>
#include <babeltrace/trace-ir/resolve-field-path-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/align-internal.h>
#include <babeltrace/endian-internal.h>
BT_LIB_LOGD("Destroying stream class: %!+S", stream_class);
BT_LOGD_STR("Putting default clock class.");
- bt_put(stream_class->default_clock_class);
+ bt_object_put_ref(stream_class->default_clock_class);
if (stream_class->event_classes) {
BT_LOGD_STR("Destroying event classes.");
}
BT_LOGD_STR("Putting event header field classe.");
- bt_put(stream_class->event_header_fc);
+ bt_object_put_ref(stream_class->event_header_fc);
BT_LOGD_STR("Putting packet context field classe.");
- bt_put(stream_class->packet_context_fc);
+ bt_object_put_ref(stream_class->packet_context_fc);
BT_LOGD_STR("Putting event common context field classe.");
- bt_put(stream_class->event_common_context_fc);
+ bt_object_put_ref(stream_class->event_common_context_fc);
bt_object_pool_finalize(&stream_class->event_header_field_pool);
bt_object_pool_finalize(&stream_class->packet_context_field_pool);
g_free(stream_class);
goto end;
error:
- BT_PUT(stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class);
end:
return stream_class;
}
bt_field_class_make_part_of_trace(field_class);
- bt_put(stream_class->packet_context_fc);
- stream_class->packet_context_fc = bt_get(field_class);
+ bt_object_put_ref(stream_class->packet_context_fc);
+ stream_class->packet_context_fc = bt_object_get_ref(field_class);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set stream class's packet context field classe: %!+S",
stream_class);
}
bt_field_class_make_part_of_trace(field_class);
- bt_put(stream_class->event_header_fc);
- stream_class->event_header_fc = bt_get(field_class);
+ bt_object_put_ref(stream_class->event_header_fc);
+ stream_class->event_header_fc = bt_object_get_ref(field_class);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set stream class's event header field classe: %!+S",
stream_class);
}
bt_field_class_make_part_of_trace(field_class);
- bt_put(stream_class->event_common_context_fc);
- stream_class->event_common_context_fc = bt_get(field_class);
+ bt_object_put_ref(stream_class->event_common_context_fc);
+ stream_class->event_common_context_fc = bt_object_get_ref(field_class);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set stream class's event common context field classe: %!+S",
stream_class);
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
- bt_put(stream_class->default_clock_class);
- stream_class->default_clock_class = bt_get(clock_class);
+ bt_object_put_ref(stream_class->default_clock_class);
+ stream_class->default_clock_class = bt_object_get_ref(clock_class);
bt_clock_class_freeze(clock_class);
BT_LIB_LOGV("Set stream class's default clock class: %!+S",
stream_class);
#include <babeltrace/trace-ir/trace.h>
#include <babeltrace/trace-ir/trace-internal.h>
#include <babeltrace/trace-ir/packet-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/align-internal.h>
#include <babeltrace/assert-internal.h>
goto end;
error:
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
end:
return stream;
#include <babeltrace/compiler-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/values-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/types.h>
#include <babeltrace/endian-internal.h>
#include <babeltrace/assert-internal.h>
}
BT_LOGD_STR("Putting packet header field classe.");
- bt_put(trace->packet_header_fc);
+ bt_object_put_ref(trace->packet_header_fc);
g_free(trace);
}
goto end;
error:
- BT_PUT(trace);
+ BT_OBJECT_PUT_REF_AND_RESET(trace);
end:
return trace;
ret = set_environment_entry(trace, name, value_obj);
end:
- bt_put(value_obj);
+ bt_object_put_ref(value_obj);
return ret;
}
ret = set_environment_entry(trace, name, value_obj);
end:
- bt_put(value_obj);
+ bt_object_put_ref(value_obj);
return ret;
}
}
bt_field_class_make_part_of_trace(field_class);
- bt_put(trace->packet_header_fc);
- trace->packet_header_fc = bt_get(field_class);
+ bt_object_put_ref(trace->packet_header_fc);
+ trace->packet_header_fc = bt_object_get_ref(field_class);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set trace's packet header field classe: %!+t", trace);
#include <glib.h>
#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/clock-class.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
#include <string.h>
#include <inttypes.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/values.h>
#include <babeltrace/compat/glib-internal.h>
#include <babeltrace/types.h>
BT_LOGE("Cannot copy array value's element: "
"array-addr=%p, index=%d",
array_obj, i);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
ret = bt_value_array_append_element(copy_obj, element_obj_copy);
- BT_PUT(element_obj_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
BT_LOGE("Cannot append to array value: addr=%p",
array_obj);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
}
BT_LOGE("Cannot copy map value's element: "
"map-addr=%p, key=\"%s\"",
map_obj, key_str);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
ret = bt_value_map_insert_entry(copy_obj, key_str, element_obj_copy);
- BT_PUT(element_obj_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
map_obj, key_str);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
}
array_obj->base = bt_value_create_base(BT_VALUE_TYPE_ARRAY);
array_obj->garray = bt_g_ptr_array_new_full(0,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
if (!array_obj->garray) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
g_free(array_obj);
map_obj->base = bt_value_create_base(BT_VALUE_TYPE_MAP);
map_obj->ght = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify) bt_put);
+ NULL, (GDestroyNotify) bt_object_put_ref);
if (!map_obj->ght) {
BT_LOGE_STR("Failed to allocate a GHashTable.");
g_free(map_obj);
BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
g_ptr_array_add(typed_array_obj->garray, element_obj);
- bt_get(element_obj);
+ bt_object_get_ref(element_obj);
BT_LOGV("Appended element to array value: array-value-addr=%p, "
"element-value-addr=%p, new-size=%u",
array_obj, element_obj, typed_array_obj->garray->len);
bool_obj = bt_value_bool_create_init(val);
ret = bt_value_array_append_element(array_obj, bool_obj);
- bt_put(bool_obj);
+ bt_object_put_ref(bool_obj);
return ret;
}
integer_obj = bt_value_integer_create_init(val);
ret = bt_value_array_append_element(array_obj, integer_obj);
- bt_put(integer_obj);
+ bt_object_put_ref(integer_obj);
return ret;
}
real_obj = bt_value_real_create_init(val);
ret = bt_value_array_append_element(array_obj, real_obj);
- bt_put(real_obj);
+ bt_object_put_ref(real_obj);
return ret;
}
string_obj = bt_value_string_create_init(val);
ret = bt_value_array_append_element(array_obj, string_obj);
- bt_put(string_obj);
+ bt_object_put_ref(string_obj);
return ret;
}
empty_array_obj = bt_value_array_create();
ret = bt_value_array_append_element(array_obj, empty_array_obj);
- bt_put(empty_array_obj);
+ bt_object_put_ref(empty_array_obj);
return ret;
}
map_obj = bt_value_map_create();
ret = bt_value_array_append_element(array_obj, map_obj);
- bt_put(map_obj);
+ bt_object_put_ref(map_obj);
return ret;
}
BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index,
typed_array_obj->garray->len);
- bt_put(g_ptr_array_index(typed_array_obj->garray, index));
+ bt_object_put_ref(g_ptr_array_index(typed_array_obj->garray, index));
g_ptr_array_index(typed_array_obj->garray, index) = element_obj;
- bt_get(element_obj);
+ bt_object_get_ref(element_obj);
BT_LOGV("Set array value's element: array-value-addr=%p, "
"index=%" PRIu64 ", element-value-addr=%p",
array_obj, index, element_obj);
BT_ASSERT_PRE_VALUE_HOT(map_obj, "Map value object");
g_hash_table_insert(BT_VALUE_TO_MAP(map_obj)->ght,
GUINT_TO_POINTER(g_quark_from_string(key)), element_obj);
- bt_get(element_obj);
+ bt_object_get_ref(element_obj);
BT_LOGV("Inserted value into map value: map-value-addr=%p, "
"key=\"%s\", element-value-addr=%p",
map_obj, key, element_obj);
bool_obj = bt_value_bool_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, bool_obj);
- bt_put(bool_obj);
+ bt_object_put_ref(bool_obj);
return ret;
}
integer_obj = bt_value_integer_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, integer_obj);
- bt_put(integer_obj);
+ bt_object_put_ref(integer_obj);
return ret;
}
real_obj = bt_value_real_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, real_obj);
- bt_put(real_obj);
+ bt_object_put_ref(real_obj);
return ret;
}
string_obj = bt_value_string_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, string_obj);
- bt_put(string_obj);
+ bt_object_put_ref(string_obj);
return ret;
}
array_obj = bt_value_array_create();
ret = bt_value_map_insert_entry(map_obj, key, array_obj);
- bt_put(array_obj);
+ bt_object_put_ref(array_obj);
return ret;
}
empty_map_obj = bt_value_map_create();
ret = bt_value_map_insert_entry(map_obj, key, empty_map_obj);
- bt_put(empty_map_obj);
+ bt_object_put_ref(empty_map_obj);
return ret;
}
extend_data->got_error = BT_TRUE;
end:
- BT_PUT(extension_obj_elem_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(extension_obj_elem_copy);
return ret;
}
goto end;
error:
- BT_PUT(extended_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(extended_obj);
end:
return extended_obj;
#include <babeltrace/bitfield-internal.h>
#include <babeltrace/common-internal.h>
#include <babeltrace/babeltrace.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/align-internal.h>
#include <glib.h>
ret = bt_field_class_structure_append_member(ir_fc,
named_fc->name->str, member_ir_fc);
BT_ASSERT(ret == 0);
- bt_put(member_ir_fc);
+ bt_object_put_ref(member_ir_fc);
}
return ir_fc;
ret = bt_field_class_variant_append_option(ir_fc,
named_fc->name->str, option_ir_fc);
BT_ASSERT(ret == 0);
- bt_put(option_ir_fc);
+ bt_object_put_ref(option_ir_fc);
}
return ir_fc;
BT_ASSERT(elem_ir_fc);
ir_fc = bt_field_class_static_array_create(elem_ir_fc, fc->length);
BT_ASSERT(ir_fc);
- bt_put(elem_ir_fc);
+ bt_object_put_ref(elem_ir_fc);
end:
return ir_fc;
BT_ASSERT(elem_ir_fc);
ir_fc = bt_field_class_dynamic_array_create(elem_ir_fc);
BT_ASSERT(ir_fc);
- bt_put(elem_ir_fc);
+ bt_object_put_ref(elem_ir_fc);
BT_ASSERT(ir_fc);
ret = bt_field_class_dynamic_array_set_length_field_class(ir_fc,
borrow_ir_ft_from_field_path(&fc->length_path, tc, sc, ec));
ir_ec = bt_event_class_create_with_id(ir_sc, ec->id);
BT_ASSERT(ir_ec);
- bt_put(ir_ec);
+ bt_object_put_ref(ir_ec);
if (ec->spec_context_fc) {
struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
ret = bt_event_class_set_specific_context_field_class(
ir_ec, ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_fc);
+ bt_object_put_ref(ir_fc);
}
}
ret = bt_event_class_set_payload_field_class(ir_ec,
ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_fc);
+ bt_object_put_ref(ir_fc);
}
}
ir_sc = bt_stream_class_create_with_id(ir_trace, sc->id);
BT_ASSERT(ir_sc);
- bt_put(ir_sc);
+ bt_object_put_ref(ir_sc);
if (sc->packet_context_fc) {
struct bt_field_class *ir_fc = scope_ctf_field_class_to_ir(
ret = bt_stream_class_set_packet_context_field_class(
ir_sc, ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_fc);
+ bt_object_put_ref(ir_fc);
}
}
ret = bt_stream_class_set_event_header_field_class(ir_sc,
ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_fc);
+ bt_object_put_ref(ir_fc);
}
}
ret = bt_stream_class_set_event_common_context_field_class(
ir_sc, ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_fc);
+ bt_object_put_ref(ir_fc);
}
}
ret = bt_trace_set_packet_header_field_class(ir_trace,
ir_fc);
BT_ASSERT(ret == 0);
- bt_put(ir_fc);
+ bt_object_put_ref(ir_fc);
}
}
}
if (!stream_class->default_clock_class) {
- stream_class->default_clock_class = bt_get(clock_class);
+ stream_class->default_clock_class = bt_object_get_ref(clock_class);
}
end:
void _ctf_field_class_int_destroy(struct ctf_field_class_int *fc)
{
BT_ASSERT(fc);
- bt_put(fc->mapped_clock_class);
+ bt_object_put_ref(fc->mapped_clock_class);
g_free(fc);
}
void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc)
{
BT_ASSERT(fc);
- bt_put(fc->base.mapped_clock_class);
+ bt_object_put_ref(fc->base.mapped_clock_class);
if (fc->mappings) {
uint64_t i;
dst_fc->is_signed = src_fc->is_signed;
dst_fc->disp_base = src_fc->disp_base;
dst_fc->encoding = src_fc->encoding;
- dst_fc->mapped_clock_class = bt_get(src_fc->mapped_clock_class);
+ dst_fc->mapped_clock_class = bt_object_get_ref(src_fc->mapped_clock_class);
dst_fc->storing_index = src_fc->storing_index;
}
ctf_field_class_destroy(sc->packet_context_fc);
ctf_field_class_destroy(sc->event_header_fc);
ctf_field_class_destroy(sc->event_common_context_fc);
- bt_put(sc->default_clock_class);
+ bt_object_put_ref(sc->default_clock_class);
g_free(sc);
}
tc->default_byte_order = -1;
BT_ASSERT(tc->name);
tc->clock_classes = g_ptr_array_new_with_free_func(
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
BT_ASSERT(tc->clock_classes);
tc->stream_classes = g_ptr_array_new_with_free_func(
(GDestroyNotify) ctf_stream_class_destroy);
scope = parent_scope;
}
- bt_put(ctx->trace);
+ bt_object_put_ref(ctx->trace);
if (ctx->ctf_tc) {
ctf_trace_class_destroy(ctx->ctf_tc);
(*integer_decl)->is_signed = (signedness > 0);
(*integer_decl)->disp_base = base;
(*integer_decl)->encoding = encoding;
- (*integer_decl)->mapped_clock_class = bt_get(mapped_clock_class);
+ (*integer_decl)->mapped_clock_class = bt_object_get_ref(mapped_clock_class);
return 0;
error:
"default");
BT_ASSERT(ret == 0);
g_ptr_array_add(ctx->ctf_tc->clock_classes,
- bt_get(clock_class_to_map_to));
+ bt_object_get_ref(clock_class_to_map_to));
break;
case 1:
/*
* this one.
*/
clock_class_to_map_to =
- bt_get(ctx->ctf_tc->clock_classes->pdata[0]);
+ bt_object_get_ref(ctx->ctf_tc->clock_classes->pdata[0]);
break;
default:
/*
}
BT_ASSERT(clock_class_to_map_to);
- int_fc->mapped_clock_class = bt_get(clock_class_to_map_to);
+ int_fc->mapped_clock_class = bt_object_get_ref(clock_class_to_map_to);
end:
- bt_put(clock_class_to_map_to);
+ bt_object_put_ref(clock_class_to_map_to);
return ret;
}
ret = bt_clock_class_set_offset(clock, offset_seconds, offset_cycles);
BT_ASSERT(ret == 0);
apply_clock_class_offset(ctx, clock);
- g_ptr_array_add(ctx->ctf_tc->clock_classes, bt_get(clock));
+ g_ptr_array_add(ctx->ctf_tc->clock_classes, bt_object_get_ref(clock));
end:
- BT_PUT(clock);
+ BT_OBJECT_PUT_REF_AND_RESET(clock);
return ret;
}
BT_ASSERT(ctx);
BT_ASSERT(ctx->trace);
- return bt_get(ctx->trace);
+ return bt_object_get_ref(ctx->trace);
}
BT_HIDDEN
"stream-class-addr=%p, stream-class-id=%" PRId64,
notit, notit->meta.sc,
notit->meta.sc->id);
- stream = bt_get(notit->medium.medops.borrow_stream(
+ stream = bt_object_get_ref(notit->medium.medops.borrow_stream(
notit->meta.sc->ir_sc, notit->cur_data_stream_id,
notit->medium.data));
BT_LOGV("User function returned: stream-addr=%p", stream);
goto end;
}
- BT_MOVE(notit->stream, stream);
+ BT_OBJECT_MOVE_REF(notit->stream, stream);
end:
- bt_put(stream);
+ bt_object_put_ref(stream);
return status;
}
goto end;
error:
- BT_PUT(packet);
+ BT_OBJECT_PUT_REF_AND_RESET(packet);
status = BT_NOTIF_ITER_STATUS_ERROR;
end:
- BT_MOVE(notit->packet, packet);
+ BT_OBJECT_MOVE_REF(notit->packet, packet);
return status;
}
goto end;
error:
- BT_PUT(notif);
+ BT_OBJECT_PUT_REF_AND_RESET(notif);
status = BT_NOTIF_ITER_STATUS_ERROR;
end:
- BT_MOVE(notit->event_notif, notif);
+ BT_OBJECT_MOVE_REF(notit->event_notif, notif);
return status;
}
stack_clear(notit->stack);
notit->meta.sc = NULL;
notit->meta.ec = NULL;
- BT_PUT(notit->packet);
- BT_PUT(notit->stream);
- BT_PUT(notit->event_notif);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->packet);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->stream);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->event_notif);
release_all_dscopes(notit);
notit->cur_dscope_field = NULL;
notit->cur_packet_offset);
stack_clear(notit->stack);
notit->meta.ec = NULL;
- BT_PUT(notit->packet);
- BT_PUT(notit->event_notif);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->packet);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->event_notif);
release_all_dscopes(notit);
notit->cur_dscope_field = NULL;
status = set_current_stream(notit);
if (status != BT_NOTIF_ITER_STATUS_OK) {
- BT_PUT(ret);
+ BT_OBJECT_PUT_REF_AND_RESET(ret);
goto end;
}
}
- BT_PUT(notit->packet);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->packet);
*notification = notif;
}
void bt_notif_iter_destroy(struct bt_notif_iter *notit)
{
- BT_PUT(notit->packet);
- BT_PUT(notit->stream);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->packet);
+ BT_OBJECT_PUT_REF_AND_RESET(notit->stream);
release_all_dscopes(notit);
BT_LOGD("Destroying CTF plugin notification iterator: addr=%p", notit);
static
void unref_stream_class(struct bt_stream_class *writer_stream_class)
{
- bt_put(writer_stream_class);
+ bt_object_put_ref(writer_stream_class);
}
static
void unref_stream(struct bt_stream_class *writer_stream)
{
- bt_put(writer_stream);
+ bt_object_put_ref(writer_stream);
}
static
goto end;
error:
- BT_PUT(writer_stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class);
end:
- bt_put(writer_trace);
- bt_put(trace);
+ bt_object_put_ref(writer_trace);
+ bt_object_put_ref(trace);
return writer_stream_class;
}
ret = ctf_copy_trace(writer_component->err, trace, writer_trace);
if (ret != BT_COMPONENT_STATUS_OK) {
BT_LOGE_STR("Failed to copy trace.");
- BT_PUT(ctf_writer);
+ BT_OBJECT_PUT_REF_AND_RESET(ctf_writer);
goto error;
}
fs_writer->trace = trace;
fs_writer->writer_trace = writer_trace;
fs_writer->writer_component = writer_component;
- BT_PUT(writer_trace);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_trace);
fs_writer->stream_class_map = g_hash_table_new_full(g_direct_hash,
g_direct_equal, NULL, (GDestroyNotify) unref_stream_class);
fs_writer->stream_map = g_hash_table_new_full(g_direct_hash,
BT_ASSERT(stream);
insert_new_stream_state(writer_component, fs_writer, stream);
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
}
/* Check if the trace is already static or register a listener. */
error:
g_free(fs_writer);
fs_writer = NULL;
- bt_put(writer_trace);
- bt_put(stream);
- BT_PUT(ctf_writer);
+ bt_object_put_ref(writer_trace);
+ bt_object_put_ref(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(ctf_writer);
end:
return fs_writer;
}
if (!fs_writer) {
fs_writer = insert_new_writer(writer_component, trace);
}
- BT_PUT(trace);
+ BT_OBJECT_PUT_REF_AND_RESET(trace);
return fs_writer;
}
fs_writer = get_fs_writer(writer_component, stream_class);
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
return fs_writer;
}
{
struct bt_stream *writer_stream = NULL;
struct bt_stream_class *writer_stream_class = NULL;
- struct bt_ctf_writer *ctf_writer = bt_get(fs_writer->writer);
+ struct bt_ctf_writer *ctf_writer = bt_object_get_ref(fs_writer->writer);
writer_stream_class = lookup_stream_class(writer_component,
stream_class);
goto error;
}
}
- bt_get(writer_stream_class);
+ bt_object_get_ref(writer_stream_class);
writer_stream = bt_stream_create(writer_stream_class,
bt_stream_get_name(stream));
goto end;
error:
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
end:
- bt_put(ctf_writer);
- bt_put(writer_stream_class);
+ bt_object_put_ref(ctf_writer);
+ bt_object_put_ref(writer_stream_class);
return writer_stream;
}
BT_LOGE_STR("Failed to find existing stream.");
goto error;
}
- bt_get(writer_stream);
+ bt_object_get_ref(writer_stream);
goto end;
error:
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
end:
return writer_stream;
}
error:
ret = BT_COMPONENT_STATUS_ERROR;
end:
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
return ret;
}
error:
ret = BT_COMPONENT_STATUS_ERROR;
end:
- BT_PUT(trace);
- BT_PUT(stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(trace);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class);
return ret;
}
BT_LOGE_STR("Failed to get writer_stream.");
goto error;
}
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
int_ret = ctf_stream_copy_packet_context(
writer_component->err, packet, writer_stream);
error:
ret = BT_COMPONENT_STATUS_ERROR;
end:
- bt_put(writer_stream);
- bt_put(stream);
+ bt_object_put_ref(writer_stream);
+ bt_object_put_ref(stream);
return ret;
}
BT_LOGE_STR("Failed to find existing stream.");
goto error;
}
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
- bt_get(writer_stream);
+ bt_object_get_ref(writer_stream);
ret = bt_stream_flush(writer_stream);
if (ret) {
goto error;
}
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
ret = BT_COMPONENT_STATUS_OK;
goto end;
error:
ret = BT_COMPONENT_STATUS_ERROR;
end:
- bt_put(writer_stream);
- bt_put(stream);
+ bt_object_put_ref(writer_stream);
+ bt_object_put_ref(stream);
return ret;
}
BT_ASSERT(stream);
writer_stream = lookup_stream(writer_component, stream);
- if (!writer_stream || !bt_get(writer_stream)) {
+ if (!writer_stream || !bt_object_get_ref(writer_stream)) {
BT_LOGE_STR("Failed for find existing stream.");
goto error;
}
BT_ASSERT(stream_class);
writer_stream_class = lookup_stream_class(writer_component, stream_class);
- if (!writer_stream_class || !bt_get(writer_stream_class)) {
+ if (!writer_stream_class || !bt_object_get_ref(writer_stream_class)) {
BT_LOGE_STR("Failed to find existing stream_class.");
goto error;
}
error:
ret = BT_COMPONENT_STATUS_ERROR;
end:
- bt_put(writer_trace);
- bt_put(writer_event);
- bt_put(writer_event_class);
- bt_put(writer_stream_class);
- bt_put(stream_class);
- bt_put(writer_stream);
- bt_put(stream);
- bt_put(event_class);
+ bt_object_put_ref(writer_trace);
+ bt_object_put_ref(writer_event);
+ bt_object_put_ref(writer_event_class);
+ bt_object_put_ref(writer_stream_class);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(writer_stream);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(event_class);
return ret;
}
static
void destroy_writer_component_data(struct writer_component *writer_component)
{
- bt_put(writer_component->input_iterator);
+ bt_object_put_ref(writer_component->input_iterator);
g_hash_table_foreach_remove(writer_component->trace_map,
empty_trace_map, writer_component);
static
void free_fs_writer(struct fs_writer *fs_writer)
{
- bt_put(fs_writer->writer);
+ bt_object_put_ref(fs_writer->writer);
g_free(fs_writer);
}
}
ret = writer_new_packet(writer_component, packet);
- bt_put(packet);
+ bt_object_put_ref(packet);
break;
}
case BT_NOTIFICATION_TYPE_PACKET_END:
goto end;
}
ret = writer_close_packet(writer_component, packet);
- bt_put(packet);
+ bt_object_put_ref(packet);
break;
}
case BT_NOTIFICATION_TYPE_EVENT:
goto end;
}
ret = writer_output_event(writer_component, event);
- bt_put(event);
+ bt_object_put_ref(event);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
goto end;
}
ret = writer_stream_begin(writer_component, stream);
- bt_put(stream);
+ bt_object_put_ref(stream);
break;
}
case BT_NOTIFICATION_TYPE_STREAM_END:
goto end;
}
ret = writer_stream_end(writer_component, stream);
- bt_put(stream);
+ bt_object_put_ref(stream);
break;
}
default:
writer->error = true;
}
- bt_put(connection);
+ bt_object_put_ref(connection);
}
BT_HIDDEN
switch (it_ret) {
case BT_NOTIFICATION_ITERATOR_STATUS_END:
ret = BT_COMPONENT_STATUS_END;
- BT_PUT(writer_component->input_iterator);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_component->input_iterator);
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
ret = BT_COMPONENT_STATUS_AGAIN;
BT_ASSERT(notification);
ret = handle_notification(writer_component, notification);
end:
- bt_put(notification);
+ bt_object_put_ref(notification);
return ret;
}
*found = true;
}
end:
- bt_put(value);
+ bt_object_put_ref(value);
return ret;
}
ret = BT_COMPONENT_STATUS_INVALID;
goto error;
}
- bt_put(value);
+ bt_object_put_ref(value);
writer_component->base_path = g_string_new(path);
if (!writer_component->base_path) {
goto error;
}
- ds_file->stream = bt_get(stream);
+ ds_file->stream = bt_object_get_ref(stream);
ds_file->metadata = ctf_fs_trace->metadata;
g_string_assign(ds_file->file->path, path);
ret = ctf_fs_file_open(ds_file->file, "rb");
return;
}
- bt_put(ds_file->cc_prio_map);
- bt_put(ds_file->stream);
+ bt_object_put_ref(ds_file->cc_prio_map);
+ bt_object_put_ref(ds_file->stream);
(void) ds_file_munmap(ds_file);
if (ds_file->file) {
* BT_NOTIFICATION_TYPE_STREAM_BEGIN
* notification: skip this one, get a new one.
*/
- BT_PUT(*notif);
+ BT_OBJECT_PUT_REF_AND_RESET(*notif);
status = ctf_fs_ds_file_next(notif_iter_data->ds_file,
notif);
BT_ASSERT(status != BT_NOTIFICATION_ITERATOR_STATUS_END);
goto end;
}
- BT_PUT(*notif);
+ BT_OBJECT_PUT_REF_AND_RESET(*notif);
bt_notif_iter_reset(notif_iter_data->notif_iter);
/*
if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
BT_ASSERT(bt_notification_get_type(*notif) ==
BT_NOTIFICATION_TYPE_STREAM_BEGIN);
- BT_PUT(*notif);
+ BT_OBJECT_PUT_REF_AND_RESET(*notif);
status = ctf_fs_ds_file_next(notif_iter_data->ds_file,
notif);
BT_ASSERT(status != BT_NOTIFICATION_ITERATOR_STATUS_END);
g_ptr_array_free(ds_file_group->ds_file_infos, TRUE);
}
- bt_put(ds_file_group->stream);
- bt_put(ds_file_group->stream_class);
+ bt_object_put_ref(ds_file_group->stream);
+ bt_object_put_ref(ds_file_group->stream_class);
g_free(ds_file_group);
}
ds_file_group->stream_id = stream_instance_id;
BT_ASSERT(stream_class);
- ds_file_group->stream_class = bt_get(stream_class);
+ ds_file_group->stream_class = bt_object_get_ref(stream_class);
ds_file_group->ctf_fs_trace = ctf_fs_trace;
goto end;
}
if (metadata->trace) {
- BT_PUT(metadata->trace);
+ BT_OBJECT_PUT_REF_AND_RESET(metadata->trace);
}
if (metadata->decoder) {
goto end;
error:
- BT_PUT(query_ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(query_ret.result);
if (query_ret.status >= 0) {
query_ret.status = BT_QUERY_STATUS_ERROR;
goto end;
}
end:
- bt_put(range_map);
+ bt_object_put_ref(range_map);
return ret;
}
goto end;
}
end:
- bt_put(file_paths);
+ bt_object_put_ref(file_paths);
return ret;
}
ret = populate_stream_info(group, group_info, &group_range);
if (ret) {
- bt_put(group_info);
+ bt_object_put_ref(group_info);
goto end;
}
group_range.end_ns);
trace_intersection.set = true;
status = bt_value_array_append_element(file_groups, group_info);
- bt_put(group_info);
+ bt_object_put_ref(group_info);
if (status != BT_VALUE_STATUS_OK) {
goto end;
}
}
status = bt_value_map_insert_entry(trace_info, "streams", file_groups);
- BT_PUT(file_groups);
+ BT_OBJECT_PUT_REF_AND_RESET(file_groups);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
end:
- bt_put(file_groups);
+ bt_object_put_ref(file_groups);
ctf_fs_trace_destroy(trace);
return ret;
}
ret = populate_trace_info(trace_path->str, trace_name->str,
trace_info);
if (ret) {
- bt_put(trace_info);
+ bt_object_put_ref(trace_info);
goto error;
}
status = bt_value_array_append_element(query_ret.result, trace_info);
- bt_put(trace_info);
+ bt_object_put_ref(trace_info);
if (status != BT_VALUE_STATUS_OK) {
goto error;
}
goto end;
error:
- BT_PUT(query_ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(query_ret.result);
if (query_ret.status >= 0) {
query_ret.status = BT_QUERY_STATUS_ERROR;
BT_ASSERT(!ret);
if (stream->stream) {
- BT_PUT(stream->stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream->stream);
}
if (stream->notif_iter) {
bt_notif_iter_destroy(stream->notif_iter);
}
g_free(stream->buf);
- BT_PUT(stream->packet_end_notif_queue);
+ BT_OBJECT_PUT_REF_AND_RESET(stream->packet_end_notif_queue);
bt_list_del(&stream->node);
/*
* Ensure we poke the trace metadata in the future, which is
print_state(stream),
stream->last_returned_inactivity_timestamp,
stream->current_inactivity_timestamp);
- bt_put(port);
+ bt_object_put_ref(port);
}
BT_HIDDEN
component = bt_component_from_private(lttng_live->private_component);
graph = bt_component_get_graph(component);
ret = bt_graph_is_canceled(graph);
- bt_put(graph);
- bt_put(component);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(component);
return ret;
}
default:
return -1;
}
- bt_put(private_port); /* weak */
+ bt_object_put_ref(private_port); /* weak */
BT_LOGI("Added port %s", name);
if (lttng_live->no_stream_port) {
- bt_get(lttng_live->no_stream_port);
+ bt_object_get_ref(lttng_live->no_stream_port);
ret = bt_private_port_remove_from_component(lttng_live->no_stream_port);
- bt_put(lttng_live->no_stream_port);
+ bt_object_put_ref(lttng_live->no_stream_port);
if (ret) {
return -1;
}
if (nr_ports < 0) {
return -1;
}
- BT_PUT(component);
+ BT_OBJECT_PUT_REF_AND_RESET(component);
if (nr_ports == 1) {
enum bt_component_status status;
default:
return -1;
}
- bt_put(lttng_live->no_stream_port); /* weak */
+ bt_object_put_ref(lttng_live->no_stream_port); /* weak */
lttng_live->no_stream_iter->port = lttng_live->no_stream_port;
}
- bt_get(port);
+ bt_object_get_ref(port);
ret = bt_private_port_remove_from_component(port);
- bt_put(port);
+ bt_object_put_ref(port);
if (ret) {
return -1;
}
retval = bt_trace_set_is_static(trace->trace);
BT_ASSERT(!retval);
- BT_PUT(trace->trace);
+ BT_OBJECT_PUT_REF_AND_RESET(trace->trace);
}
lttng_live_metadata_fini(trace);
- BT_PUT(trace->cc_prio_map);
+ BT_OBJECT_PUT_REF_AND_RESET(trace->cc_prio_map);
g_free(trace);
}
trace = lttng_live_find_trace(session, trace_id);
if (trace) {
- bt_get(trace);
+ bt_object_get_ref(trace);
return trace;
}
return lttng_live_create_trace(session, trace_id);
BT_HIDDEN
void lttng_live_unref_trace(struct lttng_live_trace *trace)
{
- bt_put(trace);
+ bt_object_put_ref(trace);
}
static
}
*notification = notif;
end:
- bt_put(clock_value);
- bt_put(clock_class);
+ bt_object_put_ref(clock_value);
+ bt_object_put_ref(clock_class);
return ret;
error:
ret = BT_LTTNG_LIVE_ITERATOR_STATUS_ERROR;
- bt_put(notif);
+ bt_object_put_ref(notif);
goto end;
}
lttng_live_stream->last_returned_inactivity_timestamp =
lttng_live_stream->current_inactivity_timestamp;
end:
- bt_put(clock_value);
- bt_put(clock_class);
+ bt_object_put_ref(clock_value);
+ bt_object_put_ref(clock_class);
return ret;
}
goto end;
error:
- BT_PUT(query_ret.result);
+ BT_OBJECT_PUT_REF_AND_RESET(query_ret.result);
if (query_ret.status >= 0) {
query_ret.status = BT_QUERY_STATUS_ERROR;
if (viewer_connection) {
bt_live_viewer_connection_destroy(viewer_connection);
}
- BT_PUT(url_value);
+ BT_OBJECT_PUT_REF_AND_RESET(url_value);
return query_ret;
}
bt_list_for_each_entry_safe(session, s, <tng_live->sessions, node) {
lttng_live_destroy_session(session);
}
- BT_PUT(lttng_live->viewer_connection);
+ BT_OBJECT_PUT_REF_AND_RESET(lttng_live->viewer_connection);
if (lttng_live->url) {
g_string_free(lttng_live->url, TRUE);
}
if (lttng_live->no_stream_port) {
- bt_get(lttng_live->no_stream_port);
+ bt_object_get_ref(lttng_live->no_stream_port);
ret = bt_private_port_remove_from_component(lttng_live->no_stream_port);
- bt_put(lttng_live->no_stream_port);
+ bt_object_put_ref(lttng_live->no_stream_port);
BT_ASSERT(!ret);
}
if (lttng_live->no_stream_iter) {
if (!lttng_live->url) {
goto error;
}
- BT_PUT(value);
+ BT_OBJECT_PUT_REF_AND_RESET(value);
lttng_live->viewer_connection =
bt_live_viewer_connection_create(lttng_live->url->str, lttng_live);
if (!lttng_live->viewer_connection) {
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
- bt_put(lttng_live->no_stream_port); /* weak */
+ bt_object_put_ref(lttng_live->no_stream_port); /* weak */
lttng_live->no_stream_iter->port = lttng_live->no_stream_port;
ret = bt_private_component_set_user_data(private_component, lttng_live);
struct bt_port *self_port = bt_port_from_private(self_private_port);
other_component = bt_port_get_component(other_port);
- bt_put(other_component); /* weak */
+ bt_object_put_ref(other_component); /* weak */
if (!lttng_live->downstream_component) {
lttng_live->downstream_component = other_component;
goto end;
}
end:
- bt_put(self_port);
+ bt_object_put_ref(self_port);
return status;
}
size_t i;
int count, ret;
- BT_PUT(trace->cc_prio_map);
+ BT_OBJECT_PUT_REF_AND_RESET(trace->cc_prio_map);
trace->cc_prio_map = bt_clock_class_priority_map_create();
if (!trace->cc_prio_map) {
goto error;
BT_ASSERT(clock_class);
ret = bt_clock_class_priority_map_add_clock_class(
trace->cc_prio_map, clock_class, 0);
- BT_PUT(clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_class);
if (ret) {
goto error;
decoder_status = ctf_metadata_decoder_decode(metadata->decoder, fp);
switch (decoder_status) {
case CTF_METADATA_DECODER_STATUS_OK:
- BT_PUT(trace->trace);
+ BT_OBJECT_PUT_REF_AND_RESET(trace->trace);
trace->trace = ctf_metadata_decoder_get_trace(metadata->decoder);
trace->new_metadata_needed = false;
status = lttng_live_update_clock_map(trace);
if (ret != BT_VALUE_STATUS_OK) {
goto end;
}
- BT_PUT(btval);
+ BT_OBJECT_PUT_REF_AND_RESET(btval);
btval = bt_value_map_get(map, "client-count");
if (!btval) {
if (ret != BT_VALUE_STATUS_OK) {
goto end;
}
- BT_PUT(btval);
+ BT_OBJECT_PUT_REF_AND_RESET(btval);
}
- BT_PUT(hostname);
- BT_PUT(session_name);
- BT_PUT(map);
+ BT_OBJECT_PUT_REF_AND_RESET(hostname);
+ BT_OBJECT_PUT_REF_AND_RESET(session_name);
+ BT_OBJECT_PUT_REF_AND_RESET(map);
if (found) {
break;
}
}
end:
- BT_PUT(btval);
- BT_PUT(hostname);
- BT_PUT(session_name);
- BT_PUT(map);
+ BT_OBJECT_PUT_REF_AND_RESET(btval);
+ BT_OBJECT_PUT_REF_AND_RESET(hostname);
+ BT_OBJECT_PUT_REF_AND_RESET(session_name);
+ BT_OBJECT_PUT_REF_AND_RESET(map);
*_found = found;
return ret;
}
if (url) {
g_string_free(url, TRUE);
}
- BT_PUT(map);
+ BT_OBJECT_PUT_REF_AND_RESET(map);
return ret;
}
}
goto end;
error:
- BT_PUT(results);
+ BT_OBJECT_PUT_REF_AND_RESET(results);
end:
return results;
}
if (!clock) {
return 0;
}
- BT_PUT(clock);
+ BT_OBJECT_PUT_REF_AND_RESET(clock);
ret = bt_field_type_integer_set_size(type, 64);
if (ret) {
BT_LOGE_STR("Failed to find clock fields.");
goto error;
}
- BT_PUT(entry_type);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_type);
}
ret = 0;
error:
ret = -1;
end:
- bt_put(entry_type);
+ bt_object_put_ref(entry_type);
return ret;
}
BT_LOGE_STR("Failed to find clock fields.");
goto error;
}
- BT_PUT(entry_type);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_type);
}
ret = 0;
goto end;
error:
- bt_put(entry_type);
+ bt_object_put_ref(entry_type);
end:
return ret;
}
BT_ASSERT(entry_type);
ret = find_update_clock_fields(err, entry_type, writer_clock_class);
- BT_PUT(entry_type);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_type);
if (ret) {
BT_LOGE_STR("Failed to find clock fields.");
goto error;
BT_ASSERT(entry_type);
ret = find_update_clock_fields(err, entry_type, writer_clock_class);
- BT_PUT(entry_type);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_type);
if (ret) {
BT_LOGE_STR("Failed to find clock fields.");
ret = -1;
BT_ASSERT(entry_type);
ret = find_update_clock_fields(err, entry_type, writer_clock_class);
- BT_PUT(entry_type);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_type);
if (ret) {
BT_LOGE_STR("Failed to find clock fields.");
goto error;
BT_LOGE_STR("Failed to find clock fields in struct.");
goto error;
}
- BT_PUT(writer_clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class);
goto end;
error:
- bt_put(writer_clock_class);
- BT_PUT(new_type);
+ bt_object_put_ref(writer_clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(new_type);
end:
return new_type;
}
break;
}
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
return ret;
}
error:
ret = -1;
end:
- bt_put(copy_container);
- bt_put(container);
+ bt_object_put_ref(copy_container);
+ bt_object_put_ref(container);
return ret;
}
error:
ret = -1;
end:
- bt_put(copy_variant_field);
- bt_put(variant_field);
- bt_put(tag);
+ bt_object_put_ref(copy_variant_field);
+ bt_object_put_ref(variant_field);
+ bt_object_put_ref(tag);
return ret;
}
BT_LOGE_STR("Failed to set sequence length.");
goto error;
}
- BT_PUT(length_field);
+ BT_OBJECT_PUT_REF_AND_RESET(length_field);
for (i = 0; i < count; i++) {
entry_field = bt_field_sequence_get_field(field, i);
BT_LOGE_STR("Faield to override field in sequence.");
goto error;
}
- BT_PUT(entry_field);
- BT_PUT(entry_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_field);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_copy);
}
ret = 0;
goto end;
error:
- bt_put(length_field);
- bt_put(entry_field);
- bt_put(entry_copy);
+ bt_object_put_ref(length_field);
+ bt_object_put_ref(entry_field);
+ bt_object_put_ref(entry_copy);
ret = -1;
end:
return ret;
BT_LOGE_STR("Failed to override field in array.");
goto error;
}
- BT_PUT(entry_field);
- BT_PUT(entry_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_field);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_copy);
}
ret = 0;
goto end;
error:
- bt_put(entry_field);
- bt_put(entry_copy);
+ bt_object_put_ref(entry_field);
+ bt_object_put_ref(entry_copy);
end:
return ret;
BT_LOGE_STR("Failed to override field in struct.");
goto error;
}
- BT_PUT(entry_copy);
- BT_PUT(entry_field);
- BT_PUT(entry_type);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_field);
+ BT_OBJECT_PUT_REF_AND_RESET(entry_type);
}
ret = 0;
goto end;
error:
- bt_put(entry_type);
- bt_put(entry_field);
- bt_put(entry_copy);
+ bt_object_put_ref(entry_type);
+ bt_object_put_ref(entry_field);
+ bt_object_put_ref(entry_copy);
ret = -1;
end:
return ret;
/* FIXME multi-clock? */
clock_class = bt_trace_get_clock_class_by_index(trace, 0);
- bt_put(trace);
+ bt_object_put_ref(trace);
return clock_class;
}
BT_ASSERT(event_class);
stream_class = bt_event_class_get_stream_class(event_class);
- BT_PUT(event_class);
+ BT_OBJECT_PUT_REF_AND_RESET(event_class);
BT_ASSERT(stream_class);
clock_class = stream_class_get_clock_class(err, stream_class);
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
return clock_class;
}
}
clock_value = bt_event_get_clock_value(event, clock_class);
- BT_PUT(clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_class);
BT_ASSERT(clock_value);
ret = bt_clock_value_get_value(clock_value, &value);
- BT_PUT(clock_value);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_value);
if (ret) {
BT_LOGE("Failed to get clock value.");
goto error;
BT_ASSERT(writer_clock_class);
writer_clock_value = bt_clock_value_create(writer_clock_class, value);
- BT_PUT(writer_clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class);
if (!writer_clock_value) {
BT_LOGE_STR("Failed to create clock value.");
goto error;
}
ret = bt_event_set_clock_value(writer_event, writer_clock_value);
- BT_PUT(writer_clock_value);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_clock_value);
if (ret) {
BT_LOGE_STR("Failed to set clock value.");
goto error;
BT_ASSERT(clock_class);
writer_clock_class = ctf_copy_clock_class(err, clock_class);
- bt_put(clock_class);
+ bt_object_put_ref(clock_class);
if (!writer_clock_class) {
BT_LOGE_STR("Failed to copy clock class.");
ret = BT_COMPONENT_STATUS_ERROR;
int_ret = bt_trace_add_clock_class(writer_trace, writer_clock_class);
if (int_ret != 0) {
- BT_PUT(writer_clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class);
BT_LOGE_STR("Failed to add clock class.");
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
/*
* Ownership transferred to the trace.
*/
- bt_put(writer_clock_class);
+ bt_object_put_ref(writer_clock_class);
}
ret = BT_COMPONENT_STATUS_OK;
ret = bt_field_type_integer_set_mapped_clock_class(
field_type, clock_class_copy);
BT_ASSERT(ret == 0);
- bt_put(mapped_clock_class);
- bt_put(clock_class_copy);
+ bt_object_put_ref(mapped_clock_class);
+ bt_object_put_ref(clock_class_copy);
break;
}
case BT_FIELD_TYPE_ID_ENUM:
BT_ASSERT(subtype);
replace_clock_classes(trace_copy, subtype);
- bt_put(subtype);
+ bt_object_put_ref(subtype);
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
field_type, &name, &member_type, i);
BT_ASSERT(ret == 0);
replace_clock_classes(trace_copy, member_type);
- bt_put(member_type);
+ bt_object_put_ref(member_type);
}
break;
field_type, &name, &member_type, i);
BT_ASSERT(ret == 0);
replace_clock_classes(trace_copy, member_type);
- bt_put(member_type);
+ bt_object_put_ref(member_type);
}
break;
replace_clock_classes(trace_copy, ft_copy);
ret = bt_event_class_set_payload_type(writer_event_class,
ft_copy);
- bt_put(ft_copy);
+ bt_object_put_ref(ft_copy);
if (ret < 0) {
BT_LOGE_STR("Failed to set payload type.");
goto error;
ret = bt_event_class_set_context_type(
writer_event_class, ft_copy);
- bt_put(ft_copy);
+ bt_object_put_ref(ft_copy);
if (ret < 0) {
BT_LOGE_STR("Failed to set context type.");
goto error;
goto end;
error:
- BT_PUT(writer_event_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event_class);
end:
- BT_PUT(context);
- BT_PUT(payload_type);
+ BT_OBJECT_PUT_REF_AND_RESET(context);
+ BT_OBJECT_PUT_REF_AND_RESET(payload_type);
return writer_event_class;
}
* event_classes after a trace has become
* static.
*/
- BT_PUT(writer_event_class);
- BT_PUT(event_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event_class);
+ BT_OBJECT_PUT_REF_AND_RESET(event_class);
continue;
}
}
ret = BT_COMPONENT_STATUS_ERROR;
goto error;
}
- BT_PUT(writer_event_class);
- BT_PUT(event_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event_class);
+ BT_OBJECT_PUT_REF_AND_RESET(event_class);
}
goto end;
error:
- bt_put(event_class);
- bt_put(writer_event_class);
+ bt_object_put_ref(event_class);
+ bt_object_put_ref(writer_event_class);
end:
- bt_put(writer_trace);
+ bt_object_put_ref(writer_trace);
return ret;
}
replace_clock_classes(writer_trace, type_copy);
ret_int = bt_stream_class_set_packet_context_type(
writer_stream_class, type_copy);
- BT_PUT(type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(type_copy);
if (ret_int < 0) {
BT_LOGE_STR("Failed to set packet_context type.");
goto error;
}
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
}
type = bt_stream_class_get_event_header_type(stream_class);
replace_clock_classes(writer_trace, type_copy);
ret_int = bt_stream_class_set_event_header_type(
writer_stream_class, new_event_header_type);
- BT_PUT(type_copy);
- BT_PUT(new_event_header_type);
+ BT_OBJECT_PUT_REF_AND_RESET(type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(new_event_header_type);
if (ret_int < 0) {
BT_LOGE_STR("Failed to set event_header type.");
goto error;
replace_clock_classes(writer_trace, type_copy);
ret_int = bt_stream_class_set_event_header_type(
writer_stream_class, type_copy);
- BT_PUT(type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(type_copy);
if (ret_int < 0) {
BT_LOGE_STR("Failed to set event_header type.");
goto error;
}
}
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
}
type = bt_stream_class_get_event_context_type(stream_class);
replace_clock_classes(writer_trace, type_copy);
ret_int = bt_stream_class_set_event_context_type(
writer_stream_class, type_copy);
- BT_PUT(type_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(type_copy);
if (ret_int < 0) {
BT_LOGE_STR("Failed to set event_contexttype.");
goto error;
}
}
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
goto end;
error:
- BT_PUT(writer_stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class);
end:
- bt_put(type);
- bt_put(type_copy);
+ bt_object_put_ref(type);
+ bt_object_put_ref(type_copy);
return writer_stream_class;
}
error:
ret = -1;
end:
- bt_put(writer_packet_header);
- bt_put(packet_header);
+ bt_object_put_ref(writer_packet_header);
+ bt_object_put_ref(packet_header);
return ret;
}
error:
ret = -1;
end:
- bt_put(packet_header);
- bt_put(writer_packet_header);
+ bt_object_put_ref(packet_header);
+ bt_object_put_ref(writer_packet_header);
return ret;
}
error:
ret = -1;
end:
- bt_put(packet_context);
- bt_put(writer_packet_context);
+ bt_object_put_ref(packet_context);
+ bt_object_put_ref(writer_packet_context);
return ret;
}
error:
ret = -1;
end:
- bt_put(writer_packet_context);
- bt_put(packet_context);
+ bt_object_put_ref(writer_packet_context);
+ bt_object_put_ref(packet_context);
return ret;
}
}
clock_value = bt_event_get_clock_value(event, clock_class);
- BT_PUT(clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_class);
BT_ASSERT(clock_value);
ret = bt_clock_value_get_value(clock_value, &value);
- BT_PUT(clock_value);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_value);
if (ret) {
BT_LOGE_STR("Failed to get clock value.");
goto error;
}
writer_clock_value = bt_clock_value_create(writer_clock_class, value);
- BT_PUT(writer_clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_clock_class);
if (!writer_clock_value) {
BT_LOGE_STR("Failed to create clock value.");
goto error;
}
ret = bt_event_set_clock_value(writer_event, writer_clock_value);
- BT_PUT(writer_clock_value);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_clock_value);
if (ret) {
BT_LOGE_STR("Failed to set clock value.");
goto error;
}
ret = bt_event_set_header(writer_event, writer_event_header);
- BT_PUT(writer_event_header);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event_header);
if (ret < 0) {
BT_LOGE_STR("Failed to set event_header.");
goto error;
trace = bt_stream_class_get_trace(stream_class);
BT_ASSERT(trace);
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
return trace;
}
BT_LOGE_STR("Failed to copy and override field.");
goto error;
}
- BT_PUT(copy_field);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_field);
} else {
ret = ctf_copy_event_header(err, event, writer_event_class,
writer_event, field);
goto error;
}
}
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
}
/* Optional field, so it can fail silently. */
BT_LOGE_STR("Failed to set stream_event_context.");
goto error;
}
- BT_PUT(field);
- BT_PUT(copy_field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_field);
}
/* Optional field, so it can fail silently. */
BT_LOGE_STR("Failed to set event_context.");
goto error;
}
- BT_PUT(field);
- BT_PUT(copy_field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_field);
}
field = bt_event_get_event_payload(event);
BT_LOGE_STR("Failed to set event_payload.");
goto error;
}
- BT_PUT(field);
- BT_PUT(copy_field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_field);
}
goto end;
error:
- BT_PUT(writer_event);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event);
end:
- bt_put(field);
- bt_put(copy_field);
- bt_put(writer_trace);
+ bt_object_put_ref(field);
+ bt_object_put_ref(copy_field);
+ bt_object_put_ref(writer_trace);
return writer_event;
}
ret_int = bt_trace_set_environment_field(writer_trace,
name, value);
- BT_PUT(value);
+ BT_OBJECT_PUT_REF_AND_RESET(value);
if (ret_int < 0) {
BT_LOGE("Failed to set environment: field-name=\"%s\"",
name);
header_type = bt_trace_get_packet_header_type(trace);
if (header_type) {
int_ret = bt_trace_set_packet_header_type(writer_trace, header_type);
- BT_PUT(header_type);
+ BT_OBJECT_PUT_REF_AND_RESET(header_type);
if (int_ret < 0) {
BT_LOGE_STR("Failed to set packet header type.");
ret = BT_COMPONENT_STATUS_ERROR;
static
void unref_stream(struct bt_stream *stream)
{
- bt_put(stream);
+ bt_object_put_ref(stream);
}
static
void unref_packet(struct bt_packet *packet)
{
- bt_put(packet);
+ bt_object_put_ref(packet);
}
static
void unref_stream_class(struct bt_stream_class *stream_class)
{
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
}
static
field = bt_field_structure_get_field_by_name(payload, field_name);
end:
- bt_put(payload_class);
- bt_put(payload);
+ bt_object_put_ref(payload_class);
+ bt_object_put_ref(payload);
return field;
}
field = bt_field_structure_get_field_by_name(sec, field_name);
end:
- bt_put(sec_class);
- bt_put(sec);
+ bt_object_put_ref(sec_class);
+ bt_object_put_ref(sec);
return field;
}
error:
ret = -1;
end:
- bt_put(field_class);
- bt_put(field);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
return ret;
}
error:
ret = -1;
end:
- bt_put(field_class);
- bt_put(field);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
return ret;
}
error:
ret = -1;
end:
- bt_put(field_class);
- bt_put(field);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
return ret;
}
error:
ret = -1;
end:
- bt_put(field_class);
- bt_put(field);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
return ret;
}
error:
ret = -1;
end:
- bt_put(field_class);
- bt_put(field);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
return ret;
}
BT_LOGE("Wrong type, expected sequence: field-name=\"%s\"", field_name);
goto error;
}
- BT_PUT(field_class);
+ BT_OBJECT_PUT_REF_AND_RESET(field_class);
seq_len = bt_field_sequence_get_length(field);
BT_ASSERT(seq_len);
field_name);
goto error;
}
- BT_PUT(seq_len);
+ BT_OBJECT_PUT_REF_AND_RESET(seq_len);
*build_id = g_new0(uint8_t, *build_id_len);
if (!*build_id) {
goto error;
}
- BT_PUT(seq_field);
+ BT_OBJECT_PUT_REF_AND_RESET(seq_field);
(*build_id)[i] = (uint8_t) tmp;
}
ret = 0;
g_free(*build_id);
ret = -1;
end:
- bt_put(field_class);
- bt_put(field);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
return ret;
}
if (strcmp(str_value, "ust") != 0) {
goto end;
}
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
/* No tracer_name, no debug info */
field = bt_trace_get_environment_field_value_by_name(writer_trace,
if (strcmp(str_value, "lttng-ust") != 0) {
goto end;
}
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
debug_info = debug_info_create(debug_it->debug_info_component);
if (!debug_info) {
debug_info);
end:
- bt_put(field);
+ bt_object_put_ref(field);
return debug_info;
}
error:
int_ret = -1;
end:
- bt_put(stream_class);
- bt_put(writer_stream_class);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(writer_stream_class);
return int_ret;
}
BT_LOGE_STR("Failed to synchronize the event classes.");
goto error;
}
- BT_PUT(stream);
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
}
bt_trace_set_is_static(di_trace->writer_trace);
}
error:
- bt_put(writer_stream);
- bt_put(stream);
+ bt_object_put_ref(writer_stream);
+ bt_object_put_ref(stream);
}
static
BT_LOGE_STR("Failed to insert new stream.");
goto error;
}
- bt_get(writer_stream);
+ bt_object_get_ref(writer_stream);
ret = sync_event_classes(debug_it, stream, writer_stream);
if (ret) {
BT_LOGE_STR("Failed to synchronize event classes.");
goto error;
}
- BT_PUT(writer_stream);
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
}
/* Check if the trace is already static or register a listener. */
goto end;
error:
- BT_PUT(writer_trace);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_trace);
g_free(di_trace);
di_trace = NULL;
end:
- bt_put(stream);
- bt_put(writer_stream);
- bt_put(stream_class);
- bt_put(trace);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(writer_stream);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(trace);
return di_trace;
}
goto end;
error:
- BT_PUT(writer_packet);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_packet);
end:
return writer_packet;
}
if (!ip_field) {
goto end;
}
- BT_PUT(ip_field);
+ BT_OBJECT_PUT_REF_AND_RESET(ip_field);
debug_field_class = bt_field_class_structure_get_field_class_by_name(
writer_event_context_class,
goto end;
error:
- BT_PUT(debug_field_class);
+ BT_OBJECT_PUT_REF_AND_RESET(debug_field_class);
ret = -1;
end:
- bt_put(src_field_class);
- bt_put(func_field_class);
- bt_put(bin_field_class);
- bt_put(debug_field_class);
+ bt_object_put_ref(src_field_class);
+ bt_object_put_ref(func_field_class);
+ bt_object_put_ref(bin_field_class);
+ bt_object_put_ref(debug_field_class);
return ret;
}
ret = bt_field_class_structure_add_field(writer_event_context_class,
field_class, field_name);
- BT_PUT(field_class);
+ BT_OBJECT_PUT_REF_AND_RESET(field_class);
if (ret) {
BT_LOGE("Failed to add a field to the event-context: field-name=\"%s\"",
field_name);
BT_LOGE_STR("Failed to set packet_context type.");
goto error;
}
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
}
type = bt_stream_class_get_event_header_type(stream_class);
BT_LOGE_STR("Failed to set event_header type.");
goto error;
}
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
}
type = bt_stream_class_get_event_context_class(stream_class);
BT_LOGE_STR("Failed to create debug_info event_context type.");
goto error;
}
- BT_PUT(type);
+ BT_OBJECT_PUT_REF_AND_RESET(type);
ret_int = bt_stream_class_set_event_context_class(
writer_stream_class, writer_event_context_class);
BT_LOGE_STR("Failed to set event_context type.");
goto error;
}
- BT_PUT(writer_event_context_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event_context_class);
}
goto end;
error:
- BT_PUT(writer_stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class);
end:
- bt_put(writer_event_context_class);
- bt_put(type);
+ bt_object_put_ref(writer_event_context_class);
+ bt_object_put_ref(type);
return writer_stream_class;
}
existing_clock_class = bt_trace_get_clock_class_by_name(
writer_trace, bt_clock_class_get_name(clock_class));
- bt_put(existing_clock_class);
+ bt_object_put_ref(existing_clock_class);
if (existing_clock_class) {
- bt_put(clock_class);
+ bt_object_put_ref(clock_class);
continue;
}
ret = bt_trace_add_clock_class(writer_trace, clock_class);
- BT_PUT(clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(clock_class);
if (ret != 0) {
BT_LOGE_STR("Failed to add clock_class.");
goto error;
goto error;
}
writer_trace = di_trace->writer_trace;
- bt_get(writer_trace);
+ bt_object_get_ref(writer_trace);
writer_stream_class = copy_stream_class_debug_info(debug_it->err, stream_class,
writer_trace, debug_it->debug_info_component);
goto end;
error:
- BT_PUT(writer_stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream_class);
end:
- bt_put(trace);
- bt_put(writer_trace);
+ bt_object_put_ref(trace);
+ bt_object_put_ref(writer_trace);
return writer_stream_class;
}
goto error;
}
}
- bt_get(writer_stream_class);
+ bt_object_get_ref(writer_stream_class);
id = bt_stream_get_id(stream);
if (id < 0) {
goto end;
error:
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
end:
- bt_put(stream_class);
- bt_put(writer_stream_class);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(writer_stream_class);
return writer_stream;
}
di_trace = (struct debug_info_trace *) g_hash_table_lookup(
debug_it->trace_map, (gpointer) trace);
- BT_PUT(stream_class);
- BT_PUT(trace);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class);
+ BT_OBJECT_PUT_REF_AND_RESET(trace);
return di_trace;
}
BT_LOGE_STR("Failed to find existing stream.");
goto error;
}
- bt_get(writer_stream);
+ bt_object_get_ref(writer_stream);
goto end;
error:
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
end:
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
return writer_stream;
}
writer_packet = lookup_packet(debug_it, packet, di_trace);
if (writer_packet) {
g_hash_table_remove(di_trace->packet_map, packet);
- BT_PUT(writer_packet);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_packet);
}
writer_packet = insert_new_packet(debug_it, packet, writer_stream,
BT_LOGE_STR("Failed to copy packet context.");
goto error;
}
- BT_PUT(packet_context);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_context);
}
- bt_get(writer_packet);
+ bt_object_get_ref(writer_packet);
goto end;
error:
end:
- bt_put(packet_context);
- bt_put(writer_stream);
- bt_put(stream);
+ bt_object_put_ref(packet_context);
+ bt_object_put_ref(writer_stream);
+ bt_object_put_ref(stream);
return writer_packet;
}
BT_LOGE_STR("Failed to find existing packet.");
goto end;
}
- bt_get(writer_packet);
+ bt_object_get_ref(writer_packet);
g_hash_table_remove(di_trace->packet_map, packet);
end:
- bt_put(stream);
+ bt_object_put_ref(stream);
return writer_packet;
}
if (!writer_stream) {
writer_stream = insert_new_stream(debug_it, stream, di_trace);
}
- bt_get(writer_stream);
+ bt_object_get_ref(writer_stream);
goto end;
error:
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
end:
return writer_stream;
}
* Take the ref on the stream and keep it until the notification
* is created.
*/
- bt_get(writer_stream);
+ bt_object_get_ref(writer_stream);
state = g_hash_table_lookup(di_trace->stream_states, stream);
if (*state != DEBUG_INFO_ACTIVE_STREAM) {
goto end;
error:
- BT_PUT(writer_stream);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_stream);
end:
return writer_stream;
field_name);
goto error;
}
- BT_PUT(field_class);
+ BT_OBJECT_PUT_REF_AND_RESET(field_class);
field = bt_field_structure_get_field_by_index(debug_field, i);
if (!strcmp(field_name, "bin")) {
ret = bt_field_string_set_value(field, "");
}
}
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
if (ret) {
BT_LOGE("Failed to set value in debug-info struct: field-name=\"%s\"",
field_name);
error:
ret = -1;
end:
- bt_put(field_class);
- bt_put(field);
- bt_put(debug_field_class);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
+ bt_object_put_ref(debug_field_class);
return ret;
}
BT_LOGE_STR("Failed to set debug_info field.");
goto error;
}
- BT_PUT(debug_field);
+ BT_OBJECT_PUT_REF_AND_RESET(debug_field);
} else {
copy_field = bt_field_copy(field);
if (!copy_field) {
field_name);
goto error;
}
- BT_PUT(copy_field);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_field);
}
- BT_PUT(field_class);
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field_class);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
}
ret = 0;
error:
ret = -1;
end:
- bt_put(event_context_class);
- bt_put(writer_event_context_class);
- bt_put(writer_event_context);
- bt_put(field);
- bt_put(copy_field);
- bt_put(debug_field);
- bt_put(field_class);
+ bt_object_put_ref(event_context_class);
+ bt_object_put_ref(writer_event_context_class);
+ bt_object_put_ref(writer_event_context);
+ bt_object_put_ref(field);
+ bt_object_put_ref(copy_field);
+ bt_object_put_ref(debug_field);
+ bt_object_put_ref(field_class);
return ret;
}
/* FIXME multi-clock? */
clock_class = bt_trace_get_clock_class_by_index(trace, 0);
- bt_put(trace);
+ bt_object_put_ref(trace);
end:
return clock_class;
goto end;
end:
- bt_put(stream_class);
- bt_put(event_class);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(event_class);
return clock_class;
}
error:
ret = -1;
end:
- bt_put(clock_class);
- bt_put(clock_value);
+ bt_object_put_ref(clock_class);
+ bt_object_put_ref(clock_value);
return ret;
}
BT_LOGE_STR("Failed to copy event header.");
goto error;
}
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
}
/* Optional field, so it can fail silently. */
BT_LOGE_STR("Failed to debug_info stream event context.");
goto error;
}
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
}
/* Optional field, so it can fail silently. */
BT_LOGE_STR("Failed to set event_context.");
goto error;
}
- BT_PUT(copy_field);
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
}
field = bt_event_get_event_payload(event);
BT_LOGE_STR("Failed to set event payload.");
goto error;
}
- BT_PUT(copy_field);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_field);
}
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
goto end;
error:
- BT_PUT(writer_event);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event);
end:
- bt_put(copy_field);
- bt_put(field);
+ bt_object_put_ref(copy_field);
+ bt_object_put_ref(field);
return writer_event;
}
BT_LOGE_STR("Failed to find existing stream_class.");
goto error;
}
- bt_get(writer_stream_class);
+ bt_object_get_ref(writer_stream_class);
writer_trace = bt_stream_class_get_trace(writer_stream_class);
BT_ASSERT(writer_trace);
writer_event_class = get_event_class(debug_it,
BT_LOGE_STR("Failed to find existing packet.");
goto error;
}
- bt_get(writer_packet);
+ bt_object_get_ref(writer_packet);
int_ret = bt_event_set_packet(writer_event, writer_packet);
if (int_ret < 0) {
goto end;
error:
- BT_PUT(writer_event);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event);
end:
- bt_put(stream);
- bt_put(writer_trace);
- bt_put(writer_packet);
- bt_put(packet);
- bt_put(writer_event_class);
- bt_put(writer_stream_class);
- bt_put(stream_class);
- bt_put(event_class);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(writer_trace);
+ bt_object_put_ref(writer_packet);
+ bt_object_put_ref(packet);
+ bt_object_put_ref(writer_event_class);
+ bt_object_put_ref(writer_stream_class);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(event_class);
return writer_event;
}
}
end_put_class:
- bt_put(event_class);
+ bt_object_put_ref(event_class);
end:
return;
}
static
void unref_trace(struct debug_info_trace *di_trace)
{
- bt_put(di_trace->writer_trace);
+ bt_object_put_ref(di_trace->writer_trace);
g_free(di_trace);
}
empty_trace_map, it_data);
g_hash_table_destroy(it_data->trace_map);
- bt_put(it_data->current_notification);
- bt_put(it_data->input_iterator);
+ bt_object_put_ref(it_data->current_notification);
+ bt_object_put_ref(it_data->input_iterator);
g_free(it_data);
}
new_notification = bt_notification_packet_begin_create(
writer_packet);
BT_ASSERT(new_notification);
- bt_put(packet);
- bt_put(writer_packet);
+ bt_object_put_ref(packet);
+ bt_object_put_ref(writer_packet);
break;
}
case BT_NOTIFICATION_TYPE_PACKET_END:
new_notification = bt_notification_packet_end_create(
writer_packet);
BT_ASSERT(new_notification);
- bt_put(packet);
- bt_put(writer_packet);
+ bt_object_put_ref(packet);
+ bt_object_put_ref(writer_packet);
break;
}
case BT_NOTIFICATION_TYPE_EVENT:
BT_ASSERT(writer_event);
new_notification = bt_notification_event_create(writer_event,
cc_prio_map);
- bt_put(cc_prio_map);
+ bt_object_put_ref(cc_prio_map);
BT_ASSERT(new_notification);
- bt_put(event);
- bt_put(writer_event);
+ bt_object_put_ref(event);
+ bt_object_put_ref(writer_event);
break;
}
case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
new_notification = bt_notification_stream_begin_create(
writer_stream);
BT_ASSERT(new_notification);
- bt_put(stream);
- bt_put(writer_stream);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(writer_stream);
break;
}
case BT_NOTIFICATION_TYPE_STREAM_END:
new_notification = bt_notification_stream_end_create(
writer_stream);
BT_ASSERT(new_notification);
- bt_put(stream);
- bt_put(writer_stream);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(writer_stream);
break;
}
default:
- new_notification = bt_get(notification);
+ new_notification = bt_object_get_ref(notification);
break;
}
ret.notification = handle_notification(debug_info->err, debug_it,
notification);
BT_ASSERT(ret.notification);
- bt_put(notification);
+ bt_object_put_ref(notification);
end:
- bt_put(component);
+ bt_object_put_ref(component);
return ret;
}
}
connection = bt_private_port_get_private_connection(input_port);
- bt_put(input_port);
+ bt_object_put_ref(input_port);
if (!connection) {
ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
goto end;
}
end:
- bt_put(connection);
- bt_put(component);
+ bt_object_put_ref(connection);
+ bt_object_put_ref(component);
return ret;
}
"Expecting a string.");
}
strcpy(debug_info_component->arg_debug_info_field_name, tmp);
- bt_put(value);
+ bt_object_put_ref(value);
} else {
debug_info_component->arg_debug_info_field_name =
malloc(strlen("debug_info") + 1);
"Expecting a string.");
}
}
- bt_put(value);
+ bt_object_put_ref(value);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
"Expecting a string.");
}
}
- bt_put(value);
+ bt_object_put_ref(value);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
debug_info_component->arg_full_path = bool_val;
}
- bt_put(value);
+ bt_object_put_ref(value);
if (ret != BT_COMPONENT_STATUS_OK) {
goto end;
}
goto end;
error:
- BT_PUT(root_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(root_fc);
end:
- bt_put(fc);
+ bt_object_put_ref(fc);
return root_fc;
}
ret = -1;
end:
- bt_put(fc);
+ bt_object_put_ref(fc);
if (basename) {
g_free(basename);
g_string_free(dmesg_comp->params.path, TRUE);
}
- bt_put(dmesg_comp->packet);
- bt_put(dmesg_comp->trace);
- bt_put(dmesg_comp->stream_class);
- bt_put(dmesg_comp->event_class);
- bt_put(dmesg_comp->stream);
- bt_put(dmesg_comp->clock_class);
- bt_put(dmesg_comp->cc_prio_map);
+ bt_object_put_ref(dmesg_comp->packet);
+ bt_object_put_ref(dmesg_comp->trace);
+ bt_object_put_ref(dmesg_comp->stream_class);
+ bt_object_put_ref(dmesg_comp->event_class);
+ bt_object_put_ref(dmesg_comp->stream);
+ bt_object_put_ref(dmesg_comp->clock_class);
+ bt_object_put_ref(dmesg_comp->cc_prio_map);
g_free(dmesg_comp);
}
goto end;
error:
- BT_PUT(notif);
+ BT_OBJECT_PUT_REF_AND_RESET(notif);
end:
return notif;
goto end;
error:
- BT_PUT(notif);
+ BT_OBJECT_PUT_REF_AND_RESET(notif);
end:
return notif;
}
}
- bt_put(dmesg_notif_iter->tmp_event_notif);
+ bt_object_put_ref(dmesg_notif_iter->tmp_event_notif);
free(dmesg_notif_iter->linebuf);
g_free(dmesg_notif_iter);
}
}
end:
- bt_put(priv_comp);
+ bt_object_put_ref(priv_comp);
return status;
}
static
void destroy_pretty_data(struct pretty_component *pretty)
{
- bt_put(pretty->input_iterator);
+ bt_object_put_ref(pretty->input_iterator);
if (pretty->string) {
(void) g_string_free(pretty->string, TRUE);
status = BT_COMPONENT_STATUS_ERROR;
}
- bt_put(connection);
+ bt_object_put_ref(connection);
return status;
}
switch (it_ret) {
case BT_NOTIFICATION_ITERATOR_STATUS_END:
ret = BT_COMPONENT_STATUS_END;
- BT_PUT(pretty->input_iterator);
+ BT_OBJECT_PUT_REF_AND_RESET(pretty->input_iterator);
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
ret = BT_COMPONENT_STATUS_AGAIN;
goto end;
}
- bt_put(notifs[i]);
+ bt_object_put_ref(notifs[i]);
}
end:
for (; i < count; i++) {
- bt_put(notifs[i]);
+ bt_object_put_ref(notifs[i]);
}
return ret;
}
end:
- bt_put(pretty->plugin_opt_map);
+ bt_object_put_ref(pretty->plugin_opt_map);
pretty->plugin_opt_map = NULL;
g_free(str);
return ret;
void destroy_private_counter_data(struct counter *counter)
{
- bt_put(counter->notif_iter);
+ bt_object_put_ref(counter->notif_iter);
g_free(counter);
}
counter = bt_private_component_get_user_data(component);
BT_ASSERT(counter);
try_print_last(counter);
- bt_put(counter->notif_iter);
+ bt_object_put_ref(counter->notif_iter);
g_free(counter);
}
goto end;
}
- BT_MOVE(counter->notif_iter, iterator);
+ BT_OBJECT_MOVE_REF(counter->notif_iter, iterator);
end:
- bt_put(connection);
+ bt_object_put_ref(connection);
return status;
}
counter->count.other++;
}
- bt_put(notif);
+ bt_object_put_ref(notif);
}
}
default:
void destroy_private_dummy_data(struct dummy *dummy)
{
- bt_put(dummy->notif_iter);
+ bt_object_put_ref(dummy->notif_iter);
g_free(dummy);
}
goto end;
}
- BT_MOVE(dummy->notif_iter, iterator);
+ BT_OBJECT_MOVE_REF(dummy->notif_iter, iterator);
end:
- bt_put(connection);
+ bt_object_put_ref(connection);
return status;
}
ret = BT_COMPONENT_STATUS_OK;
for (i = 0; i < count; i++) {
- bt_put(notifs[i]);
+ bt_object_put_ref(notifs[i]);
}
break;
muxer_upstream_notif_iter,
muxer_upstream_notif_iter->notif_iter,
muxer_upstream_notif_iter->notifs->length);
- bt_put(muxer_upstream_notif_iter->notif_iter);
+ bt_object_put_ref(muxer_upstream_notif_iter->notif_iter);
if (muxer_upstream_notif_iter->notifs) {
struct bt_notification *notif;
while ((notif = g_queue_pop_head(
muxer_upstream_notif_iter->notifs))) {
- bt_put(notif);
+ bt_object_put_ref(notif);
}
g_queue_free(muxer_upstream_notif_iter->notifs);
goto end;
}
- muxer_upstream_notif_iter->notif_iter = bt_get(notif_iter);
+ muxer_upstream_notif_iter->notif_iter = bt_object_get_ref(notif_iter);
muxer_upstream_notif_iter->notifs = g_queue_new();
if (!muxer_upstream_notif_iter->notifs) {
BT_LOGE_STR("Failed to allocate a GQueue.");
goto end;
error:
- BT_PUT(params);
+ BT_OBJECT_PUT_REF_AND_RESET(params);
end:
return params;
ret = -1;
end:
- bt_put(default_params);
- bt_put(real_params);
+ bt_object_put_ref(default_params);
+ bt_object_put_ref(real_params);
return ret;
}
port, bt_port_get_name(port), priv_conn, notif_iter);
end:
- bt_put(priv_conn);
+ bt_object_put_ref(priv_conn);
return notif_iter;
}
* won't be considered again to find the youngest
* notification.
*/
- BT_PUT(muxer_upstream_notif_iter->notif_iter);
+ BT_OBJECT_PUT_REF_AND_RESET(muxer_upstream_notif_iter->notif_iter);
status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
break;
default:
muxer_notif_iter_add_upstream_notif_iter(
muxer_notif_iter, upstream_notif_iter,
priv_port);
- BT_PUT(upstream_notif_iter);
+ BT_OBJECT_PUT_REF_AND_RESET(upstream_notif_iter);
if (!muxer_upstream_notif_iter) {
/*
* muxer_notif_iter_add_upstream_notif_iter()
}
remove_node:
- bt_put(upstream_notif_iter);
+ bt_object_put_ref(upstream_notif_iter);
muxer_notif_iter->newly_connected_priv_ports =
g_list_delete_link(
muxer_notif_iter->newly_connected_priv_ports,
BT_LOGD("Skipping input port: not connected: "
"muxer-comp-addr=%p, port-addr=%p, port-name\"%s\"",
muxer_comp, port, bt_port_get_name(port));
- bt_put(priv_port);
+ bt_object_put_ref(priv_port);
continue;
}
- bt_put(priv_port);
+ bt_object_put_ref(priv_port);
muxer_notif_iter->newly_connected_priv_ports =
g_list_append(
muxer_notif_iter->newly_connected_priv_ports,
end:
muxer_comp->initializing_muxer_notif_iter = false;
- bt_put(priv_comp);
+ bt_object_put_ref(priv_comp);
return status;
}
destroy_muxer_notif_iter(muxer_notif_iter);
}
- bt_put(priv_comp);
+ bt_object_put_ref(priv_comp);
}
BT_HIDDEN
bt_notification_iterator_status_string(status));
}
- bt_put(priv_comp);
+ bt_object_put_ref(priv_comp);
return status;
}
goto end;
error:
- BT_PUT(writer_packet);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_packet);
end:
return writer_packet;
}
goto error;
}
if (strcmp(field_name, name)) {
- BT_PUT(field_class);
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field_class);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
continue;
}
if (bt_field_class_id(field_class) !=
int_ret = bt_field_unsigned_integer_set_value(writer_field, value);
BT_ASSERT(int_ret == 0);
- BT_PUT(writer_field);
- BT_PUT(field_class);
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_field);
+ BT_OBJECT_PUT_REF_AND_RESET(field_class);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
}
ret = BT_COMPONENT_STATUS_OK;
goto end;
error:
- bt_put(writer_field);
- bt_put(field_class);
- bt_put(field);
+ bt_object_put_ref(writer_field);
+ bt_object_put_ref(field_class);
+ bt_object_put_ref(field);
ret = BT_COMPONENT_STATUS_ERROR;
end:
- bt_put(struct_class);
- bt_put(packet_context);
+ bt_object_put_ref(struct_class);
+ bt_object_put_ref(packet_context);
return ret;
}
writer_packet = lookup_packet(trim_it, packet);
if (writer_packet) {
g_hash_table_remove(trim_it->packet_map, packet);
- BT_PUT(writer_packet);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_packet);
}
writer_packet = insert_new_packet(trim_it, packet, stream);
BT_LOGE_STR("Failed to insert new packet.");
goto error;
}
- bt_get(writer_packet);
+ bt_object_get_ref(writer_packet);
int_ret = ctf_packet_copy_context(trim_it->err, packet,
stream, writer_packet);
goto end;
error:
- BT_PUT(writer_packet);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_packet);
end:
- bt_put(stream);
+ bt_object_put_ref(stream);
return writer_packet;
}
BT_LOGE_STR("Failed to find existing packet.");
goto error;
}
- bt_get(writer_packet);
+ bt_object_get_ref(writer_packet);
int_ret = bt_event_set_packet(writer_event, writer_packet);
if (int_ret < 0) {
goto end;
error:
- BT_PUT(writer_event);
+ BT_OBJECT_PUT_REF_AND_RESET(writer_event);
end:
- bt_put(writer_packet);
- bt_put(packet);
- bt_put(event_class);
+ bt_object_put_ref(writer_packet);
+ bt_object_put_ref(packet);
+ bt_object_put_ref(event_class);
return writer_event;
}
{
struct bt_packet *writer_packet = value;
- bt_put(writer_packet);
+ bt_object_put_ref(writer_packet);
return TRUE;
}
trim_it = bt_private_connection_private_notification_iterator_get_user_data(it);
BT_ASSERT(trim_it);
- bt_put(trim_it->input_iterator);
+ bt_object_put_ref(trim_it->input_iterator);
g_hash_table_foreach_remove(trim_it->packet_map,
close_packets, NULL);
g_hash_table_destroy(trim_it->packet_map);
goto end;
}
end:
- bt_put(component);
- bt_put(connection);
- bt_put(input_port);
+ bt_object_put_ref(component);
+ bt_object_put_ref(connection);
+ bt_object_put_ref(input_port);
return ret;
}
BT_ASSERT(writer_event);
new_notification = bt_notification_event_create(writer_event, cc_prio_map);
BT_ASSERT(new_notification);
- bt_put(cc_prio_map);
+ bt_object_put_ref(cc_prio_map);
stream = bt_event_get_stream(event);
BT_ASSERT(stream);
goto end;
error:
- BT_PUT(new_notification);
+ BT_OBJECT_PUT_REF_AND_RESET(new_notification);
end:
- bt_put(event);
- bt_put(writer_event);
- bt_put(clock_class);
- bt_put(trace);
- bt_put(stream);
- bt_put(stream_class);
- bt_put(clock_value);
+ bt_object_put_ref(event);
+ bt_object_put_ref(writer_event);
+ bt_object_put_ref(clock_class);
+ bt_object_put_ref(trace);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(clock_value);
*_event_in_range = in_range;
return new_notification;
}
ret = bt_clock_value_get_value_ns_from_epoch(clock_value, ns);
end:
- bt_put(integer_class);
- bt_put(clock_class);
- bt_put(clock_value);
+ bt_object_put_ref(integer_class);
+ bt_object_put_ref(clock_class);
+ bt_object_put_ref(clock_value);
return ret;
}
ns += ns_from_value(freq, cycles_offset);
- bt_put(writer_clock_class);
- bt_put(writer_trace);
- bt_put(writer_stream_class);
- bt_put(writer_stream);
+ bt_object_put_ref(writer_clock_class);
+ bt_object_put_ref(writer_trace);
+ bt_object_put_ref(writer_stream_class);
+ bt_object_put_ref(writer_stream);
return timestamp - ns;
}
}
end_no_notif:
*_packet_in_range = in_range;
- bt_put(packet);
- bt_put(writer_packet);
- bt_put(packet_context);
- bt_put(timestamp_begin);
- bt_put(timestamp_end);
+ bt_object_put_ref(packet);
+ bt_object_put_ref(writer_packet);
+ bt_object_put_ref(packet_context);
+ bt_object_put_ref(timestamp_begin);
+ bt_object_put_ref(timestamp_end);
return new_notification;
}
default:
break;
}
- BT_PUT(*notification);
+ BT_OBJECT_PUT_REF_AND_RESET(*notification);
*notification = new_notification;
if (finished) {
&trimmer->begin, &trimmer->end,
¬ification_in_range);
if (!notification_in_range) {
- BT_PUT(ret.notification);
+ BT_OBJECT_PUT_REF_AND_RESET(ret.notification);
}
if (ret.status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
}
}
end:
- bt_put(component);
+ bt_object_put_ref(component);
return ret;
}
goto end;
}
- BT_PUT(value);
+ BT_OBJECT_PUT_REF_AND_RESET(value);
value = bt_value_map_get(params, "begin");
if (value) {
if (timestamp_from_param("begin", value,
}
}
- BT_PUT(value);
+ BT_OBJECT_PUT_REF_AND_RESET(value);
value = bt_value_map_get(params, "end");
if (value) {
if (timestamp_from_param("end", value,
}
end:
- bt_put(value);
+ bt_object_put_ref(value);
if (trimmer->begin.set && trimmer->end.set) {
if (trimmer->begin.value > trimmer->end.value) {
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/plugin/plugin.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/graph/component-class.h>
error:
print_python_traceback_warn();
pyerr_clear();
- BT_PUT(plugin);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
end:
Py_XDECREF(py_name);
goto end;
error:
- BT_PUT(plugin_set);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
end:
- bt_put(plugin);
+ bt_object_put_ref(plugin);
Py_XDECREF(py_plugin_info);
g_free(basename);
return plugin_set;
#include <babeltrace/plugin/plugin-dev.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/values.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/assert-internal.h>
#include <babeltrace/graph/private-connection-private-notification-iterator.h>
#include <babeltrace/graph/private-port.h>
#include <babeltrace/plugin/plugin.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <glib.h>
#include "tap/tap.h"
fprintf(stderr, ":: stream 2, packet 2: %p\n", src_stream2_packet2);
}
- bt_put(trace);
+ bt_object_put_ref(trace);
}
static
g_array_free(test_events, TRUE);
/* Metadata */
- bt_put(src_stream_class);
- bt_put(src_event_class);
- bt_put(src_stream1);
- bt_put(src_stream2);
- bt_put(src_stream1_packet1);
- bt_put(src_stream1_packet2);
- bt_put(src_stream2_packet1);
- bt_put(src_stream2_packet2);
+ bt_object_put_ref(src_stream_class);
+ bt_object_put_ref(src_event_class);
+ bt_object_put_ref(src_stream1);
+ bt_object_put_ref(src_stream2);
+ bt_object_put_ref(src_stream1_packet1);
+ bt_object_put_ref(src_stream1_packet2);
+ bt_object_put_ref(src_stream2_packet1);
+ bt_object_put_ref(src_stream2_packet2);
}
static
for (i = 0; i < count; i++) {
append_test_events_from_notification(notifications[i]);
- bt_put(notifications[i]);
+ bt_object_put_ref(notifications[i]);
}
end:
switch (it_ret) {
case BT_NOTIFICATION_ITERATOR_STATUS_END:
ret = BT_COMPONENT_STATUS_END;
- BT_PUT(user_data->notif_iter);
+ BT_OBJECT_PUT_REF_AND_RESET(user_data->notif_iter);
goto end;
case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
abort();
conn_status = bt_private_connection_create_notification_iterator(
priv_conn, &user_data->notif_iter);
BT_ASSERT(conn_status == 0);
- bt_put(priv_conn);
+ bt_object_put_ref(priv_conn);
return BT_COMPONENT_STATUS_OK;
}
private_component);
if (user_data) {
- bt_put(user_data->notif_iter);
+ bt_object_put_ref(user_data->notif_iter);
g_free(user_data);
}
}
ret = bt_graph_add_component(graph, src_comp_class, "source",
NULL, source);
BT_ASSERT(ret == 0);
- bt_put(src_comp_class);
+ bt_object_put_ref(src_comp_class);
}
/* Create sink component */
ret = bt_graph_add_component(graph, sink_comp_class, "sink",
NULL, sink);
BT_ASSERT(ret == 0);
- bt_put(sink_comp_class);
+ bt_object_put_ref(sink_comp_class);
}
}
BT_ASSERT(downstream_port);
graph_status = bt_graph_connect_ports(graph, upstream_port,
downstream_port, NULL);
- bt_put(upstream_port);
- bt_put(downstream_port);
+ bt_object_put_ref(upstream_port);
+ bt_object_put_ref(downstream_port);
/* Run the graph until the end */
while (graph_status == BT_GRAPH_STATUS_OK ||
"the produced sequence of test events is the expected one");
}
- bt_put(src_comp);
- bt_put(sink_comp);
- BT_PUT(graph);
+ bt_object_put_ref(src_comp);
+ bt_object_put_ref(sink_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(graph);
}
static
notif_iter = bt_output_port_notification_iterator_create(upstream_port,
NULL);
ok(notif_iter, "bt_output_port_notification_iterator_create() succeeds");
- bt_put(upstream_port);
+ bt_object_put_ref(upstream_port);
/* Consume the notification iterator */
while (iter_status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
ok(compare_test_events(expected_test_events),
"the produced sequence of test events is the expected one");
- bt_put(src_comp);
- BT_PUT(graph);
- bt_put(notif_iter);
+ bt_object_put_ref(src_comp);
+ BT_OBJECT_PUT_REF_AND_RESET(graph);
+ bt_object_put_ref(notif_iter);
}
#define DEBUG_ENV_VAR "TEST_BT_NOTIFICATION_ITERATOR_DEBUG"
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/values.h>
#include <babeltrace/assert-internal.h>
#include <string.h>
ok(bt_value_null, "bt_value_null is not NULL");
ok(bt_value_is_null(bt_value_null),
"bt_value_null is a null value object");
- bt_get(bt_value_null);
+ bt_object_get_ref(bt_value_null);
pass("getting bt_value_null does not cause a crash");
- bt_put(bt_value_null);
+ bt_object_put_ref(bt_value_null);
pass("putting bt_value_null does not cause a crash");
}
ret = bt_value_bool_get(obj, &value);
ok(!ret && value, "bt_value_bool_set() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing boolean value object does not cause a crash")
value = BT_FALSE;
ok(!ret && value,
"bt_value_bool_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
ret = bt_value_integer_get(obj, &value);
ok(!ret && value == -98765, "bt_value_integer_set() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing integer value object does not cause a crash")
obj = bt_value_integer_create_init(321456987);
ok(!ret && value == 321456987,
"bt_value_integer_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
ret = bt_value_real_get(obj, &value);
ok(!ret && value == -3.1416, "bt_value_real_set() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing real number value object does not cause a crash")
obj = bt_value_real_create_init(33.1649758);
ok(!ret && value == 33.1649758,
"bt_value_real_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
ok(!ret && value && !strcmp(value, "hello worldz"),
"bt_value_string_get() works");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
pass("putting an existing string value object does not cause a crash")
obj = bt_value_string_create_init("initial value");
ok(!ret && value && !strcmp(value, "initial value"),
"bt_value_string_create_init() sets the appropriate initial value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
}
static
obj = bt_value_integer_create_init(345);
ret = bt_value_array_append_element(array_obj, obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_real_create_init(-17.45);
ret |= bt_value_array_append_element(array_obj, obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_bool_create_init(BT_TRUE);
ret |= bt_value_array_append_element(array_obj, obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
ret |= bt_value_array_append_element(array_obj, bt_value_null);
ok(!ret, "bt_value_array_append_element() succeeds");
ok(bt_value_array_get_size(array_obj) == 4,
BT_ASSERT(obj);
ok(!bt_value_array_set_element_by_index(array_obj, 2, obj),
"bt_value_array_set_element_by_index() succeeds");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_array_borrow_element_by_index(array_obj, 2);
ok(obj && bt_value_is_integer(obj),
"bt_value_array_set_element_by_index() inserts an value object with the appropriate type");
ok(bt_value_map_is_empty(obj),
"bt_value_array_append_empty_map_element() an empty map value object");
- BT_PUT(array_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(array_obj);
pass("putting an existing array value object does not cause a crash")
}
obj = bt_value_integer_create_init(19457);
ret = bt_value_map_insert_entry(map_obj, "int", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_real_create_init(5.444);
ret |= bt_value_map_insert_entry(map_obj, "real", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_value_bool_create();
ret |= bt_value_map_insert_entry(map_obj, "bt_bool", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
ret |= bt_value_map_insert_entry(map_obj, "null", bt_value_null);
ok(!ret, "bt_value_map_insert_entry() succeeds");
ok(bt_value_map_get_size(map_obj) == 4,
obj = bt_value_bool_create_init(BT_TRUE);
ret = bt_value_map_insert_entry(map_obj, "bt_bool", obj);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
ok(!ret, "bt_value_map_insert_entry() accepts an existing key");
obj = bt_value_map_borrow_entry_value(map_obj, "life");
checklist.array2 && checklist.map2,
"bt_value_map_foreach_entry() iterates over all the map value object's elements");
- BT_PUT(map_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(map_obj);
pass("putting an existing map value object does not cause a crash")
}
ok(bt_value_compare(bool1, bool3),
"boolean value objects are equivalent (BT_FALSE and BT_FALSE)");
- BT_PUT(bool1);
- BT_PUT(bool2);
- BT_PUT(bool3);
+ BT_OBJECT_PUT_REF_AND_RESET(bool1);
+ BT_OBJECT_PUT_REF_AND_RESET(bool2);
+ BT_OBJECT_PUT_REF_AND_RESET(bool3);
}
static
ok(bt_value_compare(int1, int3),
"integer value objects are equivalent (10 and 10)");
- BT_PUT(int1);
- BT_PUT(int2);
- BT_PUT(int3);
+ BT_OBJECT_PUT_REF_AND_RESET(int1);
+ BT_OBJECT_PUT_REF_AND_RESET(int2);
+ BT_OBJECT_PUT_REF_AND_RESET(int3);
}
static
ok(bt_value_compare(real1, real3),
"real number value objects are equivalent (17.38 and 17.38)");
- BT_PUT(real1);
- BT_PUT(real2);
- BT_PUT(real3);
+ BT_OBJECT_PUT_REF_AND_RESET(real1);
+ BT_OBJECT_PUT_REF_AND_RESET(real2);
+ BT_OBJECT_PUT_REF_AND_RESET(real3);
}
static
ok(bt_value_compare(string1, string3),
"string value objects are equivalent (\"hello\" and \"hello\")");
- BT_PUT(string1);
- BT_PUT(string2);
- BT_PUT(string3);
+ BT_OBJECT_PUT_REF_AND_RESET(string1);
+ BT_OBJECT_PUT_REF_AND_RESET(string2);
+ BT_OBJECT_PUT_REF_AND_RESET(string3);
}
static
ok(bt_value_compare(array1, array3),
"array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])");
- BT_PUT(array1);
- BT_PUT(array2);
- BT_PUT(array3);
+ BT_OBJECT_PUT_REF_AND_RESET(array1);
+ BT_OBJECT_PUT_REF_AND_RESET(array2);
+ BT_OBJECT_PUT_REF_AND_RESET(array3);
}
static
ok(bt_value_compare(map1, map3),
"map value objects are equivalent");
- BT_PUT(map1);
- BT_PUT(map2);
- BT_PUT(map3);
+ BT_OBJECT_PUT_REF_AND_RESET(map1);
+ BT_OBJECT_PUT_REF_AND_RESET(map2);
+ BT_OBJECT_PUT_REF_AND_RESET(map3);
}
static
ok(bt_value_compare(map_obj, map_copy_obj),
"source and destination value objects have the same content");
- BT_PUT(map_copy_obj);
- BT_PUT(bool_obj);
- BT_PUT(integer_obj);
- BT_PUT(real_obj);
- BT_PUT(string_obj);
- BT_PUT(array_obj);
- BT_PUT(map_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(map_copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(bool_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(integer_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(real_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(string_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(array_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(map_obj);
}
static
ok(compare_map_elements(extension_map, extended_map, "project"),
"bt_value_map_extend() picks the appropriate element (project)");
- BT_PUT(array);
- BT_PUT(base_map);
- BT_PUT(extension_map);
- BT_PUT(extended_map);
+ BT_OBJECT_PUT_REF_AND_RESET(array);
+ BT_OBJECT_PUT_REF_AND_RESET(base_map);
+ BT_OBJECT_PUT_REF_AND_RESET(extension_map);
+ BT_OBJECT_PUT_REF_AND_RESET(extended_map);
}
int main(void)
#include <babeltrace/ctf-writer/event-fields.h>
#include <babeltrace/ctf-writer/stream-class.h>
#include <babeltrace/ctf-writer/trace.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/ctf/events.h>
#include <babeltrace/values.h>
#include <glib.h>
ok(returned_type == int_64_type, "bt_ctf_field_type_enumeration_get_container_field_type returns the right type");
ok(!bt_ctf_field_type_enumeration_create(enum_type),
"bt_ctf_field_enumeration_type_create rejects non-integer container field types");
- bt_put(returned_type);
+ bt_object_put_ref(returned_type);
bt_ctf_field_type_set_alignment(float_type, 32);
ok(bt_ctf_field_type_get_alignment(float_type) == 32,
returned_type = bt_ctf_event_class_get_context_field_type(simple_event_class);
ok(returned_type == event_context_type,
"bt_ctf_event_class_get_context_field_type returns the appropriate type");
- bt_put(returned_type);
+ bt_object_put_ref(returned_type);
ok(!bt_ctf_stream_class_add_event_class(stream_class, simple_event_class),
"Adding simple event class to stream class");
* of simple_event_class, so we retrieve the new ones to create
* the appropriate fields.
*/
- BT_PUT(event_context_type);
- BT_PUT(event_payload_type);
+ BT_OBJECT_PUT_REF_AND_RESET(event_context_type);
+ BT_OBJECT_PUT_REF_AND_RESET(event_payload_type);
event_payload_type = bt_ctf_event_class_get_payload_field_type(
simple_event_class);
BT_ASSERT(event_payload_type);
ret_event_class = bt_ctf_stream_class_get_event_class_by_index(stream_class, 0);
ok(ret_event_class == simple_event_class,
"bt_ctf_stream_class_get_event_class returns the correct event class");
- bt_put(ret_event_class);
+ bt_object_put_ref(ret_event_class);
ok(!bt_ctf_stream_class_get_event_class_by_id(stream_class, 2),
"bt_ctf_stream_class_get_event_class_by_id returns NULL when the requested ID doesn't exist");
ret_event_class =
bt_ctf_stream_class_get_event_class_by_id(stream_class, 13);
ok(ret_event_class == simple_event_class,
"bt_ctf_stream_class_get_event_class_by_id returns a correct event class");
- bt_put(ret_event_class);
+ bt_object_put_ref(ret_event_class);
simple_event = bt_ctf_event_create(simple_event_class);
ok(simple_event,
"Set signed enumeration container value");
ret = bt_ctf_event_set_payload(simple_event, "enum_field", enum_field);
BT_ASSERT(!ret);
- BT_PUT(iter);
+ BT_OBJECT_PUT_REF_AND_RESET(iter);
enum_field_unsigned = bt_ctf_field_create(ep_enum_field_unsigned_type);
BT_ASSERT(enum_field_unsigned);
"packet_size");
ok(packet_context_field,
"Packet context contains the default packet_size field.");
- bt_put(packet_context_field);
+ bt_object_put_ref(packet_context_field);
packet_context_field = bt_ctf_field_structure_get_field_by_name(packet_context,
"custom_packet_context_field");
ok(bt_ctf_field_integer_unsigned_set_value(packet_context_field, 8) == 0,
ok(bt_ctf_stream_flush(stream) == 0,
"Flush trace stream with one event");
- bt_put(simple_event_class);
- bt_put(simple_event);
- bt_put(uint_12_type);
- bt_put(int_64_type);
- bt_put(float_type);
- bt_put(enum_type);
- bt_put(enum_type_unsigned);
- bt_put(returned_type);
- bt_put(event_context_type);
- bt_put(integer_field);
- bt_put(float_field);
- bt_put(enum_field);
- bt_put(enum_field_unsigned);
- bt_put(enum_container_field);
- bt_put(enum_container_field_unsigned);
- bt_put(packet_context);
- bt_put(packet_context_field);
- bt_put(stream_event_context);
- bt_put(stream_event_context_field);
- bt_put(event_context);
- bt_put(event_context_field);
- bt_put(event_payload_type);
- bt_put(ep_integer_field_type);
- bt_put(ep_enum_field_type);
- bt_put(ep_enum_field_unsigned_type);
- bt_put(iter);
+ bt_object_put_ref(simple_event_class);
+ bt_object_put_ref(simple_event);
+ bt_object_put_ref(uint_12_type);
+ bt_object_put_ref(int_64_type);
+ bt_object_put_ref(float_type);
+ bt_object_put_ref(enum_type);
+ bt_object_put_ref(enum_type_unsigned);
+ bt_object_put_ref(returned_type);
+ bt_object_put_ref(event_context_type);
+ bt_object_put_ref(integer_field);
+ bt_object_put_ref(float_field);
+ bt_object_put_ref(enum_field);
+ bt_object_put_ref(enum_field_unsigned);
+ bt_object_put_ref(enum_container_field);
+ bt_object_put_ref(enum_container_field_unsigned);
+ bt_object_put_ref(packet_context);
+ bt_object_put_ref(packet_context_field);
+ bt_object_put_ref(stream_event_context);
+ bt_object_put_ref(stream_event_context_field);
+ bt_object_put_ref(event_context);
+ bt_object_put_ref(event_context_field);
+ bt_object_put_ref(event_payload_type);
+ bt_object_put_ref(ep_integer_field_type);
+ bt_object_put_ref(ep_enum_field_type);
+ bt_object_put_ref(ep_enum_field_unsigned_type);
+ bt_object_put_ref(iter);
}
static
array_type);
ok(ret_field_type == int_16_type,
"bt_ctf_field_type_array_get_element_field_type returns the correct type");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
ok(bt_ctf_field_type_array_get_length(array_type) == ARRAY_TEST_LENGTH,
"bt_ctf_field_type_array_get_length returns the correct length");
ret_field_type = bt_ctf_field_type_variant_get_tag_field_type(variant_type);
ok(ret_field_type == enum_variant_type,
"bt_ctf_field_type_variant_get_tag_field_type returns a correct tag type");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
ret_string = bt_ctf_field_type_variant_get_tag_name(variant_type);
ok(ret_string ? !strcmp(ret_string, "variant_selector") : 0,
variant_type, "INT16_TYPE");
ok(ret_field_type == int_16_type,
"bt_ctf_field_type_variant_get_field_type_by_name returns a correct field type");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
ok(bt_ctf_field_type_variant_get_field_count(variant_type) == 3,
"bt_ctf_field_type_variant_get_field_count returns the correct count");
ok(bt_ctf_field_type_variant_get_field_by_index(variant_type, NULL, &ret_field_type, 0) == 0,
"bt_ctf_field_type_variant_get_field handles a NULL field name correctly");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
ok(bt_ctf_field_type_variant_get_field_by_index(variant_type, &ret_string, NULL, 0) == 0,
"bt_ctf_field_type_variant_get_field handles a NULL field type correctly");
ok(bt_ctf_field_type_variant_get_field_by_index(variant_type, &ret_string, &ret_field_type, 1) == 0,
"bt_ctf_field_type_variant_get_field returns a correct field name");
ok(ret_field_type == int_16_type,
"bt_ctf_field_type_variant_get_field returns a correct field type");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
ok(!bt_ctf_field_type_structure_add_field(complex_structure_type,
enum_variant_type, "variant_selector"),
ret_stream_class = bt_ctf_event_class_get_stream_class(event_class);
ok(ret_stream_class == stream_class,
"bt_ctf_event_class_get_stream_class returns the correct stream class");
- bt_put(ret_stream_class);
+ bt_object_put_ref(ret_stream_class);
ok(bt_ctf_event_class_get_field_by_name(event_class, "truie") == NULL,
"bt_ctf_event_class_get_field_by_name handles an invalid field name correctly");
ret_field_type = bt_ctf_event_class_get_field_by_name(event_class,
"complex_structure");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
event = bt_ctf_event_create(event_class);
ok(event, "Instanciate a complex event");
ret_event_class = bt_ctf_event_get_class(event);
ok(ret_event_class == event_class,
"bt_ctf_event_get_class returns the correct event class");
- bt_put(ret_event_class);
+ bt_object_put_ref(ret_event_class);
uint_35_field = bt_ctf_event_get_payload(event, "uint_35");
ok(uint_35_field, "Use bt_ctf_event_get_payload to get a field instance ");
"bt_ctf_field_integer_unsigned_get_value succeeds after setting a value");
ok(ret_unsigned_int == 0x0DDF00D,
"bt_ctf_field_integer_unsigned_get_value returns the correct value");
- bt_put(uint_35_field);
+ bt_object_put_ref(uint_35_field);
int_16_field = bt_ctf_event_get_payload(event, "int_16");
bt_ctf_field_integer_signed_set_value(int_16_field, -12345);
"bt_ctf_field_integer_signed_get_value succeeds after setting a value");
ok(ret_signed_int == -12345,
"bt_ctf_field_integer_signed_get_value returns the correct value");
- bt_put(int_16_field);
+ bt_object_put_ref(int_16_field);
complex_structure_field = bt_ctf_event_get_payload(event,
"complex_structure");
inner_structure_field = bt_ctf_field_structure_get_field_by_index(
complex_structure_field, 3);
ret_field_type = bt_ctf_field_get_type(inner_structure_field);
- bt_put(inner_structure_field);
- bt_put(ret_field_type);
+ bt_object_put_ref(inner_structure_field);
+ bt_object_put_ref(ret_field_type);
inner_structure_field = bt_ctf_field_structure_get_field_by_name(
complex_structure_field, "inner_structure");
int_16_field = bt_ctf_field_variant_get_field(variant_field,
enum_variant_field);
bt_ctf_field_integer_signed_set_value(int_16_field, -200);
- bt_put(int_16_field);
+ bt_object_put_ref(int_16_field);
bt_ctf_field_string_set_value(a_string_field,
test_string_1);
ok(!bt_ctf_field_string_append(a_string_field, test_string_2),
int_16_field = bt_ctf_field_sequence_get_field(
a_sequence_field, i);
bt_ctf_field_integer_signed_set_value(int_16_field, 4 - i);
- bt_put(int_16_field);
+ bt_object_put_ref(int_16_field);
}
for (i = 0; i < ARRAY_TEST_LENGTH; i++) {
int_16_field = bt_ctf_field_array_get_field(
an_array_field, i);
bt_ctf_field_integer_signed_set_value(int_16_field, i);
- bt_put(int_16_field);
+ bt_object_put_ref(int_16_field);
}
stream_event_ctx_field = bt_ctf_event_get_stream_event_context(event);
BT_ASSERT(stream_event_ctx_field);
stream_event_ctx_int_field = bt_ctf_field_structure_get_field_by_name(
stream_event_ctx_field, "common_event_context");
- BT_PUT(stream_event_ctx_field);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_field);
bt_ctf_field_integer_unsigned_set_value(stream_event_ctx_int_field, 17);
- BT_PUT(stream_event_ctx_int_field);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_event_ctx_int_field);
bt_ctf_clock_set_time(clock, ++current_time);
ok(bt_ctf_stream_append_event(stream, event) == 0,
ok(bt_ctf_stream_flush(stream) == 0,
"Flush a stream containing a complex event");
- bt_put(uint_35_field);
- bt_put(a_string_field);
- bt_put(inner_structure_field);
- bt_put(complex_structure_field);
- bt_put(a_sequence_field);
- bt_put(an_array_field);
- bt_put(enum_variant_field);
- bt_put(enum_container_field);
- bt_put(variant_field);
- bt_put(packet_context_field);
- bt_put(packet_context);
- bt_put(uint_35_type);
- bt_put(int_16_type);
- bt_put(string_type);
- bt_put(sequence_type);
- bt_put(array_type);
- bt_put(inner_structure_type);
- bt_put(complex_structure_type);
- bt_put(uint_3_type);
- bt_put(enum_variant_type);
- bt_put(variant_type);
- bt_put(ret_field_type);
- bt_put(event_class);
- bt_put(event);
+ bt_object_put_ref(uint_35_field);
+ bt_object_put_ref(a_string_field);
+ bt_object_put_ref(inner_structure_field);
+ bt_object_put_ref(complex_structure_field);
+ bt_object_put_ref(a_sequence_field);
+ bt_object_put_ref(an_array_field);
+ bt_object_put_ref(enum_variant_field);
+ bt_object_put_ref(enum_container_field);
+ bt_object_put_ref(variant_field);
+ bt_object_put_ref(packet_context_field);
+ bt_object_put_ref(packet_context);
+ bt_object_put_ref(uint_35_type);
+ bt_object_put_ref(int_16_type);
+ bt_object_put_ref(string_type);
+ bt_object_put_ref(sequence_type);
+ bt_object_put_ref(array_type);
+ bt_object_put_ref(inner_structure_type);
+ bt_object_put_ref(complex_structure_type);
+ bt_object_put_ref(uint_3_type);
+ bt_object_put_ref(enum_variant_type);
+ bt_object_put_ref(variant_type);
+ bt_object_put_ref(ret_field_type);
+ bt_object_put_ref(event_class);
+ bt_object_put_ref(event);
}
static
sequence_type);
ok(returned_type == int_16_type,
"bt_ctf_field_type_sequence_get_element_field_type returns the correct type");
- bt_put(returned_type);
+ bt_object_put_ref(returned_type);
string_type = bt_ctf_field_type_string_create();
ok(string_type, "Create a string type");
ok(bt_ctf_field_type_structure_get_field(structure_seq_type,
NULL, &returned_type, 1) == 0,
"bt_ctf_field_type_structure_get_field handles a NULL name correctly");
- bt_put(returned_type);
+ bt_object_put_ref(returned_type);
ok(bt_ctf_field_type_structure_get_field(structure_seq_type,
&ret_string, NULL, 1) == 0,
"bt_ctf_field_type_structure_get_field handles a NULL return type correctly");
"bt_ctf_field_type_structure_get_field returns a correct field name");
ok(returned_type == sequence_type,
"bt_ctf_field_type_structure_get_field returns a correct field type");
- bt_put(returned_type);
+ bt_object_put_ref(returned_type);
returned_type = bt_ctf_field_type_structure_get_field_type_by_name(
structure_seq_type, "a_sequence");
ok(returned_type == sequence_type,
"bt_ctf_field_type_structure_get_field_type_by_name returns the correct field type");
- bt_put(returned_type);
+ bt_object_put_ref(returned_type);
composite_structure_type = bt_ctf_field_type_structure_create();
ok(bt_ctf_field_type_structure_add_field(composite_structure_type,
structure_seq_type, "a_sequence");
ok(returned_type == sequence_type,
"bt_ctf_field_type_structure_get_field_type_by_name returns a correct type");
- bt_put(returned_type);
+ bt_object_put_ref(returned_type);
int_16 = bt_ctf_field_create(int_16_type);
ok(int_16, "Instanciate a signed 16-bit integer");
ok(enumeration_type,
"Create an enumeration type with an unsigned 12-bit integer as container");
- bt_put(string);
- bt_put(uint_12);
- bt_put(int_16);
- bt_put(composite_structure_type);
- bt_put(structure_seq_type);
- bt_put(string_type);
- bt_put(sequence_type);
- bt_put(uint_8_type);
- bt_put(int_16_type);
- bt_put(uint_12_type);
- bt_put(enumeration_type);
- bt_put(returned_type);
+ bt_object_put_ref(string);
+ bt_object_put_ref(uint_12);
+ bt_object_put_ref(int_16);
+ bt_object_put_ref(composite_structure_type);
+ bt_object_put_ref(structure_seq_type);
+ bt_object_put_ref(string_type);
+ bt_object_put_ref(sequence_type);
+ bt_object_put_ref(uint_8_type);
+ bt_object_put_ref(int_16_type);
+ bt_object_put_ref(uint_12_type);
+ bt_object_put_ref(enumeration_type);
+ bt_object_put_ref(returned_type);
}
static
event = bt_ctf_event_create(event_class);
ret_field = bt_ctf_event_get_payload(event, 0);
ret_field_type = bt_ctf_field_get_type(ret_field);
- bt_put(ret_field_type);
- bt_put(ret_field);
- bt_put(event);
+ bt_object_put_ref(ret_field_type);
+ bt_object_put_ref(ret_field);
+ bt_object_put_ref(event);
for (i = 0; i < packet_resize_test_length; i++) {
event = bt_ctf_event_create(event_class);
ret |= bt_ctf_field_integer_unsigned_set_value(integer, i);
ret |= bt_ctf_event_set_payload(event, "field_1",
integer);
- bt_put(integer);
+ bt_object_put_ref(integer);
ret |= bt_ctf_field_string_set_value(string, "This is a test");
ret |= bt_ctf_event_set_payload(event, "a_string",
string);
- bt_put(string);
+ bt_object_put_ref(string);
/* Populate stream event context */
stream_event_context =
bt_ctf_event_get_stream_event_context(event);
integer = bt_ctf_field_structure_get_field_by_name(stream_event_context,
"common_event_context");
- BT_PUT(stream_event_context);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_event_context);
ret |= bt_ctf_field_integer_unsigned_set_value(integer,
i % 42);
- bt_put(integer);
+ bt_object_put_ref(integer);
ret |= bt_ctf_stream_append_event(stream, event);
- bt_put(event);
+ bt_object_put_ref(event);
if (ret) {
break;
ret = bt_ctf_stream_get_discarded_events_count(stream, &ret_uint64);
ok(ret == 0 && ret_uint64 == 1000,
"bt_ctf_stream_get_discarded_events_count returns a correct number of discarded events after a flush");
- bt_put(integer_type);
- bt_put(string_type);
- bt_put(packet_context);
- bt_put(packet_context_field);
- bt_put(stream_event_context);
- bt_put(event_class);
- bt_put(ep_field_1_type);
- bt_put(ep_a_string_type);
- bt_put(ep_type);
+ bt_object_put_ref(integer_type);
+ bt_object_put_ref(string_type);
+ bt_object_put_ref(packet_context);
+ bt_object_put_ref(packet_context_field);
+ bt_object_put_ref(stream_event_context);
+ bt_object_put_ref(event_class);
+ bt_object_put_ref(ep_field_1_type);
+ bt_object_put_ref(ep_a_string_type);
+ bt_object_put_ref(ep_type);
}
static
end:
ok(ret == 0,
"Created a stream class with default attributes and an empty stream");
- bt_put(trace);
- bt_put(ret_trace);
- bt_put(stream);
- bt_put(stream_class);
+ bt_object_put_ref(trace);
+ bt_object_put_ref(ret_trace);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(stream_class);
}
static
fail("Failed to set custom_trace_packet_header_field value");
goto end;
}
- bt_put(integer);
+ bt_object_put_ref(integer);
event = bt_ctf_event_create(event_class);
if (!event) {
fail("Failed to set sequence length");
goto end;
}
- bt_put(integer);
+ bt_object_put_ref(integer);
for (i = 0; i < 2; i++) {
integer = bt_ctf_field_sequence_get_field(sequence, i);
goto end;
}
- bt_put(integer);
+ bt_object_put_ref(integer);
integer = NULL;
}
fail("Failed to flush custom_event_header stream");
}
end:
- bt_put(stream);
- bt_put(stream_class);
- bt_put(event_class);
- bt_put(event);
- bt_put(integer);
- bt_put(sequence);
- bt_put(event_header);
- bt_put(packet_header);
- bt_put(sequence_type);
- bt_put(integer_type);
- bt_put(event_header_type);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(event_class);
+ bt_object_put_ref(event);
+ bt_object_put_ref(integer);
+ bt_object_put_ref(sequence);
+ bt_object_put_ref(event_header);
+ bt_object_put_ref(packet_header);
+ bt_object_put_ref(sequence_type);
+ bt_object_put_ref(integer_type);
+ bt_object_put_ref(event_header_type);
}
static
end:
ok(ret == 0,
"Create an event before instanciating its associated stream");
- bt_put(stream);
- bt_put(ret_stream);
- bt_put(stream_class);
- bt_put(event_class);
- bt_put(event);
- bt_put(integer_type);
- bt_put(integer);
- bt_put(payload_field);
+ bt_object_put_ref(stream);
+ bt_object_put_ref(ret_stream);
+ bt_object_put_ref(stream_class);
+ bt_object_put_ref(event_class);
+ bt_object_put_ref(event);
+ bt_object_put_ref(integer_type);
+ bt_object_put_ref(integer);
+ bt_object_put_ref(payload_field);
}
static
BT_ASSERT(event_class);
ok(bt_ctf_stream_class_add_event_class(stream_class, event_class) == 0,
"two event classes with the same name may cohabit within the same stream class");
- bt_put(event_class);
+ bt_object_put_ref(event_class);
event_class = bt_ctf_event_class_create("different name, ok");
BT_ASSERT(event_class);
BT_ASSERT(ret == 0);
ok(bt_ctf_stream_class_add_event_class(stream_class, event_class),
"two event classes with the same ID cannot cohabit within the same stream class");
- bt_put(event_class);
+ bt_object_put_ref(event_class);
}
static
ret = bt_ctf_clock_set_frequency(clock, 1534);
BT_ASSERT(!ret);
- BT_PUT(clock);
+ BT_OBJECT_PUT_REF_AND_RESET(clock);
}
int main(int argc, char **argv)
"bt_ctf_trace_set_environment_field handles a NULL value correctly");
ok(!bt_ctf_trace_set_environment_field(trace, "test_env_int_obj", obj),
"bt_ctf_trace_set_environment_field succeeds in adding an integer object");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
/* Test bt_ctf_trace_set_environment_field with a string object */
obj = bt_value_string_create_init("the value");
BT_ASSERT(obj);
ok(!bt_ctf_trace_set_environment_field(trace, "test_env_str_obj", obj),
"bt_ctf_trace_set_environment_field succeeds in adding a string object");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
/* Test bt_ctf_trace_set_environment_field_integer */
ok(bt_ctf_trace_set_environment_field_integer(NULL, "test_env_int",
ret = bt_value_integer_get(obj, &ret_int64_t);
ok(!ret && ret_int64_t == 23,
"bt_ctf_trace_get_environment_field_value succeeds in getting an integer value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
obj = bt_ctf_trace_get_environment_field_value_by_index(trace, 2);
ret = bt_value_string_get(obj, &ret_string);
ok(!ret && ret_string && !strcmp(ret_string, "the value"),
"bt_ctf_trace_get_environment_field_value succeeds in getting a string value");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
/* Test bt_ctf_trace_get_environment_field_value_by_name */
ok(!bt_ctf_trace_get_environment_field_value_by_name(trace, "oh oh"),
ret = bt_value_string_get(obj, &ret_string);
ok(!ret && ret_string && !strcmp(ret_string, "oh yeah"),
"bt_ctf_trace_get_environment_field_value_by_name succeeds in getting an existing field");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
/* Test environment field replacement */
ok(!bt_ctf_trace_set_environment_field_integer(trace, "test_env_int",
ret = bt_value_integer_get(obj, &ret_int64_t);
ok(!ret && ret_int64_t == 654321,
"bt_ctf_trace_get_environment_field_value successfully replaces an existing field");
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
ok(bt_ctf_writer_add_environment_field(writer, "sysname", name.sysname)
== 0, "Add sysname (%s) environment field to writer instance",
ret_clock = bt_ctf_stream_class_get_clock(stream_class);
ok(ret_clock == clock,
"bt_ctf_stream_class_get_clock returns a correct clock");
- bt_put(ret_clock);
+ bt_object_put_ref(ret_clock);
/* Test the event fields and event types APIs */
type_field_tests();
ok(bt_ctf_field_type_get_type_id(
event_header_field_type) == BT_CTF_FIELD_TYPE_ID_INTEGER,
"Default event header \"id\" field is an integer");
- bt_put(event_header_field_type);
+ bt_object_put_ref(event_header_field_type);
event_header_field_type =
bt_ctf_field_type_structure_get_field_type_by_name(
ret_field_type, "timestamp");
ok(bt_ctf_field_type_get_type_id(
event_header_field_type) == BT_CTF_FIELD_TYPE_ID_INTEGER,
"Default event header \"timestamp\" field is an integer");
- bt_put(event_header_field_type);
- bt_put(ret_field_type);
+ bt_object_put_ref(event_header_field_type);
+ bt_object_put_ref(ret_field_type);
/* Add a custom trace packet header field */
packet_header_type = bt_ctf_trace_get_packet_header_field_type(trace);
ret_field_type = bt_ctf_field_type_structure_get_field_type_by_name(
packet_header_type, "magic");
ok(ret_field_type, "Default packet header type contains a \"magic\" field");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
ret_field_type = bt_ctf_field_type_structure_get_field_type_by_name(
packet_header_type, "uuid");
ok(ret_field_type, "Default packet header type contains a \"uuid\" field");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
ret_field_type = bt_ctf_field_type_structure_get_field_type_by_name(
packet_header_type, "stream_id");
ok(ret_field_type, "Default packet header type contains a \"stream_id\" field");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
packet_header_field_type = bt_ctf_field_type_integer_create(22);
ok(!bt_ctf_field_type_structure_add_field(packet_header_type,
stream_class);
ok(ret_field_type == stream_event_context_type,
"bt_ctf_stream_class_get_event_context_type returns the correct field type.");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
/* Instantiate a stream and append events */
stream = bt_ctf_trace_get_stream_by_index(trace, 0);
ok(stream == stream1,
"bt_ctf_trace_get_stream_by_index() succeeds and returns the correct value");
- BT_PUT(stream);
+ BT_OBJECT_PUT_REF_AND_RESET(stream);
/*
* Creating a stream through a writer adds the given stream
* event context types were copied for the resolving
* process
*/
- BT_PUT(packet_header_type);
- BT_PUT(packet_context_type);
- BT_PUT(stream_event_context_type);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_header_type);
+ BT_OBJECT_PUT_REF_AND_RESET(packet_context_type);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_event_context_type);
packet_header_type = bt_ctf_trace_get_packet_header_field_type(trace);
BT_ASSERT(packet_header_type);
packet_context_type =
ret_field_type = bt_ctf_field_get_type(packet_header);
ok(ret_field_type == packet_header_type,
"Stream returns a packet header of the appropriate type");
- bt_put(ret_field_type);
+ bt_object_put_ref(ret_field_type);
packet_header_field = bt_ctf_field_structure_get_field_by_name(packet_header,
"custom_trace_packet_header_field");
ok(packet_header_field,
bt_ctf_writer_flush_metadata(writer);
- bt_put(clock);
- bt_put(ret_stream_class);
- bt_put(writer);
- bt_put(stream1);
- bt_put(packet_context_type);
- bt_put(packet_context_field_type);
- bt_put(integer_type);
- bt_put(stream_event_context_type);
- bt_put(ret_field_type);
- bt_put(packet_header_type);
- bt_put(packet_header_field_type);
- bt_put(packet_header);
- bt_put(packet_header_field);
- bt_put(trace);
+ bt_object_put_ref(clock);
+ bt_object_put_ref(ret_stream_class);
+ bt_object_put_ref(writer);
+ bt_object_put_ref(stream1);
+ bt_object_put_ref(packet_context_type);
+ bt_object_put_ref(packet_context_field_type);
+ bt_object_put_ref(integer_type);
+ bt_object_put_ref(stream_event_context_type);
+ bt_object_put_ref(ret_field_type);
+ bt_object_put_ref(packet_header_type);
+ bt_object_put_ref(packet_header_field_type);
+ bt_object_put_ref(packet_header);
+ bt_object_put_ref(packet_header_field);
+ bt_object_put_ref(trace);
free(metadata_string);
- bt_put(stream_class);
+ bt_object_put_ref(stream_class);
validate_trace(argv[1], trace_path);
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/graph/component-class-source.h>
#include <babeltrace/graph/component-class-sink.h>
BT_ASSERT(def_port);
ret = bt_private_port_remove_from_component(def_port);
BT_ASSERT(ret == 0);
- bt_put(def_port);
+ bt_object_put_ref(def_port);
break;
default:
break;
struct bt_component *comp = bt_port_get_component(port);
BT_ASSERT(comp);
- bt_put(comp);
+ bt_object_put_ref(comp);
struct event event = {
.type = GRAPH_PORT_ADDED,
BT_ASSERT(upstream_comp);
BT_ASSERT(downstream_comp);
BT_ASSERT(conn);
- bt_put(upstream_comp);
- bt_put(downstream_comp);
- bt_put(conn);
+ bt_object_put_ref(upstream_comp);
+ bt_object_put_ref(downstream_comp);
+ bt_object_put_ref(conn);
struct event event = {
.type = GRAPH_PORTS_CONNECTED,
static
void fini_test(void)
{
- bt_put(src_comp_class);
- bt_put(sink_comp_class);
+ bt_object_put_ref(src_comp_class);
+ bt_object_put_ref(sink_comp_class);
g_array_free(events, TRUE);
}
ok(graph_port_removed_src_pos < graph_port_removed_sink_pos,
"event order is good (13)");
- bt_put(graph);
- bt_put(sink);
- bt_put(src);
- bt_put(conn);
- bt_put(src_def_port);
- bt_put(sink_def_port);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(sink);
+ bt_object_put_ref(src);
+ bt_object_put_ref(conn);
+ bt_object_put_ref(src_def_port);
+ bt_object_put_ref(sink_def_port);
}
static
ok(graph_ports_disconnected_pos < graph_port_removed_sink_pos,
"event order is good (11)");
- bt_put(graph);
- bt_put(sink);
- bt_put(src);
- bt_put(conn);
- bt_put(src_def_port);
- bt_put(sink_def_port);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(sink);
+ bt_object_put_ref(src);
+ bt_object_put_ref(conn);
+ bt_object_put_ref(src_def_port);
+ bt_object_put_ref(sink_def_port);
}
static
ok(graph_port_added_src_pos < graph_ports_connected_pos,
"event order is good (6)");
- bt_put(graph);
- bt_put(sink);
- bt_put(src);
- bt_put(conn);
- bt_put(src_def_port);
- bt_put(sink_def_port);
- bt_put(src_hello_port);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(sink);
+ bt_object_put_ref(src);
+ bt_object_put_ref(conn);
+ bt_object_put_ref(src_def_port);
+ bt_object_put_ref(sink_def_port);
+ bt_object_put_ref(src_hello_port);
}
static
ok(sink_accept_port_connection_pos < sink_port_connected_pos,
"event order is good (4)");
- bt_put(graph);
- bt_put(sink);
- bt_put(src);
- bt_put(conn);
- bt_put(src_def_port);
- bt_put(sink_def_port);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(sink);
+ bt_object_put_ref(src);
+ bt_object_put_ref(conn);
+ bt_object_put_ref(src_def_port);
+ bt_object_put_ref(sink_def_port);
}
static
ok(src_accept_port_connection_pos < src_port_connected_pos,
"event order is good (1)");
- bt_put(graph);
- bt_put(sink);
- bt_put(src);
- bt_put(conn);
- bt_put(src_def_port);
- bt_put(sink_def_port);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(sink);
+ bt_object_put_ref(src);
+ bt_object_put_ref(conn);
+ bt_object_put_ref(src_def_port);
+ bt_object_put_ref(sink_def_port);
}
static
ok(sink_port_connected_pos < src_port_disconnected_pos,
"event order is good (3)");
- bt_put(graph);
- bt_put(sink);
- bt_put(src);
- bt_put(conn);
- bt_put(src_def_port);
- bt_put(sink_def_port);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(sink);
+ bt_object_put_ref(src);
+ bt_object_put_ref(conn);
+ bt_object_put_ref(src_def_port);
+ bt_object_put_ref(sink_def_port);
}
static
prepare_test(TEST_EMPTY_GRAPH, "empty graph");
graph = create_graph();
ok(events->len == 0, "empty graph generates no events");
- bt_put(graph);
+ bt_object_put_ref(graph);
}
int main(int argc, char **argv)
*/
#include <babeltrace/plugin/plugin.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/values.h>
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/graph.h>
"bt_plugin_get_path() returns the expected path");
ok(bt_plugin_get_component_class_count(plugin) == 0,
"bt_plugin_get_component_class_count() returns the expected value");
- bt_put(plugin);
- bt_put(plugin_set);
+ bt_object_put_ref(plugin);
+ bt_object_put_ref(plugin_set);
ok(check_env_var("BT_TEST_PLUGIN_EXIT_CALLED") == 1,
"plugin's exit function is called when the plugin is destroyed");
"bt_component_class_query() receives the expected parameters");
diag("> putting the plugin object here");
- BT_PUT(plugin);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
graph = bt_graph_create();
BT_ASSERT(graph);
graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink",
NULL, &sink_component);
ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
"bt_graph_add_component() still works after the plugin object is destroyed");
- BT_PUT(sink_component);
- BT_PUT(source_comp_class);
- bt_put(graph);
+ BT_OBJECT_PUT_REF_AND_RESET(sink_component);
+ BT_OBJECT_PUT_REF_AND_RESET(source_comp_class);
+ bt_object_put_ref(graph);
graph = bt_graph_create();
BT_ASSERT(graph);
graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink",
NULL, &sink_component);
ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
"bt_graph_add_component() still works after the source component class object is destroyed");
- BT_PUT(sink_component);
- BT_PUT(filter_comp_class);
- bt_put(graph);
+ BT_OBJECT_PUT_REF_AND_RESET(sink_component);
+ BT_OBJECT_PUT_REF_AND_RESET(filter_comp_class);
+ bt_object_put_ref(graph);
graph = bt_graph_create();
BT_ASSERT(graph);
graph_ret = bt_graph_add_component(graph, sink_comp_class, "the-sink",
NULL, &sink_component);
ok(graph_ret == BT_GRAPH_STATUS_OK && sink_component,
"bt_graph_add_component() still works after the filter component class object is destroyed");
- BT_PUT(sink_comp_class);
- BT_PUT(sink_component);
+ BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
+ BT_OBJECT_PUT_REF_AND_RESET(sink_component);
free(sfs_path);
- bt_put(graph);
- bt_put(plugin_set);
- bt_put(results);
- bt_put(params);
- bt_put(query_exec);
+ bt_object_put_ref(graph);
+ bt_object_put_ref(plugin_set);
+ bt_object_put_ref(results);
+ bt_object_put_ref(params);
+ bt_object_put_ref(query_exec);
}
static void test_create_all_from_dir(const char *plugin_dir)
bt_plugin_set_get_plugin_count(plugin_set) == 4,
"bt_plugin_create_all_from_dir() returns the expected number of plugin objects");
- bt_put(plugin_set);
+ bt_object_put_ref(plugin_set);
}
static void test_find(const char *plugin_dir)
"bt_plugin_find() succeeds with a plugin name it can find");
ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0,
"bt_plugin_find() finds the correct plugin for a given name");
- BT_PUT(plugin);
+ BT_OBJECT_PUT_REF_AND_RESET(plugin);
comp_cls_sink = bt_plugin_find_component_class(NULL, "sink",
BT_COMPONENT_CLASS_TYPE_SINK);
ok(!comp_cls_sink, "bt_plugin_find_component_class() handles NULL (plugin name)");
ok(comp_cls_sink, "bt_plugin_find_component_class() succeeds with another component class name (same plugin)");
ok(strcmp(bt_component_class_get_name(comp_cls_source), "source") == 0,
"bt_plugin_find_component_class() returns the appropriate component class (source)");
- BT_PUT(comp_cls_sink);
- BT_PUT(comp_cls_source);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_cls_sink);
+ BT_OBJECT_PUT_REF_AND_RESET(comp_cls_source);
free(plugin_path);
}
ret = bt_field_class_structure_append_member(structure,
"payload_32", ui32);
BT_ASSERT(ret == 0);
- BT_PUT(ui8);
- BT_PUT(ui16);
- BT_PUT(ui32);
+ BT_OBJECT_PUT_REF_AND_RESET(ui8);
+ BT_OBJECT_PUT_REF_AND_RESET(ui16);
+ BT_OBJECT_PUT_REF_AND_RESET(ui32);
return structure;
}
ret = bt_ctf_field_type_structure_add_field(structure, ui32,
"payload_32");
BT_ASSERT(ret == 0);
- BT_PUT(ui8);
- BT_PUT(ui16);
- BT_PUT(ui32);
+ BT_OBJECT_PUT_REF_AND_RESET(ui8);
+ BT_OBJECT_PUT_REF_AND_RESET(ui16);
+ BT_OBJECT_PUT_REF_AND_RESET(ui32);
return structure;
}
BT_ASSERT(payload);
ret = bt_event_class_set_payload_field_class(event, payload);
BT_ASSERT(ret == 0);
- BT_PUT(payload);
+ BT_OBJECT_PUT_REF_AND_RESET(payload);
return event;
}
BT_ASSERT(ret == 0);
ret = bt_event_class_set_payload_field_class(event, outer);
BT_ASSERT(ret == 0);
- BT_PUT(inner);
- BT_PUT(outer);
+ BT_OBJECT_PUT_REF_AND_RESET(inner);
+ BT_OBJECT_PUT_REF_AND_RESET(outer);
return event;
}
ret = bt_field_class_structure_append_member(packet_context_type,
"packet_size", fc);
BT_ASSERT(ret == 0);
- bt_put(fc);
+ bt_object_put_ref(fc);
fc = bt_field_class_unsigned_integer_create();
BT_ASSERT(fc);
ret = bt_field_class_integer_set_field_value_range(fc, 32);
ret = bt_field_class_structure_append_member(packet_context_type,
"content_size", fc);
BT_ASSERT(ret == 0);
- bt_put(fc);
+ bt_object_put_ref(fc);
event_header_type = bt_field_class_structure_create();
BT_ASSERT(event_header_type);
fc = bt_field_class_unsigned_integer_create();
ret = bt_field_class_structure_append_member(event_header_type,
"id", fc);
BT_ASSERT(ret == 0);
- bt_put(fc);
+ bt_object_put_ref(fc);
ret = bt_stream_class_set_packet_context_field_class(stream_class,
packet_context_type);
BT_ASSERT(ret == 0);
ret = bt_stream_class_set_event_header_field_class(stream_class,
event_header_type);
BT_ASSERT(ret == 0);
- bt_put(packet_context_type);
- bt_put(event_header_type);
+ bt_object_put_ref(packet_context_type);
+ bt_object_put_ref(event_header_type);
}
static void create_sc1(struct bt_trace *trace)
ok(ret_stream == sc1, "Borrow parent stream SC1 from EC1");
ret_stream = bt_event_class_borrow_stream_class(ec2);
ok(ret_stream == sc1, "Borrow parent stream SC1 from EC2");
- BT_PUT(ec1);
- BT_PUT(ec2);
- BT_PUT(sc1);
+ BT_OBJECT_PUT_REF_AND_RESET(ec1);
+ BT_OBJECT_PUT_REF_AND_RESET(ec2);
+ BT_OBJECT_PUT_REF_AND_RESET(sc1);
}
static void create_sc2(struct bt_trace *trace)
ec3 = create_simple_event(sc2, "ec3");
ret_stream = bt_event_class_borrow_stream_class(ec3);
ok(ret_stream == sc2, "Borrow parent stream SC2 from EC3");
- BT_PUT(ec3);
- BT_PUT(sc2);
+ BT_OBJECT_PUT_REF_AND_RESET(ec3);
+ BT_OBJECT_PUT_REF_AND_RESET(sc2);
}
static void set_trace_packet_header(struct bt_trace *trace)
ret = bt_field_class_structure_append_member(packet_header_type,
"stream_id", fc);
BT_ASSERT(ret == 0);
- bt_put(fc);
+ bt_object_put_ref(fc);
ret = bt_trace_set_packet_header_field_class(trace,
packet_header_type);
BT_ASSERT(ret == 0);
- bt_put(packet_header_type);
+ bt_object_put_ref(packet_header_type);
}
static struct bt_trace *create_tc1(void)
"Initial EC3 reference count is 0");
/* User A has ownership of the trace. */
- BT_MOVE(user_a.tc, tc1);
+ BT_OBJECT_MOVE_REF(user_a.tc, tc1);
ok(bt_object_get_ref_count((void *) user_a.tc) == 1,
"TC1 reference count is 1");
/* User A acquires a reference to SC2 from TC1. */
- user_a.sc = bt_get(bt_trace_borrow_stream_class_by_index(user_a.tc, 1));
+ user_a.sc = bt_object_get_ref(bt_trace_borrow_stream_class_by_index(user_a.tc, 1));
ok(user_a.sc, "User A acquires SC2 from TC1");
ok(bt_object_get_ref_count((void *) weak_tc1) == 2,
"TC1 reference count is 2");
"SC2 reference count is 1");
/* User A acquires a reference to EC3 from SC2. */
- user_a.ec = bt_get(
+ user_a.ec = bt_object_get_ref(
bt_stream_class_borrow_event_class_by_index(user_a.sc, 0));
ok(user_a.ec, "User A acquires EC3 from SC2");
ok(bt_object_get_ref_count((void *) weak_tc1) == 2,
/* User A releases its reference to SC2. */
diag("User A releases SC2");
- BT_PUT(user_a.sc);
+ BT_OBJECT_PUT_REF_AND_RESET(user_a.sc);
/*
* We keep the pointer to SC2 around to validate its reference
* count.
/* User A releases its reference to TC1. */
diag("User A releases TC1");
- BT_PUT(user_a.tc);
+ BT_OBJECT_PUT_REF_AND_RESET(user_a.tc);
/*
* We keep the pointer to TC1 around to validate its reference
* count.
/* User B acquires a reference to SC1. */
diag("User B acquires a reference to SC1");
- user_b.sc = bt_get(weak_sc1);
+ user_b.sc = bt_object_get_ref(weak_sc1);
ok(bt_object_get_ref_count((void *) weak_tc1) == 2,
"TC1 reference count is 2");
ok(bt_object_get_ref_count((void *) weak_sc1) == 1,
/* User C acquires a reference to EC1. */
diag("User C acquires a reference to EC1");
- user_c.ec = bt_get(
+ user_c.ec = bt_object_get_ref(
bt_stream_class_borrow_event_class_by_index(user_b.sc, 0));
ok(bt_object_get_ref_count((void *) weak_ec1) == 1,
"EC1 reference count is 1");
/* User A releases its reference on EC3. */
diag("User A releases its reference on EC3");
- BT_PUT(user_a.ec);
+ BT_OBJECT_PUT_REF_AND_RESET(user_a.ec);
ok(bt_object_get_ref_count((void *) weak_ec3) == 0,
"EC3 reference count is 1");
ok(bt_object_get_ref_count((void *) weak_sc2) == 0,
/* User B releases its reference on SC1. */
diag("User B releases its reference on SC1");
- BT_PUT(user_b.sc);
+ BT_OBJECT_PUT_REF_AND_RESET(user_b.sc);
ok(bt_object_get_ref_count((void *) weak_sc1) == 1,
"SC1 reference count is 1");
"EC3 reference count is 0");
/* Reclaim last reference held by User C. */
- BT_PUT(user_c.ec);
+ BT_OBJECT_PUT_REF_AND_RESET(user_c.ec);
}
static void create_writer_user_full(struct writer_user *user)
BT_ASSERT(!ret);
ret = bt_ctf_stream_class_set_clock(user->sc, clock);
BT_ASSERT(!ret);
- BT_PUT(clock);
+ BT_OBJECT_PUT_REF_AND_RESET(clock);
user->stream = bt_ctf_writer_create_stream(user->writer, user->sc);
BT_ASSERT(user->stream);
user->ec = bt_ctf_event_class_create("ec");
ft = create_writer_integer_struct();
BT_ASSERT(ft);
ret = bt_ctf_event_class_set_payload_field_type(user->ec, ft);
- BT_PUT(ft);
+ BT_OBJECT_PUT_REF_AND_RESET(ft);
BT_ASSERT(!ret);
ret = bt_ctf_stream_class_add_event_class(user->sc, user->ec);
BT_ASSERT(!ret);
BT_ASSERT(field);
ret = bt_ctf_field_integer_unsigned_set_value(field, 10);
BT_ASSERT(!ret);
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
field = bt_ctf_event_get_payload(user->event, "payload_16");
BT_ASSERT(field);
ret = bt_ctf_field_integer_unsigned_set_value(field, 20);
BT_ASSERT(!ret);
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
field = bt_ctf_event_get_payload(user->event, "payload_32");
BT_ASSERT(field);
ret = bt_ctf_field_integer_unsigned_set_value(field, 30);
BT_ASSERT(!ret);
- BT_PUT(field);
+ BT_OBJECT_PUT_REF_AND_RESET(field);
ret = bt_ctf_stream_append_event(user->stream, user->event);
BT_ASSERT(!ret);
recursive_rmdir(trace_path);
void *obj = objects[array[i]];
printf("%s", writer_user_names[array[i]]);
- BT_PUT(obj);
+ BT_OBJECT_PUT_REF_AND_RESET(obj);
if (i < size - 1) {
printf(" -> ");