Add ctf fs iterator initialization
[babeltrace.git] / lib / plugin-system / component.c
index 5cfbbf0e3403e9d2d7f87b4f562864a04e168c66..b580bb5d0ae89acc2acd433ce23dab643dbe1f87 100644 (file)
@@ -59,8 +59,6 @@ void bt_component_destroy(struct bt_object *obj)
        }
 
        component = container_of(obj, struct bt_component, base);
-
-       assert(component->destroy);
        component_class = component->class;
 
        /*
@@ -68,10 +66,13 @@ 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) {
+               component->destroy(component);
        }
 
-       component->destroy(component);
        g_string_free(component->name, TRUE);
        bt_put(component_class);
        g_free(component);
@@ -83,8 +84,8 @@ enum bt_component_status bt_component_init(struct bt_component *component,
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
-       if (!component || !destroy) {
-               ret = BT_COMPONENT_STATUS_INVAL;
+       if (!component) {
+               ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
 
@@ -124,16 +125,15 @@ 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;
        }
 
        component_class->init(component, params);
        ret = component_validation_funcs[type](component);
-       if (ret) {
+       if (ret != BT_COMPONENT_STATUS_OK) {
                BT_PUT(component);
                goto end;
        }
@@ -160,7 +160,7 @@ enum bt_component_status bt_component_set_name(struct bt_component *component,
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
        if (!component || !name || name[0] == '\0') {
-               ret = BT_COMPONENT_STATUS_INVAL;
+               ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
 
@@ -175,38 +175,38 @@ struct bt_component_class *bt_component_get_class(
        return component ? bt_get(component->class) : NULL;
 }
 
-enum bt_component_status bt_component_set_error_stream(
-               struct bt_component *component, FILE *stream)
+void *bt_component_get_private_data(struct bt_component *component)
+{
+       return component ? component->user_data : NULL;
+}
+
+enum bt_component_status
+bt_component_set_private_data(struct bt_component *component,
+               void *data)
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
        if (!component) {
-               ret = BT_COMPONENT_STATUS_INVAL;
+               ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
 
-       component->error_stream = stream;
+       component->user_data = data;
 end:
        return ret;
 }
 
-void *bt_component_get_private_data(struct bt_component *component)
-{
-       return component ? component->user_data : NULL;
-}
-
-enum bt_component_status
-bt_component_set_private_data(struct bt_component *component,
-               void *data)
+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) {
-               ret = BT_COMPONENT_STATUS_INVAL;
+               ret = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
 
-       component->user_data = data;
+       component->user_destroy = destroy;
 end:
        return ret;
 }
This page took 0.029598 seconds and 4 git commands to generate.