+ BT_ASSERT(plugin);
+
+ if (plugin->frozen) {
+ return;
+ }
+
+ BT_LOGD("Freezing plugin: addr=%p, name=\"%s\", path=\"%s\"",
+ plugin, bt_plugin_get_name(plugin),
+ bt_plugin_get_path(plugin));
+ plugin->frozen = BT_TRUE;
+}
+
+static
+void bt_plugin_set_destroy(struct bt_object *obj)
+{
+ struct bt_plugin_set *plugin_set =
+ container_of(obj, struct bt_plugin_set, base);
+
+ if (!plugin_set) {
+ return;
+ }
+
+ BT_LOGD("Destroying plugin set: addr=%p", plugin_set);
+
+ if (plugin_set->plugins) {
+ BT_LOGD_STR("Putting plugins.");
+ g_ptr_array_free(plugin_set->plugins, TRUE);
+ }
+
+ g_free(plugin_set);
+}
+
+static inline
+struct bt_plugin_set *bt_plugin_set_create(void)
+{
+ struct bt_plugin_set *plugin_set = g_new0(struct bt_plugin_set, 1);
+
+ if (!plugin_set) {
+ goto end;
+ }
+
+ BT_LOGD_STR("Creating empty plugin set.");
+ bt_object_init(plugin_set, bt_plugin_set_destroy);
+
+ plugin_set->plugins = g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_put);
+ if (!plugin_set->plugins) {
+ BT_LOGE_STR("Failed to allocate a GPtrArray.");
+ BT_PUT(plugin_set);
+ goto end;
+ }
+
+ BT_LOGD("Created empty plugin set: addr=%p", plugin_set);
+
+end:
+ return plugin_set;
+}
+
+static inline
+void bt_plugin_set_add_plugin(struct bt_plugin_set *plugin_set,
+ struct bt_plugin *plugin)
+{
+ BT_ASSERT(plugin_set);
+ BT_ASSERT(plugin);
+ g_ptr_array_add(plugin_set->plugins, bt_get(plugin));
+ BT_LOGV("Added plugin to plugin set: "
+ "plugin-set-addr=%p, plugin-addr=%p, plugin-name=\"%s\", "
+ "plugin-path=\"%s\"",
+ plugin_set, plugin, bt_plugin_get_name(plugin),
+ bt_plugin_get_path(plugin));