lib: make the "port connected" method return a status
[babeltrace.git] / lib / graph / component.c
index 1c83b4b37bfd6ddf380fef35e389baee57e04bbb..9fa449db7ddcdf8a689cdff7df14713a0f1a628b 100644 (file)
@@ -86,7 +86,7 @@ void bt_component_destroy(struct bt_object *obj)
         * bt_put(): the reference count would go from 1 to 0 again and
         * this function would be called again.
         */
-       obj->ref_count.count++;
+       obj->ref_count++;
        component = container_of(obj, struct bt_component, base);
        BT_LOGD("Destroying component: addr=%p, name=\"%s\", graph-addr=%p",
                component, bt_component_get_name(component),
@@ -144,10 +144,10 @@ void bt_component_destroy(struct bt_object *obj)
        g_free(component);
 }
 
-struct bt_component *bt_component_from_private(
+struct bt_component *bt_component_borrow_from_private(
                struct bt_private_component *private_component)
 {
-       return bt_get(bt_component_borrow_from_private(private_component));
+       return (void *) private_component;
 }
 
 enum bt_component_class_type bt_component_get_class_type(
@@ -266,7 +266,8 @@ enum bt_component_status bt_component_create(
                goto end;
        }
 
-       bt_object_init(component, bt_component_destroy);
+       bt_object_init_shared_with_parent(&component->base,
+               bt_component_destroy);
        component->class = bt_get(component_class);
        component->destroy = component_destroy_funcs[type];
        component->name = g_string_new(name);
@@ -277,7 +278,7 @@ enum bt_component_status bt_component_create(
        }
 
        component->input_ports = g_ptr_array_new_with_free_func(
-               bt_object_release);
+               (GDestroyNotify) bt_object_try_spec_release);
        if (!component->input_ports) {
                BT_LOGE_STR("Failed to allocate one GPtrArray.");
                status = BT_COMPONENT_STATUS_NOMEM;
@@ -285,7 +286,7 @@ enum bt_component_status bt_component_create(
        }
 
        component->output_ports = g_ptr_array_new_with_free_func(
-               bt_object_release);
+               (GDestroyNotify) bt_object_try_spec_release);
        if (!component->output_ports) {
                BT_LOGE_STR("Failed to allocate one GPtrArray.");
                status = BT_COMPONENT_STATUS_NOMEM;
@@ -368,13 +369,13 @@ BT_HIDDEN
 void bt_component_set_graph(struct bt_component *component,
                struct bt_graph *graph)
 {
-       bt_object_set_parent(component, graph ? &graph->base : NULL);
+       bt_object_set_parent(&component->base,
+               graph ? &graph->base : NULL);
 }
 
-struct bt_graph *bt_component_get_graph(
-               struct bt_component *component)
+struct bt_graph *bt_component_borrow_graph(struct bt_component *component)
 {
-       return (struct bt_graph *) bt_object_get_parent(&component->base);
+       return (struct bt_graph *) bt_object_borrow_parent(&component->base);
 }
 
 static
@@ -600,9 +601,11 @@ enum bt_component_status bt_component_accept_port_connection(
 }
 
 BT_HIDDEN
-void bt_component_port_connected(struct bt_component *comp,
+enum bt_component_status bt_component_port_connected(struct bt_component *comp,
                struct bt_port *self_port, struct bt_port *other_port)
 {
+       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+
        BT_ASSERT(comp);
        BT_ASSERT(self_port);
        BT_ASSERT(other_port);
@@ -615,10 +618,12 @@ void bt_component_port_connected(struct bt_component *comp,
                        comp, bt_component_get_name(comp),
                        self_port, bt_port_get_name(self_port),
                        other_port, bt_port_get_name(other_port));
-               comp->class->methods.port_connected(
+               status = comp->class->methods.port_connected(
                        bt_private_component_from_component(comp),
                        bt_private_port_from_port(self_port), other_port);
        }
+
+       return status;
 }
 
 BT_HIDDEN
This page took 0.031391 seconds and 4 git commands to generate.