X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttv%2Flttv%2Fhook.c;h=841996bd82885057d1bc3c063fa07273835aa7ff;hb=d04fa8383cb80eb3c8397edc0134e301f8f7a882;hp=62918cd5e0a321f67f638e995ec09497a5a9415e;hpb=7a4bdb546094fea3343bfc80e3744ea26a08dd22;p=lttv.git diff --git a/lttv/lttv/hook.c b/lttv/lttv/hook.c index 62918cd5..841996bd 100644 --- a/lttv/lttv/hook.c +++ b/lttv/lttv/hook.c @@ -21,8 +21,7 @@ #endif #include -#include -#include +#include typedef struct _LttvHookClosure { LttvHook hook; @@ -193,19 +192,23 @@ void lttv_hooks_remove_data(LttvHooks *h, LttvHook f, void *hook_data) } -void lttv_hooks_remove_list(LttvHooks *h, LttvHooks *list) +void lttv_hooks_remove_list(LttvHooks *h, const LttvHooks *list) { guint i, j; LttvHookClosure *c, *c_list; if(list == NULL) return; + g_assert(h != list); + /* This iteration assume that both list are in the same order */ for(i = 0, j = 0 ; i < h->len && j < list->len ;) { c = &g_array_index(h, LttvHookClosure, i); c_list = &g_array_index(list, LttvHookClosure, j); if(c->hook == c_list->hook && c->hook_data == c_list->hook_data) { if(c->ref_count == 1) { + int count = h->len; lttv_hooks_remove_by_position(h, i); + g_assert((count-1) == h->len); } else { g_assert(c->ref_count != 0); c->ref_count--; @@ -394,3 +397,20 @@ gboolean lttv_hooks_call_check_merge(LttvHooks *h1, void *call_data1, return FALSE; } + + +void lttv_hooks_print(const LttvHooks *h) +{ + LttvHookClosure *c; + + guint i; + + if(likely(h != NULL)) { + for(i = 0 ; i < h->len ; i++) { + c = &g_array_index(h, LttvHookClosure, i); + printf("%p:%i:%i,", c->hook, c->ref_count, c->prio); + } + printf("\n"); + } + +}