mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
crypto: add .free() and .reset() methods to reduce memory leaks with -autofree (#16992)
* Fix unsafe pointer I was compile vab with '-prod' and it was needed to fix and it is of course warning * Add files via upload * reduce memory leak s sha512 * add method .free() and .reset() for some
This commit is contained in:
@ -20,6 +20,15 @@ mut:
|
||||
j u8
|
||||
}
|
||||
|
||||
// free the resources taken by the Cipher `c`
|
||||
[unsafe]
|
||||
pub fn (mut c Cipher) free() {
|
||||
$if prealloc {
|
||||
return
|
||||
}
|
||||
unsafe { c.s.free() }
|
||||
}
|
||||
|
||||
// new_cipher creates and returns a new Cipher. The key argument should be the
|
||||
// RC4 key, at least 1 byte and at most 256 bytes.
|
||||
pub fn new_cipher(key []u8) !Cipher {
|
||||
|
Reference in New Issue
Block a user