* instance.
*/
if (component->user_destroy) {
- component->user_destroy(component->user_data);
+ component->user_destroy(component);
}
if (component->destroy) {
goto end;
}
+ component->initializing = true;
component_class->init(component, params);
+ component->initializing = false;
ret = component_validation_funcs[type](component);
- if (ret) {
+ if (ret != BT_COMPONENT_STATUS_OK) {
BT_PUT(component);
goto end;
}
{
enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
- if (!component) {
+ if (!component || !component->initializing) {
ret = BT_COMPONENT_STATUS_INVALID;
goto end;
}
end:
return ret;
}
+
+enum bt_component_status bt_component_set_destroy_cb(
+ struct bt_component *component, bt_component_destroy_cb destroy)
+{
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component || !component->initializing) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ component->user_destroy = destroy;
+end:
+ return ret;
+}