TheThirdOne / rars

RARS -- RISC-V Assembler and Runtime Simulator
Other
1.14k stars 217 forks source link

sbrk problem #200

Closed halvbanan closed 9 months ago

halvbanan commented 9 months ago

i can't see how i can deallocate the memory that i allocated using sbrk ecall, i tried loading a negative number onto a7 and sycall it but it said negative heap amount, this is an unsafe practice because it can give others possibilities for memory leaks

TheThirdOne commented 9 months ago

It is not possible to deallocate with sbrk in RARS. There is not a good way to allocate and deallocate memory like malloc and free. It is possible to make a memory allocator in assembly that provides C like allocation on top of sbrk.