From 4b70dd83c27c589139178db25c9ddb70f24e6192 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 24 Feb 2016 18:17:20 -0500 Subject: [PATCH] Initialize component class init callback MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- include/babeltrace/plugin/component-class-internal.h | 3 ++- lib/plugin-system/component-class.c | 4 +++- lib/plugin-system/component-factory.c | 2 +- lib/plugin-system/component.c | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/babeltrace/plugin/component-class-internal.h b/include/babeltrace/plugin/component-class-internal.h index f23f2566..351e5c06 100644 --- a/include/babeltrace/plugin/component-class-internal.h +++ b/include/babeltrace/plugin/component-class-internal.h @@ -49,6 +49,7 @@ int bt_component_class_init( BT_HIDDEN struct bt_component_class *bt_component_class_create( enum bt_component_type type, const char *name, - const char *description, struct bt_plugin *plugin); + const char *description, bt_component_init_cb init, + struct bt_plugin *plugin); #endif /* BABELTRACE_PLUGIN_COMPONENT_CLASS_INTERNAL_H */ diff --git a/lib/plugin-system/component-class.c b/lib/plugin-system/component-class.c index e0e2e0bf..9f5ccb06 100644 --- a/lib/plugin-system/component-class.c +++ b/lib/plugin-system/component-class.c @@ -52,7 +52,8 @@ void bt_component_class_destroy(struct bt_object *obj) BT_HIDDEN struct bt_component_class *bt_component_class_create( enum bt_component_type type, const char *name, - const char *description, struct bt_plugin *plugin) + const char *description, bt_component_init_cb init, + struct bt_plugin *plugin) { struct bt_component_class *class; @@ -63,6 +64,7 @@ struct bt_component_class *bt_component_class_create( bt_object_init(class, bt_component_class_destroy); class->type = type; + class->init = init; class->name = g_string_new(name); class->description = g_string_new(description); if (!class->name || !class->description) { diff --git a/lib/plugin-system/component-factory.c b/lib/plugin-system/component-factory.c index 0952f461..6601a0a6 100644 --- a/lib/plugin-system/component-factory.c +++ b/lib/plugin-system/component-factory.c @@ -431,7 +431,7 @@ add_component_class(struct bt_component_factory *factory, const char *name, } component_class = bt_component_class_create(type, name, description, - factory->current_plugin); + init, factory->current_plugin); g_ptr_array_add(factory->component_classes, component_class); end: return ret; diff --git a/lib/plugin-system/component.c b/lib/plugin-system/component.c index 667601e1..483788ac 100644 --- a/lib/plugin-system/component.c +++ b/lib/plugin-system/component.c @@ -126,7 +126,7 @@ struct bt_component *bt_component_create( bt_object_init(component, bt_component_destroy); component->class = bt_get(component_class); component->name = g_string_new(name); - if (component->name) { + if (!component->name) { BT_PUT(component); goto end; } -- 2.34.1