#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
+#include <babeltrace/types.h>
#include <stdint.h>
static
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 */
goto end;
}
- component->initializing = true;
+ component->initializing = BT_TRUE;
if (component_class->methods.init) {
ret = component_class->methods.init(
bt_private_component_from_component(component), params,
init_method_data);
- component->initializing = false;
+ component->initializing = BT_FALSE;
if (ret != BT_COMPONENT_STATUS_OK) {
BT_PUT(component);
goto end;
}
}
- component->initializing = false;
+ component->initializing = BT_FALSE;
ret = component_validation_funcs[type](component);
if (ret != BT_COMPONENT_STATUS_OK) {
BT_PUT(component);