+ et = ltt_facility_eventtype_get_by_name(f, event);
+ if(unlikely(et == NULL)) goto event_error;
+
+ thf = &g_array_index(th->fac_index, LttvTraceHookByFacility, fac_id);
+ g_array_index(th->fac_list, LttvTraceHookByFacility*, 0) = thf;
+
+ ev_id = ltt_eventtype_id(et);
+
+ thf->h = h;
+ thf->id = GET_HOOK_ID(fac_id, ev_id);
+ thf->f1 = find_field(et, field1);
+ thf->f2 = find_field(et, field2);
+ thf->f3 = find_field(et, field3);
+ thf->hook_data = hook_data;
+
+ first_thf = thf;
+ first_et = et;
+
+ /* Check for type compatibility too */
+ for(i=1;i<facilities->len;i++) {
+ fac_id = g_array_index(facilities, guint, i);
+ f = ltt_trace_get_facility_by_num(t, fac_id);
+
+ et = ltt_facility_eventtype_get_by_name(f, event);
+ if(unlikely(et == NULL)) goto event_error;
+
+ thf = &g_array_index(th->fac_index, LttvTraceHookByFacility, fac_id);
+ g_array_index(th->fac_list, LttvTraceHookByFacility*, i) = thf;
+ ev_id = ltt_eventtype_id(et);
+ thf->h = h;
+ thf->id = GET_HOOK_ID(fac_id, ev_id);
+ thf->f1 = find_field(et, field1);
+ if(check_fields_compatibility(first_et, et,
+ first_thf->f1, thf->f1))
+ goto type_error;
+
+ thf->f2 = find_field(et, field2);
+ if(check_fields_compatibility(first_et, et,
+ first_thf->f2, thf->f2))
+ goto type_error;
+
+ thf->f3 = find_field(et, field3);
+ if(check_fields_compatibility(first_et, et,
+ first_thf->f3, thf->f3))
+ goto type_error;
+ thf->hook_data = hook_data;
+ }
+
+ return 0;
+
+type_error:
+ goto free;
+event_error:
+ g_error("Event type does not exist for event %s",
+ g_quark_to_string(event));
+ goto free;
+facility_error:
+ g_error("No %s facility", g_quark_to_string(facility));
+ goto free;
+free:
+ g_array_free(th->fac_index, TRUE);
+ g_array_free(th->fac_list, TRUE);
+ th->fac_index = NULL;
+ th->fac_list = NULL;
+ return -1;
+}
+
+void lttv_trace_hook_destroy(LttvTraceHook *th)
+{
+ g_array_free(th->fac_index, TRUE);
+ g_array_free(th->fac_list, TRUE);