g_slist_foreach




This definition of g_slist_foreach is not able to report errors during
execution of the user function.

void
g_slist_foreach (GSList   *list,
		 GFunc     func,
		 gpointer  user_data)
{
  while (list)
    {
      (*func) (list->data, user_data);
      list = list->next;
    }
}

I think it should be changed in this way to be able to catch errors:

gint
g_slist_foreach (GSList   *list,
		 GFunc     func,
		 gpointer  user_data)
{
  gint result;

  while (list)
    {
      result = (*func) (list->data, user_data);
      if (result) return result;
      list = list->next;
    }

  return 0;
}

-- 
/* In the beginning was the Word: */
typedef long SCM;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]