+ goto error_indices_ht;
+ }
+
+ status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
+ goto end;
+
+error_indices_ht:
+ lttng_index_allocator_destroy(state->index_allocator);
+ state->index_allocator = NULL;
+end:
+ return status;
+}
+
+static
+void fini_error_accounting_state(struct error_accounting_state *state)
+{
+ assert(state);
+
+ /*
+ * Will assert if some error counter indices were not released (an
+ * internal error).
+ */
+ lttng_ht_destroy(state->indices_ht);
+ lttng_index_allocator_destroy(state->index_allocator);
+}
+
+enum event_notifier_error_accounting_status
+event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
+ uint64_t buffer_size_ust)
+{
+ enum event_notifier_error_accounting_status status;
+
+ status = init_error_accounting_state(&kernel_state, buffer_size_kernel);
+ if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
+ ERR("Failed to initialize kernel event notifier accounting state: status = %s",
+ error_accounting_status_str(status));
+ goto end;
+ }
+
+ status = init_error_accounting_state(&ust_state, buffer_size_ust);
+ if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
+ ERR("Failed to initialize UST event notifier accounting state: status = %s",
+ error_accounting_status_str(status));
+ goto error_ust_state;