1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-21 01:34:49 +00:00

Make janet_equals and janet_compare non recursive

This makes these operatios use constant stack space rather
than linear stackspace given the size of the inputs. This is important
to prevent certain parser input from causing a stack overflow - in
general, we try to avoid unbounded recursion.
This commit is contained in:
Calvin Rose
2020-04-24 16:18:31 -05:00
parent c335bf5dc5
commit a87015598c
8 changed files with 196 additions and 136 deletions

View File

@@ -1406,6 +1406,10 @@ int janet_init(void) {
janet_vm_abstract_registry = janet_table(0);
janet_gcroot(janet_wrap_table(janet_vm_registry));
janet_gcroot(janet_wrap_table(janet_vm_abstract_registry));
/* Traversal */
janet_vm_traversal = NULL;
janet_vm_traversal_base = NULL;
janet_vm_traversal_top = NULL;
/* Core env */
janet_vm_core_env = NULL;
/* Seed RNG */
@@ -1428,6 +1432,7 @@ void janet_deinit(void) {
janet_vm_registry = NULL;
janet_vm_abstract_registry = NULL;
janet_vm_core_env = NULL;
free(janet_vm_traversal_base);
#ifdef JANET_THREADS
janet_threads_deinit();
#endif