Remove bt_component_set_name()
[babeltrace.git] / lib / graph / component.c
index c541985b3326b52f374829f877ba162f3aa835db..5e6a3303a1aa955770f0ddb4ab8117fb81d3490c 100644 (file)
@@ -78,6 +78,16 @@ void bt_component_destroy(struct bt_object *obj)
                return;
        }
 
+       /*
+        * The component's reference count is 0 if we're here. Increment
+        * it to avoid a double-destroy (possibly infinitely recursive).
+        * This could happen for example if the component's finalization
+        * function does bt_get() (or anything that causes bt_get() to
+        * be called) on itself (ref. count goes from 0 to 1), and then
+        * bt_put(): the reference count would go from 1 to 0 again and
+        * this function would be called again.
+        */
+       obj->ref_count.count++;
        component = container_of(obj, struct bt_component, base);
 
        /* Call destroy listeners in reverse registration order */
@@ -320,21 +330,6 @@ end:
        return ret;
 }
 
-enum bt_component_status bt_component_set_name(struct bt_component *component,
-               const char *name)
-{
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-
-       if (!component || !name || name[0] == '\0') {
-               ret = BT_COMPONENT_STATUS_INVALID;
-               goto end;
-       }
-
-       g_string_assign(component->name, name);
-end:
-       return ret;
-}
-
 struct bt_component_class *bt_component_get_class(
                struct bt_component *component)
 {
This page took 0.023678 seconds and 4 git commands to generate.