mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vlib: fix remaining mutability errors
This commit is contained in:
parent
329485d4b6
commit
c2814c1ada
@ -184,7 +184,6 @@ fn (cb &Clipboard) take_ownership(){
|
||||
|
||||
fn (cb mut Clipboard) set_text(text string) bool {
|
||||
if cb.window == Window(C.None) {return false}
|
||||
mut ret := false
|
||||
cb.mutex.lock()
|
||||
cb.text = text
|
||||
cb.is_owner = true
|
||||
|
@ -25,7 +25,7 @@ const (
|
||||
*/
|
||||
pub fn decode(data string) string {
|
||||
buffer := malloc( data.len * 3 / 4 )
|
||||
return tos(buffer, decode_in_buffer(data, mut buffer) )
|
||||
return tos(buffer, decode_in_buffer(data, buffer) )
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ pub fn decode(data string) string {
|
||||
*/
|
||||
pub fn encode(data string) string {
|
||||
buffer := malloc( 4 * ((data.len + 2) / 3) )
|
||||
return tos(buffer, encode_in_buffer(data, mut buffer))
|
||||
return tos(buffer, encode_in_buffer(data, buffer))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +109,7 @@ pub fn decode_in_buffer(data &string, buffer byteptr) int {
|
||||
* @return the actual size of the encoded data in the buffer.
|
||||
* NB: this function does NOT allocate new memory, and is suitable for handling very large strings.
|
||||
*/
|
||||
pub fn encode_in_buffer(data &string, buffer mut byteptr) int {
|
||||
pub fn encode_in_buffer(data &string, buffer byteptr) int {
|
||||
input_length := data.len
|
||||
output_length := 4 * ((input_length + 2) / 3)
|
||||
|
||||
|
@ -15,14 +15,14 @@ fn test_long_encoding(){
|
||||
|
||||
ebuffer := malloc( s_encoded.len )
|
||||
for i := 0; i < repeats; i++ {
|
||||
resultsize := base64.encode_in_buffer(s_original, mut ebuffer)
|
||||
resultsize := base64.encode_in_buffer(s_original, ebuffer)
|
||||
s += resultsize
|
||||
assert resultsize == s_encoded.len
|
||||
}
|
||||
|
||||
dbuffer := malloc( s_decoded.len )
|
||||
for i := 0; i < repeats; i++ {
|
||||
resultsize := base64.decode_in_buffer(s_encoded, mut dbuffer)
|
||||
resultsize := base64.decode_in_buffer(s_encoded, dbuffer)
|
||||
s += resultsize
|
||||
assert resultsize == s_decoded.len
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user