Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary (and risky) usage of atexit() #200

Open
Forkelt opened this issue Nov 7, 2021 · 0 comments
Open

Unnecessary (and risky) usage of atexit() #200

Forkelt opened this issue Nov 7, 2021 · 0 comments

Comments

@Forkelt
Copy link

Forkelt commented Nov 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant