a thoughtful web.
Good ideas and conversation. No ads, no tracking.   Login or Take a Tour!
comment
rob05c  ·  3158 days ago  ·  link  ·    ·  parent  ·  post: What does your desktop look like, Hubski?

    I don't think that all memory will get released properly if you will terminate this loop by C-c.

Not an issue. That loop is never normally exited. If `lval_eval` calls `exit(0)`, the process is terminated and memory no longer matters.

    is there no other option in your code then to re-initialize variables inside a loop?

How else would you do it? There are ways to read input into a pre-initialised buffer, but they're painful, because you have to check if the input was larger than the buffer and read again in a loop. Trading potential memory leaks for potential buffer overflows isn't a gain. There's nothing wrong with using GNU readline.

What are you worried about? Performance? Not an issue. Dynamic memory allocation? Should be avoided when possible; not possible here.

    trying out The Better String Library

Dependencies come at a cost. There are projects for which a string library dependency is justified. I doubt a toy REPL is one of them. C strings are simple and well-understood. If you don't understand them, a project like this is a great place to learn.

No code is perfect, but this looks like decent C to me.