g_slist_foreach and g_list_foreach functions
- From: "Kuykendall, PR Paul (8807)" <KUYKENDAPR raytheon com>
- To: "'gtk-devel-list gnome org'" <gtk-devel-list gnome org>
- Cc: "Ray, TD Travis (8878)" <RAYTD raytheon com>
- Subject: g_slist_foreach and g_list_foreach functions
- Date: Wed, 13 Sep 2000 14:00:17 -0500
Hello,
I ran across a situation where the g_*list_foreach() functions quit
processing before finishing through the list.
In the case of a function being called by g_*list_foreach() that removes the
current list element (via g_slist_remove() ), processing stops, due to the
node being freed. The small fix below seems to fix that problem, with a
minimal of effort. Sorry it isn't in diff format, but my that machine isn't
networked.
Any reason why this type of fix couldn't be added?
Paul Kuykendall
void
g_slist_foreach (GSList *list,
GFunc func,
gpointer user_data)
{
GSList *nextptr = NULL; /* ADD: */
while (list)
{
nextptr = list->next; /* ADD: */
(*func) (list->data, user_data);
/* REMOVE: list = list->next; */
list = nextptr; /* ADD: */
}
}
-----
Paul Ryan Kuykendall, Software Engineer
kuykendapr gvl esys com 903-457-8807
Raytheon Company -- Aircraft Integration Systems
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]