/* Returns: the next valid #GHook, or NULL if none are valid  */
GHook* g_hook_next_valid(GHookList *hook_list, GHook *hook, gboolean may_be_in_call)
/* Returns: the next valid #GHook, or NULL if none are valid  */
GHook* g_hook_next_valid(GHookList *hook_list, GHook *hook, gboolean may_be_in_call)
{
  GHook *ohook = hook;
  g_return_val_if_fail (hook_list != NULL, NULL);
  if (!hook)
    return NULL;
  hook = hook->next;
  while (hook)
    {
      if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
	{
	  g_hook_ref (hook_list, hook);
	  g_hook_unref (hook_list, ohook);
	  return hook;
	}
      hook = hook->next;
    }
  g_hook_unref (hook_list, ohook);
  return NULL;
}