munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.88k stars 1.04k forks source link

Fixed memory leaking and added exit... #1061

Closed singul4ri7y closed 2 years ago

singul4ri7y commented 2 years ago

Fixed memory leaking on errors, which may occur horrendous memory errors. Added ".exit" on REPL mode to exit.

mcfriend99 commented 2 years ago

I think this is a good addition to the code. For consistency, you should make corresponding changes in the book and site.

munificent commented 2 years ago

I don't think there's much value in freeing memory immediately before aborting the process. The OS is going to free everything anyway at that point. :)

In a larger program I might do that anyway out of a sense of cleanliness, but in the code for the book, I try to keep things as short and simple as possible since every line of code has to be explained.

singul4ri7y commented 2 years ago

Makes sense.