- for(i = 0 ; i < h->len ; i++) {
- if(h->pdata[i] != NULL) lttv_hooks_destroy((LttvHooks *)(h->pdata[i]));
+ for(i = 0 ; i < h->array->len ; i++) {
+ guint index = g_array_index(h->array, guint, i);
+ if(h->index->pdata[index] != NULL) { /* hook may have been removed */
+ lttv_hooks_destroy(h->index->pdata[index]);
+ h->index->pdata[index] = NULL; /* Must be there in case of
+ multiple addition of the same index */
+ }