Sinks own their input iterators
[babeltrace.git] / lib / plugin-system / component.c
index 5b424cd848bf85725cbc7963f59d2304d8a0c7ef..643e17ad21b3ad909862f556d35aae55e00fbff8 100644 (file)
@@ -66,7 +66,7 @@ void bt_component_destroy(struct bt_object *obj)
         * instance.
         */
        if (component->user_destroy) {
-               component->user_destroy(component->user_data);
+               component->user_destroy(component);
        }
 
        if (component->destroy) {
@@ -131,9 +131,11 @@ struct bt_component *bt_component_create(
                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;
        }
@@ -186,7 +188,7 @@ bt_component_set_private_data(struct bt_component *component,
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
-       if (!component) {
+       if (!component || !component->initializing) {
                ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
@@ -195,3 +197,18 @@ bt_component_set_private_data(struct bt_component *component,
 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;
+}
This page took 0.02445 seconds and 4 git commands to generate.