1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-16 18:29:56 +00:00

More fixups to gc.c

This commit is contained in:
Calvin Rose 2023-09-24 11:51:22 -07:00
parent 018f4e0891
commit 5dd18bac2c

View File

@ -53,11 +53,6 @@ void janet_gcpressure(size_t s) {
janet_vm.next_collection += s; janet_vm.next_collection += s;
} }
/* Instrment freed memory for simple use after free detection. */
static void gc_free_gcobj(JanetGCObject *mem) {
janet_free(mem);
}
/* Mark a value */ /* Mark a value */
void janet_mark(Janet x) { void janet_mark(Janet x) {
if (depth) { if (depth) {
@ -344,12 +339,13 @@ void janet_sweep() {
current->flags &= ~JANET_MEM_REACHABLE; current->flags &= ~JANET_MEM_REACHABLE;
} else { } else {
janet_vm.block_count--; janet_vm.block_count--;
janet_deinit_block(current);
if (NULL != previous) { if (NULL != previous) {
previous->data.next = next; previous->data.next = next;
} else { } else {
janet_vm.blocks = next; janet_vm.blocks = next;
} }
gc_free_gcobj(current); janet_free(current);
} }
current = next; current = next;
} }
@ -375,7 +371,7 @@ void janet_sweep() {
janet_assert(!head->type->gc(head->data, head->size), "finalizer failed"); janet_assert(!head->type->gc(head->data, head->size), "finalizer failed");
} }
/* Free memory */ /* Free memory */
gc_free_gcobj(janet_abstract_head(abst)); janet_free(janet_abstract_head(abst));
} }
/* Mark as tombstone in place */ /* Mark as tombstone in place */
@ -550,7 +546,7 @@ void janet_clear_memory(void) {
while (NULL != current) { while (NULL != current) {
janet_deinit_block(current); janet_deinit_block(current);
JanetGCObject *next = current->data.next; JanetGCObject *next = current->data.next;
gc_free_gcobj(current); janet_free(current);
current = next; current = next;
} }
janet_vm.blocks = NULL; janet_vm.blocks = NULL;