lib/plugin/plugin-so.c: add logging
[babeltrace.git] / python-plugin-provider / python-plugin-provider.c
index c7727f21020cbfddc4977b4c93e9872ee0f78ad6..025da46d3762e53a3f63db0b7ee779bac2b66597 100644 (file)
@@ -24,6 +24,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "PLUGIN-PY"
+#include <babeltrace/lib-logging-internal.h>
+
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/ref.h>
@@ -345,9 +348,10 @@ end:
 }
 
 G_MODULE_EXPORT
-struct bt_plugin **bt_plugin_python_create_all_from_file(const char *path)
+struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path)
 {
-       struct bt_plugin **plugins = NULL;
+       struct bt_plugin_set *plugin_set = NULL;
+       struct bt_plugin *plugin = NULL;
        PyObject *py_plugin_info = NULL;
        gchar *basename = NULL;
        size_t path_len;
@@ -422,33 +426,27 @@ struct bt_plugin **bt_plugin_python_create_all_from_file(const char *path)
 
        /*
         * Get bt_plugin from plugin info object.
-        *
-        * calloc(2, ...) because a single Python plugin file always
-        * provides a single Babeltrace plugin (second item is the
-        * sentinel).
         */
-       plugins = calloc(2, sizeof(*plugins));
-       if (!plugins) {
+       plugin = bt_plugin_from_python_plugin_info(py_plugin_info);
+       if (!plugin) {
                goto error;
        }
 
-       plugins[0] = bt_plugin_from_python_plugin_info(py_plugin_info);
-       if (!plugins[0]) {
+       bt_plugin_set_path(plugin, path);
+       plugin_set = bt_plugin_set_create();
+       if (!plugin_set) {
                goto error;
        }
 
-       bt_plugin_set_path(plugins[0], path);
+       bt_plugin_set_add_plugin(plugin_set, plugin);
        goto end;
 
 error:
-       if (plugins) {
-               BT_PUT(plugins[0]);
-               free(plugins);
-               plugins = NULL;
-       }
+       BT_PUT(plugin_set);
 
 end:
+       bt_put(plugin);
        Py_XDECREF(py_plugin_info);
        g_free(basename);
-       return plugins;
+       return plugin_set;
 }
This page took 0.023862 seconds and 4 git commands to generate.