Allocate OpenSSL objects in #initialize{,_copy}#1046
Open
rhenium wants to merge 10 commits intoruby:masterfrom
Open
Allocate OpenSSL objects in #initialize{,_copy}#1046rhenium wants to merge 10 commits intoruby:masterfrom
rhenium wants to merge 10 commits intoruby:masterfrom
Conversation
The man page discourages the use of this behavior. This also fixes a potential memory leak reported at <ruby#1011>.
Also, avoid using the "reuse" behavior of d2i_*{,_bio}() functions.
Allocate the underlying OpenSSL object in #initialize{,_copy} instead
of .allocate. Allocating an empty OpenSSL object in .allocate is
wasteful because #initialize{,_copy} cannot always reuse an existing
object and have to allocate a new one.
Some ruby/openssl classes already follow this approach, such as
OpenSSL::PKey::PKey. Let's standardize on it.
Also expand New*() and Set*() macros, which are not very helpful for
readability in my opinion.
Allocate the wrapper object before trying to load a provider. Also, expand NewProvider() and SetProvider() macros.
890a3f9 to
1c7f29a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allocate the underlying OpenSSL object in
#initialize{,_copy}instead of.allocate. Allocating an empty OpenSSL object in.allocateis wasteful because#initialize{,_copy}cannot always reuse an existing object and have to allocate a new one.Some ruby/openssl classes already follow this approach, such as
OpenSSL::PKey::PKey. Let's standardize on it.Also expand
New*()andSet*()macros, which are not very helpful for readability in my opinion.