if (auto_source_discovery_restrict_plugin_name) {
plugin_count = 1;
- plugin = find_loaded_plugin(auto_source_discovery_restrict_plugin_name);
+ plugin = borrow_loaded_plugin_by_name(auto_source_discovery_restrict_plugin_name);
plugins = &plugin;
} else {
plugin_count = get_loaded_plugins_count();
g_ptr_array_free(loaded_plugins, TRUE);
}
-const bt_plugin *find_loaded_plugin(const char *name)
+const bt_plugin *borrow_loaded_plugin_by_name(const char *name)
{
int i;
const bt_plugin *plugin = NULL;
BT_LOGI("Cannot find plugin: name=\"%s\"", name);
}
- bt_plugin_get_ref(plugin);
return plugin;
}
return (const bt_plugin **) loaded_plugins->pdata;
}
-const bt_plugin *borrow_loaded_plugin(size_t index)
+const bt_plugin *borrow_loaded_plugin_by_index(size_t index)
{
BT_ASSERT(index < loaded_plugins->len);
return g_ptr_array_index(loaded_plugins, index);
const bt_plugin *plugin =
bt_plugin_set_borrow_plugin_by_index_const(plugin_set, i);
const bt_plugin *loaded_plugin =
- find_loaded_plugin(bt_plugin_get_name(plugin));
+ borrow_loaded_plugin_by_name(bt_plugin_get_name(plugin));
BT_ASSERT(plugin);
bt_plugin_get_name(plugin),
bt_plugin_get_path(plugin),
bt_plugin_get_path(loaded_plugin));
- bt_plugin_put_ref(loaded_plugin);
} else {
/* Add to global array. */
BT_LOGD("Adding plugin to loaded plugins: plugin-path=\"%s\"",
BT_HIDDEN int require_loaded_plugins(const bt_value *plugin_paths);
-BT_HIDDEN const bt_plugin *find_loaded_plugin(const char *name);
BT_HIDDEN size_t get_loaded_plugins_count(void);
BT_HIDDEN const bt_plugin **borrow_loaded_plugins(void);
-BT_HIDDEN const bt_plugin *borrow_loaded_plugin(size_t index);
+BT_HIDDEN const bt_plugin *borrow_loaded_plugin_by_index(size_t index);
+BT_HIDDEN const bt_plugin *borrow_loaded_plugin_by_name(const char *name);
+
#endif /* CLI_BABELTRACE_PLUGINS_H */
BT_LOGI("Finding component class: plugin-name=\"%s\", "
"comp-cls-name=\"%s\"", plugin_name, comp_class_name);
- plugin = find_loaded_plugin(plugin_name);
+ plugin = borrow_loaded_plugin_by_name(plugin_name);
if (!plugin) {
goto end;
}
comp_class = plugin_borrow_comp_cls_func(plugin, comp_class_name);
bt_object_get_ref(comp_class);
- BT_PLUGIN_PUT_REF_AND_RESET(plugin);
end:
if (comp_class) {
const bt_plugin *plugin = NULL;
const bt_component_class *needed_comp_cls = NULL;
- plugin = find_loaded_plugin(cfg->cmd_data.help.cfg_component->plugin_name->str);
+ plugin = borrow_loaded_plugin_by_name(cfg->cmd_data.help.cfg_component->plugin_name->str);
if (!plugin) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find plugin: plugin-name=\"%s\"",
end:
bt_component_class_put_ref(needed_comp_cls);
- bt_plugin_put_ref(plugin);
return cmd_status;
}
}
for (i = 0; i < plugins_count; i++) {
- const bt_plugin *plugin = borrow_loaded_plugin(i);
+ const bt_plugin *plugin = borrow_loaded_plugin_by_index(i);
component_classes_count +=
bt_plugin_get_source_component_class_count(plugin) +
bt_common_color_reset());
for (i = 0; i < plugins_count; i++) {
- const bt_plugin *plugin = borrow_loaded_plugin(i);
+ const bt_plugin *plugin = borrow_loaded_plugin_by_index(i);
printf("\n");
print_plugin_info(plugin);