1
0
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:
MatejMagat305
2023-01-16 16:30:40 +01:00
committed by GitHub
parent 92fd12c18a
commit 6bf6a40e0c
13 changed files with 187 additions and 8 deletions

View File

@ -63,6 +63,7 @@ pub fn (mut d Digest) free() {
fn (mut d Digest) init() {
d.h = []u32{len: (8)}
d.x = []u8{len: sha256.chunk}
d.reset()
}
// reset the state of the Digest `d`
@ -94,7 +95,6 @@ pub fn (mut d Digest) reset() {
pub fn new() &Digest {
mut d := &Digest{}
d.init()
d.reset()
return d
}
@ -103,7 +103,6 @@ pub fn new224() &Digest {
mut d := &Digest{}
d.is224 = true
d.init()
d.reset()
return d
}