1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-22 10:14:49 +00:00

Garbage collection no longer blows stack.

This commit is contained in:
Calvin Rose
2018-09-22 14:59:50 -04:00
parent 486ce6bc81
commit d9752a9028
3 changed files with 58 additions and 55 deletions

View File

@@ -1335,10 +1335,11 @@ int janet_init(void) {
* there are no memory bugs during development */
janet_vm_gc_interval = 0x1000000;
janet_symcache_init();
/* Initialize gc roots */
janet_vm_roots = NULL;
janet_vm_root_count = 0;
janet_vm_root_capacity = 0;
/* Initialize gc list */
janet_vm_gc_marklist = NULL;
janet_vm_gc_marklist_count = 0;
janet_vm_gc_marklist_capacity = 0;
janet_vm_gc_marklist_rootcount = 0;
/* Initialize registry */
janet_vm_registry = janet_table(0);
janet_gcroot(janet_wrap_table(janet_vm_registry));
@@ -1349,9 +1350,7 @@ int janet_init(void) {
void janet_deinit(void) {
janet_clear_memory();
janet_symcache_deinit();
free(janet_vm_roots);
janet_vm_roots = NULL;
janet_vm_root_count = 0;
janet_vm_root_capacity = 0;
free(janet_vm_gc_marklist);
janet_vm_gc_marklist = NULL;
janet_vm_registry = NULL;
}