Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc26bd79

Browse files
authored
Rollup merge ofrust-lang#126854 - devnexen:std_unix_os_fallback_upd, r=Mark-Simulacrum
std::unix::os::home_dir: fallback's optimisation.we're using a guaranteed initialised field on success.
2 parents828e528 +f0b95fc commitc26bd79

File tree

1 file changed

+3
-3
lines changed
  • std/src/sys/pal/unix

1 file changed

+3
-3
lines changed

‎std/src/sys/pal/unix/os.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,17 +738,17 @@ pub fn home_dir() -> Option<PathBuf> {
738738
n => nasusize,
739739
};
740740
letmut buf =Vec::with_capacity(amt);
741-
letmutpasswd:libc::passwd = mem::zeroed();
741+
letmutp = mem::MaybeUninit::<libc::passwd>::uninit();
742742
letmut result = ptr::null_mut();
743743
match libc::getpwuid_r(
744744
libc::getuid(),
745-
&mut passwd,
745+
p.as_mut_ptr(),
746746
buf.as_mut_ptr(),
747747
buf.capacity(),
748748
&mut result,
749749
){
750750
0if !result.is_null() =>{
751-
let ptr =passwd.pw_diras*const_;
751+
let ptr =(*result).pw_diras*const_;
752752
let bytes =CStr::from_ptr(ptr).to_bytes().to_vec();
753753
Some(OsStringExt::from_vec(bytes))
754754
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp