diff --git a/vlib/net/address.v b/vlib/net/address.v index d50ed7af13..2f4a5872c1 100644 --- a/vlib/net/address.v +++ b/vlib/net/address.v @@ -31,7 +31,7 @@ fn new_addr(addr C.sockaddr) ?Addr { // Convert to string representation buf := []byte{len: net.max_ipv4_addr_len, init: 0} $if windows { - res := C.WSAAddressToStringA(&addr, addr_len, C.NULL, buf.data, &buf.len) + res := C.WSAAddressToStringA(&addr, addr_len, C.NULL, buf.data, unsafe { &u32(&buf.len) }) if res != 0 { socket_error(-1) ? } diff --git a/vlib/os/os_nix.c.v b/vlib/os/os_nix.c.v index 492f163d9e..2097301e59 100644 --- a/vlib/os/os_nix.c.v +++ b/vlib/os/os_nix.c.v @@ -170,19 +170,20 @@ pub fn execute(cmd string) Result { output: 'exec("$cmd") failed' } } - buf := [4096]byte{} + buf := unsafe { &char(malloc(4096)) } mut res := strings.new_builder(1024) defer { unsafe { res.free() } } unsafe { - bufbp := &buf[0] - for C.fgets(&char(bufbp), 4096, f) != 0 { + bufbp := buf + for C.fgets(bufbp, 4096, f) != 0 { res.write_ptr(bufbp, vstrlen(bufbp)) } } soutput := res.str() exit_code := vpclose(f) + unsafe { free(buf) } return Result{ exit_code: exit_code output: soutput diff --git a/vlib/v/util/diff.v b/vlib/v/util/diff.v index b3e2c6f509..54e089dd6b 100644 --- a/vlib/v/util/diff.v +++ b/vlib/v/util/diff.v @@ -69,14 +69,14 @@ pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string { } pub fn color_compare_strings(diff_cmd string, unique_prefix string, expected string, found string) string { - cdir := os.cache_dir() + cdir := os.join_path(os.cache_dir(), unique_prefix) + os.mkdir(cdir) or {} ctime := time.sys_mono_now() - e_file := os.join_path(cdir, '${unique_prefix}_${ctime}.expected.txt') - f_file := os.join_path(cdir, '${unique_prefix}_${ctime}.found.txt') + e_file := os.join_path(cdir, '${ctime}.expected.txt') + f_file := os.join_path(cdir, '${ctime}.found.txt') os.write_file(e_file, expected) or { panic(err) } os.write_file(f_file, found) or { panic(err) } res := color_compare_files(diff_cmd, e_file, f_file) - os.rm(e_file) or { panic(err) } - os.rm(f_file) or { panic(err) } + os.rmdir_all(cdir) or {} return res }