mirror of
https://github.com/NixOS/nix
synced 2025-06-26 15:51:15 +02:00
Move stuff around
This commit is contained in:
parent
ce3c41aef0
commit
a1ff43045b
10 changed files with 74 additions and 67 deletions
|
@ -12,3 +12,22 @@ 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue