summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-11-09 10:16:15 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-11-09 10:16:15 -0800
commit9aad0d7124ac7693a004a8b189652d1ad727d5c4 (patch)
treef45ba3cb1ac752e744cd53cd93a8809d136e70c0
parent6ac6c3657dc0dbf3c961a96f1f85d2a570ccc8ce (diff)
downloadtxr-9aad0d7124ac7693a004a8b189652d1ad727d5c4.tar.gz
txr-9aad0d7124ac7693a004a8b189652d1ad727d5c4.tar.bz2
txr-9aad0d7124ac7693a004a8b189652d1ad727d5c4.zip
gc: bugfix: maintain tail pointer in new sweep code.
* gc.c (sweep): The new logic for removing a deleted heap's blocks from the free list must correctly maintain free_tail. Whenever a node is deleted which is the tail node, the tail pointer must move to the parent's tail field, or to the free_list pointer. We don't need to do anything afterward for the free_list == 0 case; that is taken care of.
-rw-r--r--gc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index b136143a..3460fb27 100644
--- a/gc.c
+++ b/gc.c
@@ -665,13 +665,12 @@ static int_ptr_t sweep(void)
for (ppf = &free_list; *ppf != nil; ) {
val block = *ppf;
if (block >= heap->block && block < end) {
- *ppf = block->t.next;
+ if ((*ppf = block->t.next) == 0)
+ free_tail = ppf;
} else {
ppf = &block->t.next;
}
}
- if (free_list == 0)
- free_tail = &free_list;
*pph = heap->next;
free(heap);
#if HAVE_VALGRIND