Add some comments to prevent regression

This commit is contained in:
David Thomas 2024-02-14 20:03:55 +00:00 committed by GnomedDev
parent 8daf137543
commit 0433439433
No known key found for this signature in database
GPG Key ID: 9BF10F8372B254D1

View File

@ -27,6 +27,8 @@ pub fn run_with_cstr<T, F>(bytes: &[u8], mut f: F) -> io::Result<T>
where
F: FnMut(&CStr) -> io::Result<T>,
{
// Dispatch and dyn erase the closure type to prevent mono bloat.
// See https://github.com/rust-lang/rust/pull/121101.
if bytes.len() >= MAX_STACK_ALLOCATION {
run_with_cstr_allocating(bytes, &mut f)
} else {
@ -34,6 +36,9 @@ where
}
}
/// # Safety
///
/// `bytes` must have a length less than `MAX_STACK_ALLOCATION`.
unsafe fn run_with_cstr_stack<T>(
bytes: &[u8],
f: &mut dyn FnMut(&CStr) -> io::Result<T>,