From e2692a589aa868d39468864b27890747088a8f38 Mon Sep 17 00:00:00 2001 From: Andre Wagner Date: Sun, 17 May 2026 06:29:25 -0500 Subject: [PATCH] . --- .idea/tyche.iml | 2 ++ lib/code.c | 4 ++-- lib/vm.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .idea/tyche.iml diff --git a/.idea/tyche.iml b/.idea/tyche.iml new file mode 100644 index 0000000..9f4c130 --- /dev/null +++ b/.idea/tyche.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/lib/code.c b/lib/code.c index 93e7123..6cc422d 100644 --- a/lib/code.c +++ b/lib/code.c @@ -67,7 +67,7 @@ TYC_RESULT code_load_bytecode(Code* code, uint8_t const* bytecode, size_t byteco */ uint32_t n_consts = code_n_consts(code); - code->const_addr = calloc(n_consts, sizeof(uint32_t)); + code->const_addr = xcalloc(n_consts, sizeof(uint32_t)); uint32_t addr = CONST_START; for (size_t i = 0; i < n_consts; ++i) { code->const_addr[i] = addr; @@ -90,7 +90,7 @@ TYC_RESULT code_load_bytecode(Code* code, uint8_t const* bytecode, size_t byteco memcpy(&code->fn_count, &bytecode[addr], sizeof(uint32_t)); // number of functions addr += 4; - code->fn_addr = calloc(code->fn_count, sizeof(uint32_t)); + code->fn_addr = xcalloc(code->fn_count, sizeof(uint32_t)); code->fn_addr[0] = addr; for (size_t i = 1; i < code->fn_count; ++i) { uint32_t addr_next; diff --git a/lib/vm.c b/lib/vm.c index efe769d..201b772 100644 --- a/lib/vm.c +++ b/lib/vm.c @@ -105,7 +105,7 @@ static TYC_RESULT enter_function(TycheVM* T, uint16_t n_pars) TYC_RESULT r; // get parameters - VALUE params[n_pars + 1]; + VALUE* params = xcalloc(n_pars + 1, sizeof(VALUE)); for (uint16_t i = 0; i < n_pars; ++i) TRY(stack_pop(T->stack, ¶ms[i])) @@ -123,6 +123,7 @@ static TYC_RESULT enter_function(TycheVM* T, uint16_t n_pars) for (int i = n_pars-1; i >= 0; --i) TRY(stack_push(T->stack, params[i])) + free(params); return T_OK; }