Narrow use of unsafe in roc_run_native

`roc_run_native_fast` is actually the only unsafe part of the function,
so we probably don't need everything to be wrapped in an `unsafe` block.
This commit is contained in:
Jackson Wambolt 2024-06-26 03:35:02 +00:00
parent 7e609bfdbf
commit 1f0303cf53
No known key found for this signature in database
GPG key ID: 76F29A42FEE8811C

View file

@ -1099,7 +1099,6 @@ fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
) -> std::io::Result<i32> { ) -> std::io::Result<i32> {
use bumpalo::collections::CollectIn; use bumpalo::collections::CollectIn;
unsafe {
let executable = roc_run_executable_file_path(binary_bytes)?; let executable = roc_run_executable_file_path(binary_bytes)?;
let (argv_cstrings, envp_cstrings) = make_argv_envp(arena, &executable, args); let (argv_cstrings, envp_cstrings) = make_argv_envp(arena, &executable, args);
@ -1117,10 +1116,9 @@ fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
match opt_level { match opt_level {
OptLevel::Development => roc_dev_native(arena, executable, argv, envp, expect_metadata), OptLevel::Development => roc_dev_native(arena, executable, argv, envp, expect_metadata),
OptLevel::Normal | OptLevel::Size | OptLevel::Optimize => { OptLevel::Normal | OptLevel::Size | OptLevel::Optimize => unsafe {
roc_run_native_fast(executable, &argv, &envp); roc_run_native_fast(executable, &argv, &envp);
} },
}
} }
Ok(1) Ok(1)