1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 06:22:42 +01:00

Get rid of CBox

This commit is contained in:
Eelco Dolstra 2019-12-13 18:29:16 +01:00
parent 5a6d6da7ae
commit ca87707c90
4 changed files with 10 additions and 46 deletions

View file

@ -12,22 +12,3 @@ impl std::io::Read for Source {
Ok(n)
}
}
pub struct CBox<T> {
pub ptr: *mut libc::c_void,
phantom: std::marker::PhantomData<T>,
}
impl<T> CBox<T> {
pub fn new(t: T) -> Self {
unsafe {
let size = std::mem::size_of::<T>();
let ptr = libc::malloc(size);
*(ptr as *mut T) = t; // FIXME: probably UB
Self {
ptr,
phantom: std::marker::PhantomData,
}
}
}
}