Update from SetFinalizer to AddCleanup#158
Draft
michelle-clayton-work wants to merge 5 commits intomainfrom
Draft
Update from SetFinalizer to AddCleanup#158michelle-clayton-work wants to merge 5 commits intomainfrom
michelle-clayton-work wants to merge 5 commits intomainfrom
Conversation
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.
This pull request refactors resource cleanup throughout the
xcryptopackage, replacing the use ofruntime.SetFinalizerwith the more robustruntime.AddCleanupmechanism. It introduces dedicated cleanup functions for each type of cryptographic resource, improving code clarity and reliability of resource management. The changes affect cipher, hash, HMAC, RC4, and RSA key types.Resource cleanup modernization:
runtime.SetFinalizerwithruntime.AddCleanupfor cryptographic objects incipher.go,hash.go,hmac.go,rc4.go, andrsa.go, ensuring more explicit and reliable cleanup of native resources. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Introduction of cleanup helper functions:
cryptorCleanup,hashCleanup,hmacCleanup,secKeyCleanup) and supporting info structs to encapsulate resource release logic for each cryptographic type, improving maintainability and reducing code duplication. [1] [2] [3] [4]Removal of legacy finalizer methods:
finalizemethods and inline finalizer functions, consolidating cleanup logic into the new helper functions. [1] [2] [3] [4] [5] [6] [7]These changes make resource management more explicit and robust, reducing the risk of memory leaks and simplifying future maintenance.