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