+gboolean lttv_hooks_call_merge(LttvHooks *h1, void *call_data1,
+ LttvHooks *h2, void *call_data2)
+{
+ gboolean ret, sum_ret = FALSE;
+
+ LttvHookClosure *c1, *c2;
+
+ guint i, j;
+
+ if(h1 != NULL && h2 != NULL) {
+ for(i = 0, j = 0 ; i < h1->len && j < h2->len ;) {
+ c1 = &g_array_index(h1, LttvHookClosure, i);
+ c2 = &g_array_index(h2, LttvHookClosure, j);
+ if(c1->prio <= c2->prio) {
+ ret = c1->hook(c1->hook_data,call_data1);
+ sum_ret = sum_ret || ret;
+ i++;
+ }
+ else {
+ ret = c2->hook(c2->hook_data,call_data2);
+ sum_ret = sum_ret || ret;
+ j++;
+ }
+ }
+ /* Finish the last list with hooks left */
+ for(;i < h1->len; i++) {
+ c1 = &g_array_index(h1, LttvHookClosure, i);
+ ret = c1->hook(c1->hook_data,call_data1);
+ sum_ret = sum_ret || ret;
+ }
+ for(;j < h2->len; j++) {
+ c2 = &g_array_index(h2, LttvHookClosure, j);
+ ret = c2->hook(c2->hook_data,call_data2);
+ sum_ret = sum_ret || ret;
+ }
+ }
+ else if(h1 != NULL && h2 == NULL) {
+ for(i = 0 ; i < h1->len ; i++) {
+ c1 = &g_array_index(h1, LttvHookClosure, i);
+ ret = c1->hook(c1->hook_data,call_data1);
+ sum_ret = sum_ret || ret;
+ }
+ }
+ else if(h1 == NULL && h2 != NULL) {
+ for(j = 0 ; j < h2->len ; j++) {
+ c2 = &g_array_index(h2, LttvHookClosure, j);
+ ret = c2->hook(c2->hook_data,call_data2);
+ sum_ret = sum_ret || ret;
+ }
+ }
+
+ return sum_ret;
+}
+
+gboolean lttv_hooks_call_check_merge(LttvHooks *h1, void *call_data1,
+ LttvHooks *h2, void *call_data2)
+{
+ LttvHookClosure *c1, *c2;
+
+ guint i, j;
+
+ if(h1 != NULL && h2 != NULL) {
+ for(i = 0, j = 0 ; i < h1->len && j < h2->len ;) {
+ c1 = &g_array_index(h1, LttvHookClosure, i);
+ c2 = &g_array_index(h2, LttvHookClosure, j);
+ if(c1->prio <= c2->prio) {
+ if(c1->hook(c1->hook_data,call_data1)) return TRUE;
+ i++;
+ }
+ else {
+ if(c2->hook(c2->hook_data,call_data2)) return TRUE;
+ j++;
+ }
+ }
+ /* Finish the last list with hooks left */
+ for(;i < h1->len; i++) {
+ c1 = &g_array_index(h1, LttvHookClosure, i);
+ if(c1->hook(c1->hook_data,call_data1)) return TRUE;
+ }
+ for(;j < h2->len; j++) {
+ c2 = &g_array_index(h2, LttvHookClosure, j);
+ if(c2->hook(c2->hook_data,call_data2)) return TRUE;
+ }
+ }
+ else if(h1 != NULL && h2 == NULL) {
+ for(i = 0 ; i < h1->len ; i++) {
+ c1 = &g_array_index(h1, LttvHookClosure, i);
+ if(c1->hook(c1->hook_data,call_data1)) return TRUE;
+ }
+ }
+ else if(h1 == NULL && h2 != NULL) {
+ for(j = 0 ; j < h2->len ; j++) {
+ c2 = &g_array_index(h2, LttvHookClosure, j);
+ if(c2->hook(c2->hook_data,call_data2)) return TRUE;
+ }
+ }
+
+ return FALSE;
+
+}
+