Fix some memory leaks

This commit is contained in:
2026-01-28 14:54:15 -08:00
parent de43dfcda2
commit 76b28c1dc0
8 changed files with 51 additions and 2 deletions
+16
View File
@@ -26,6 +26,21 @@ void lisp_init_stack(void) {
the_stack.nogc_retval = Qnil;
}
static void teardown_stack_frame(struct StackFrame *restrict frame) {
for (size_t i = 0; i < frame->local_refs.num_blocks; ++i) {
lisp_free(frame->local_refs.blocks[i]);
}
lisp_free(frame->local_refs.blocks);
}
void lisp_teardown_stack(void) {
assert(the_stack.depth == 0);
for (size_t i = 0; i < the_stack.max_depth; ++i) {
teardown_stack_frame(&the_stack.frames[i]);
}
lisp_free(the_stack.frames);
}
void push_stack_frame(LispVal *name, LispVal *fobj, LispVal *args) {
assert(the_stack.depth < the_stack.max_depth);
struct StackFrame *frame = &the_stack.frames[the_stack.depth++];
@@ -164,6 +179,7 @@ void add_local_reference(LispVal *obj) {
while ((cur = next_local_reference(&i))) {
add_local_refs_for_object_sub_vals(seen_objs, cur);
}
release_hash_table_no_gc(seen_objs);
}
void compact_stack_frame(struct StackFrame *restrict frame) {