use o3::{alloc, alloc::BoxSliceExt as _};
pub(super) fn copy(base: &[u8], suffix: &[u8]) -> Result<Box<std::ffi::CStr>, alloc::Error> {
let len = base.len() + suffix.len() + 1;
let mut bytes = Box::<[u8]>::try_uninit(len)?;
let (head, rest) = bytes.split_at_mut(base.len());
let (tail, end) = rest.split_at_mut(suffix.len());
head.write_copy_of_slice(base);
tail.write_copy_of_slice(suffix);
end[0].write(0);
let name =
unsafe { std::ffi::CString::from_vec_with_nul_unchecked(bytes.assume_init().into_vec()) };
Ok(name.into_boxed_c_str())
}