Skip to content

Commit

Permalink
os: work towards being able to again use -autofree while recompilin…
Browse files Browse the repository at this point in the history
…g the V compiler several times
  • Loading branch information
spytheman committed Nov 14, 2024
1 parent 2831b61 commit df51e84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vlib/os/os.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ pub fn write_file_array(path string, buffer array) ! {
f.close()
}

@[manualfree]
pub fn glob(patterns ...string) ![]string {
mut matches := []string{}
for pattern in patterns {
Expand All @@ -1025,6 +1026,8 @@ pub fn glob(patterns ...string) ![]string {
return matches
}

// last_error returns a V error, formed by the last libc error (from GetLastError() on windows and from `errno` on !windows)
@[manualfree]
pub fn last_error() IError {
$if windows {
code := int(C.GetLastError())
Expand All @@ -1050,7 +1053,7 @@ pub:
// Return a POSIX error:
// Code defaults to last error (from C.errno)
// Message defaults to POSIX error message for the error code
@[inline]
@[inline; manualfree]
pub fn error_posix(e SystemError) IError {
code := if e.code == error_code_not_set { C.errno } else { e.code }
message := if e.msg == '' { posix_get_error_msg(code) } else { e.msg }
Expand All @@ -1060,7 +1063,7 @@ pub fn error_posix(e SystemError) IError {
// Return a Win32 API error:
// Code defaults to last error (calling C.GetLastError())
// Message defaults to Win 32 API error message for the error code
@[inline]
@[inline; manualfree]
pub fn error_win32(e SystemError) IError {
$if windows {
code := if e.code == error_code_not_set { int(C.GetLastError()) } else { e.code }
Expand Down
1 change: 1 addition & 0 deletions vlib/os/os_nix.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ fn init_os_args(argc int, argv &&u8) []string {
// }
// }
// ```
@[manualfree]
pub fn ls(path string) ![]string {
if path == '' {
return error('ls() expects a folder, not an empty string')
Expand Down

0 comments on commit df51e84

Please sign in to comment.