loop { match backend::termios::syscalls::ttyname(dirfd, buffer.spare_capacity_mut()) {
Err(io::Errno::RANGE) => { // Use `Vec` reallocation strategy to grow capacity // exponentially.
buffer.reserve(buffer.capacity() + 1);
}
Ok(len) => { // SAFETY: Assume the backend returns the length of the string // excluding the NUL. unsafe {
buffer.set_len(len + 1);
}
// SAFETY: // - “ttyname_r stores this pathname in the buffer buf” // - [POSIX definition 3.271: Pathname]: “A string that is used // to identify a file.” // - [POSIX definition 3.375: String]: “A contiguous sequence // of bytes terminated by and including the first null byte.” // // Thus, there will be a single NUL byte at the end of the // string. // // [POSIX definition 3.271: Pathname]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271 // [POSIX definition 3.375: String]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_375 unsafe { return Ok(CString::from_vec_with_nul_unchecked(buffer));
}
}
Err(errno) => return Err(errno),
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.