mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/thread/thread.c (remove_one): Preserve List invariants;
submitted by: MenTaLguY <mental AT rydia.net> in [ruby-core:10598] and [ruby-bugs:PR#9388]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
59aac16283
commit
1bb22ded25
2 changed files with 13 additions and 2 deletions
|
@ -163,13 +163,18 @@ static void
|
|||
remove_one(List *list, VALUE value)
|
||||
{
|
||||
Entry **ref;
|
||||
Entry *prev;
|
||||
Entry *entry;
|
||||
|
||||
for (ref = &list->entries, entry = list->entries;
|
||||
for (ref = &list->entries, prev = NULL, entry = list->entries;
|
||||
entry != NULL;
|
||||
ref = &entry->next, entry = entry->next) {
|
||||
ref = &entry->next, prev = entry, entry = entry->next) {
|
||||
if (entry->value == value) {
|
||||
*ref = entry->next;
|
||||
list->size--;
|
||||
if (!entry->next) {
|
||||
list->last_entry = prev;
|
||||
}
|
||||
recycle_entries(list, entry, entry);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue