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

os: remove unnecessary unsafes

This commit is contained in:
Alexander Medvednikov 2022-07-06 07:07:48 +03:00
parent d3090de02e
commit 819b6f475a
2 changed files with 42 additions and 48 deletions

View File

@ -949,7 +949,6 @@ pub fn open_append(path string) ?File {
// Note: this function will NOT return when successfull, since
// the child process will take control over execution.
pub fn execvp(cmdpath string, cmdargs []string) ? {
unsafe {
mut cargs := []&char{}
cargs << &char(cmdpath.str)
for i in 0 .. cmdargs.len {
@ -968,7 +967,6 @@ pub fn execvp(cmdpath string, cmdargs []string) ? {
// just in case C._execvp returned ... that happens on windows ...
exit(res)
}
}
// execve - loads and executes a new child process, *in place* of the current process.
@ -978,7 +976,6 @@ pub fn execvp(cmdpath string, cmdargs []string) ? {
// Note: this function will NOT return when successfull, since
// the child process will take control over execution.
pub fn execve(cmdpath string, cmdargs []string, envs []string) ? {
unsafe {
mut cargv := []&char{}
mut cenvs := []&char{}
cargv << &char(cmdpath.str)
@ -1001,7 +998,6 @@ pub fn execve(cmdpath string, cmdargs []string, envs []string) ? {
if res == -1 {
return error_with_code(posix_get_error_msg(C.errno), C.errno)
}
}
}
// is_atty returns 1 if the `fd` file descriptor is open and refers to a terminal

View File

@ -138,13 +138,11 @@ pub fn (pool &PoolProcessor) get_results<T>() []T {
// get_results_ref - get a list of type safe results in the main thread.
pub fn (pool &PoolProcessor) get_results_ref<T>() []&T {
unsafe {
mut res := []&T{cap: pool.results.len}
for i in 0 .. pool.results.len {
res << &T(pool.results[i])
}
return res
}
}
// set_shared_context - can be called during the setup so that you can