+
+BT_HIDDEN
+void bt_component_add_destroy_listener(struct bt_component *component,
+ bt_component_destroy_listener_func func, void *data)
+{
+ struct bt_component_destroy_listener listener;
+
+ assert(component);
+ assert(func);
+ listener.func = func;
+ listener.data = data;
+ g_array_append_val(component->destroy_listeners, listener);
+ BT_LOGV("Added destroy listener: "
+ "comp-addr=%p, comp-name=\"%s\", "
+ "func-addr=%p, data-addr=%p",
+ component, bt_component_get_name(component),
+ func, data);
+}
+
+BT_HIDDEN
+void bt_component_remove_destroy_listener(struct bt_component *component,
+ bt_component_destroy_listener_func func, void *data)
+{
+ size_t i;
+
+ assert(component);
+ assert(func);
+
+ for (i = 0; i < component->destroy_listeners->len; i++) {
+ struct bt_component_destroy_listener *listener =
+ &g_array_index(component->destroy_listeners,
+ struct bt_component_destroy_listener, i);
+
+ if (listener->func == func && listener->data == data) {
+ g_array_remove_index(component->destroy_listeners, i);
+ i--;
+ BT_LOGV("Removed destroy listener: "
+ "comp-addr=%p, comp-name=\"%s\", "
+ "func-addr=%p, data-addr=%p",
+ component, bt_component_get_name(component),
+ func, data);
+ }
+ }
+}