-
Notifications
You must be signed in to change notification settings - Fork 97
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
Safer file handling #1320
Safer file handling #1320
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Much better!
@@ -79,4 +79,44 @@ module Tree = Tree | |||
module Forest = Tree.Forest | |||
module Json = Json | |||
|
|||
module Io_utils = struct | |||
let _with_resource res ~close f = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this starting with an underscore to indicate it's not for use outside of the module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. This avoids writing a signature to abstract this one function while the others are trivial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added some documentation to the module to make it easier to read without an interface.
Input or output channels used for marshalling were often left unclosed. This can cause resource leaks when a piece of code that was once run once is suddenly called multiple times.
This adds safe function for reading from and writing to files and replaces code that did unsafe resource manipulations.
ab3aa8e
to
21826bb
Compare
Thanks @Julow ! |
On top of #1315
Remove many misuses of input and output channels.