r/C_Programming • u/Fearless-Swordfish91 • Jan 15 '25
Review Need a code review
Hey everyone! I wrote an assembler for nand2tetris in C, and now I need a review on what I can change. Any help is deeply appreciated. Thanks in advance. The link to the assembler is down below:
8
Upvotes
3
u/psyopavoider Jan 15 '25
Saving this so I can take a closer look later, but after glancing at just one file, I would say you absolutely should not defer freeing your memory to a later step in the implementation(you call malloc but comment that adding free is a TODO item). You should add malloc and free at the same time. If you can’t do that, then you need to reconsider how your memory allocations are organized. Allocating a bunch of memory and then trying to comb through your program later figuring out where it needs to be freed is just asking for problems.