Wrap in/out length pointer APIs: avoid heap escape #130
+53
−11
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.
Add wrappers that help avoid escape to the heap for this list:
openssl/cgo_go122.go
Lines 10 to 17 in 61234a9
There's only a benchmark for ECDH (EVP_PKEY_derive) but this PR shows the same results as #113:
The wrapper makes it so you can't distinguish a "valid" returned
0
vs. a0
returned because there's an error, and I don't know for sure that won't cause problems in some use cases. (E.g. make an error show up in the wrong way.)Returning a C struct with two values is what I have in mind make a more transparent wrapper that avoids losing this difference, but I figured I'd submit this PR first in case it's not worth the complexity. Please let me know if that seems better. (The benchmark result is the same when I tried this out for
EVP_PKEY_derive
.)