Correct doubly-linked list management logic; bug exposed during conversation on issue #106.

This commit is contained in:
Graydon Hoare 2010-07-12 13:11:58 -07:00
parent 314b906679
commit 7c837b8c9b
1 changed files with 4 additions and 0 deletions

View File

@ -423,6 +423,8 @@ rust_task::link_gc(gc_alloc *gcm) {
gcm->prev = NULL;
gcm->next = gc_alloc_chain;
gc_alloc_chain = gcm;
if (gcm->next)
gcm->next->prev = gcm;
}
void
@ -431,6 +433,8 @@ rust_task::unlink_gc(gc_alloc *gcm) {
gcm->prev->next = gcm->next;
if (gcm->next)
gcm->next->prev = gcm->prev;
if (gc_alloc_chain == gcm)
gc_alloc_chain = gcm->next;
gcm->prev = NULL;
gcm->next = NULL;
}