1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vlib: add [unsafe] tag to more functions: tos, string_from_wide, strings.Builder: write_bytes, free (#8766)

This commit is contained in:
Nick Treleaven
2021-02-15 15:15:52 +00:00
committed by GitHub
parent 4bdbb0cfa8
commit 4a0367a63c
25 changed files with 82 additions and 60 deletions

View File

@@ -10,7 +10,7 @@ fn (mut ws Client) handshake() ? {
seckey := base64.encode(nonce)
mut sb := strings.new_builder(1024)
defer {
sb.free()
unsafe { sb.free() }
}
sb.write('GET ')
sb.write(ws.uri.resource)

View File

@@ -35,7 +35,7 @@ fn create_key_challenge_response(seckey string) ?string {
sha1buf := seckey + guid
shabytes := sha1buf.bytes()
hash := sha1.sum(shabytes)
b64 := base64.encode(tos(hash.data, hash.len))
b64 := base64.encode(unsafe { tos(hash.data, hash.len) })
unsafe {
hash.free()
shabytes.free()
@@ -50,5 +50,5 @@ fn get_nonce(nonce_size int) string {
for i in 0 .. nonce_size {
nonce[i] = alphanum[rand.intn(alphanum.len)]
}
return tos(nonce.data, nonce.len).clone()
return unsafe { tos(nonce.data, nonce.len) }.clone()
}