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:
@@ -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)
|
||||
|
@@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user