antirez/linenoise

Unnecessary (and risky) usage of atexit()

Forkelt opened this issue · 0 comments

As of now, linenoise uses atexit() to call free a bunch of times. It seems completely unnecessary do so, because the OS will already reclaim that memory at exit (and far more efficiently, too).
Also, using atexit() for this purpose means that if some user of the library decides to use atexit() to save linenoise history to a file, it won't work because linenoise's atexit() will practically always be called later (because it's only called once the first line is processed), and therefore its atexit() set function would be called first once the program exits, making the history written to file complete garbage.

I would suggest simply removing the freeHistory() call from linenoiseAtExit(), or removing the function altogether.