From: Jérémie Galarneau Date: Wed, 24 Feb 2016 23:17:20 +0000 (-0500) Subject: Initialize component class init callback X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=4b70dd83c27c589139178db25c9ddb70f24e6192;p=deliverable%2Fbabeltrace.git Initialize component class init callback Signed-off-by: Jérémie Galarneau --- diff --git a/include/babeltrace/plugin/component-class-internal.h b/include/babeltrace/plugin/component-class-internal.h index f23f25667..351e5c06b 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 e0e2e0bf2..9f5ccb063 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 0952f4615..6601a0a61 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 667601e1b..483788acd 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; }