Created
November 8, 2022 20:10
-
-
Save BetterProgramming/12598917aeefca01a3768431063010b2 to your computer and use it in GitHub Desktop.
This file contains 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
func (h *boringHMAC) Reset() { | |
if h.needCleanup { | |
C._goboringcrypto_HMAC_CTX_cleanup(&h.ctx) | |
} else { | |
h.needCleanup = true | |
// Note: Because of the finalizer, any time h.ctx is passed to cgo, | |
// that call must be followed by a call to runtime.KeepAlive(h), | |
// to make sure h is not collected (and finalized) before the cgo | |
// call returns. | |
runtime.SetFinalizer(h, (*boringHMAC).finalize) | |
} | |
} | |
func (h *boringHMAC) finalize() { | |
C._goboringcrypto_HMAC_CTX_cleanup(&h.ctx) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment