Found and fixed a memory leak in the rope strings

Also fixed a bit manipulation error in the GC.
This commit is contained in:
2026-05-10 15:39:04 +10:00
parent 3b813da1cf
commit 83fb5222a2
9 changed files with 124 additions and 6 deletions
+13
View File
@@ -1,5 +1,6 @@
#include "ast_inspector.h"
#include "bytecode_inspector.h"
#include "bucket_inspector.h"
#include "toy_console_colors.h"
@@ -380,14 +381,26 @@ int repl(const char* filepath, bool verbose) {
//run
Toy_runVM(&vm);
int depthBeforeGC = 0;
int depthAfterGC = 0;
//print the debug info
if (verbose) {
debugStackPrint(vm.stack);
debugScopePrint(vm.scope, 0);
depthBeforeGC = inspect_bucket(&vm.memoryBucket);
}
//free the memory, and leave the VM ready for the next loop
Toy_resetVM(&vm, true, true);
if (verbose) {
depthAfterGC = inspect_bucket(&vm.memoryBucket);
printf("GC Report: %d -> %d\n", depthBeforeGC, depthAfterGC);
}
free(bytecode);
printf("%s> ", prompt); //shows the terminal prompt