Added valgrind to the CI, fixed tests

This exposed an issue with my dev environment, which I had to patch.

Fixed #153
This commit is contained in:
2024-11-17 18:49:40 +11:00
parent 2f9489d5fd
commit 7398898a61
12 changed files with 63 additions and 25 deletions

View File

@@ -651,12 +651,17 @@ void Toy_bindVMToModule(Toy_VM* vm, unsigned char* module) {
vm->subsAddr = READ_UNSIGNED_INT(vm);
}
//allocate the stack, scope, and memory
vm->stringBucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
vm->scopeBucket = Toy_allocateBucket(TOY_BUCKET_SMALL);
vm->stack = Toy_allocateStack();
//allocate the stack, scope, and memory (skip if already in use)
if (vm->stringBucket == NULL) {
vm->stringBucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
}
if (vm->scopeBucket == NULL) {
vm->scopeBucket = Toy_allocateBucket(TOY_BUCKET_SMALL);
}
if (vm->stack == NULL) {
vm->stack = Toy_allocateStack();
}
if (vm->scope == NULL) {
//only allocate a new top-level scope when needed, otherwise REPL will break
vm->scope = Toy_pushScope(&vm->scopeBucket, NULL);
}
}