- guint i, fac_id, ev_id;
-
- LttvTraceHookByFacility *thf, *first_thf;
-
- facilities = ltt_trace_facility_get_by_name(t, facility);
-
- if(unlikely(facilities == NULL)) goto facility_error;
-
- th->fac_index = g_array_sized_new(FALSE, TRUE,
- sizeof(LttvTraceHookByFacility),
- NUM_FACILITIES);
- th->fac_index = g_array_set_size(th->fac_index, NUM_FACILITIES);
-
- th->fac_list = g_array_sized_new(FALSE, TRUE,
- sizeof(LttvTraceHookByFacility*),
- facilities->len);
- th->fac_list = g_array_set_size(th->fac_list, facilities->len);
-
- fac_id = g_array_index(facilities, guint, 0);
- 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*, 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;