add io.readChars overload (simpler, less error prone) (#16044)

* add simpler to use readChars overload

* use new readChars overload

* Update lib/wrappers/openssl.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: flywind <xzsflywind@gmail.com>
This commit is contained in:
Timothee Cour 2021-02-22 11:13:08 -08:00 • committed by GitHub
commit ce7caec4b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 6 deletions

View file

@ -760,7 +760,7 @@ proc md5_File*(file: string): string {.raises: [IOError,Exception].} =
ctx: MD5_CTX
discard md5_Init(ctx)
while(let bytes = f.readChars(buf, 0, sz); bytes > 0):
while (let bytes = f.readChars(buf); bytes > 0):
discard md5_Update(ctx, buf[0].addr, cast[csize_t](bytes))
discard md5_Final(buf[0].addr, ctx)