From 0402b625ee727469c040890235f8521a2e23d5c7 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Thu, 3 May 2001 10:47:32 +0000 Subject: [PATCH] Make foreach() safe against removal of the _current_ element. While this Thu May 3 06:38:28 2001 Owen Taylor * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make foreach() safe against removal of the _current_ element. While this could break some code, the new behavior is consistent with the rest of GLib/GTK+ and probably is what people expect in most cases. (Suggested by Paul Kuykendall, #50071) --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-0 | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-12 | 8 ++++++++ ChangeLog.pre-2-2 | 8 ++++++++ ChangeLog.pre-2-4 | 8 ++++++++ ChangeLog.pre-2-6 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ docs/Changes-2.0.txt | 8 +++++++- glib/glist.c | 3 ++- glib/gslist.c | 3 ++- glist.c | 3 ++- gslist.c | 3 ++- 13 files changed, 79 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f12a6e69..a0a1eed2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index f12a6e69..a0a1eed2 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f12a6e69..a0a1eed2 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index f12a6e69..a0a1eed2 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index f12a6e69..a0a1eed2 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f12a6e69..a0a1eed2 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f12a6e69..a0a1eed2 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f12a6e69..a0a1eed2 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Thu May 3 06:38:28 2001 Owen Taylor + + * g[s]list.c (g_[s]list_foreach) docs/Changes-2.0.txt: Make + foreach() safe against removal of the _current_ element. While + this could break some code, the new behavior is consistent with + the rest of GLib/GTK+ and probably is what people expect in most + cases. (Suggested by Paul Kuykendall, #50071) + Wed May 2 11:10:22 2001 Owen Taylor * gutf8.c (g_utf8_to_ucs4_fast): Fix read past end of the string. diff --git a/docs/Changes-2.0.txt b/docs/Changes-2.0.txt index 8bf2819b..13f79b3d 100644 --- a/docs/Changes-2.0.txt +++ b/docs/Changes-2.0.txt @@ -21,4 +21,10 @@ in to the ->dispatch() vfunc. To go along with this change, the vtable for GIOChannel has changed and - add_watch() has been replaced by create_watch(). \ No newline at end of file + add_watch() has been replaced by create_watch(). + +* g_list_foreach() and g_slist_foreach() have been changed so they + are now safe against removal of the current item, not the next item. + + It's not recommended to mutate the list in the callback to these + functions in any case. \ No newline at end of file diff --git a/glib/glist.c b/glib/glist.c index 3518221f..6d9f0dde 100644 --- a/glib/glist.c +++ b/glib/glist.c @@ -617,8 +617,9 @@ g_list_foreach (GList *list, { while (list) { + GList *next = list->next; (*func) (list->data, user_data); - list = list->next; + list = next; } } diff --git a/glib/gslist.c b/glib/gslist.c index 5577fb32..4dafb98b 100644 --- a/glib/gslist.c +++ b/glib/gslist.c @@ -589,8 +589,9 @@ g_slist_foreach (GSList *list, { while (list) { + GSList *next = list->next; (*func) (list->data, user_data); - list = list->next; + list = next; } } diff --git a/glist.c b/glist.c index 3518221f..6d9f0dde 100644 --- a/glist.c +++ b/glist.c @@ -617,8 +617,9 @@ g_list_foreach (GList *list, { while (list) { + GList *next = list->next; (*func) (list->data, user_data); - list = list->next; + list = next; } } diff --git a/gslist.c b/gslist.c index 5577fb32..4dafb98b 100644 --- a/gslist.c +++ b/gslist.c @@ -589,8 +589,9 @@ g_slist_foreach (GSList *list, { while (list) { + GSList *next = list->next; (*func) (list->data, user_data); - list = list->next; + list = next; } } -- 2.34.1