let cache = LruCache {
map: HashMap::new(),
max_size: capacity,
- head: unsafe{ mem::transmute(box mem::uninit::<LruEntry<K, V>>()) },
+ head: unsafe{ mem::transmute(box mem::uninitialized::<LruEntry<K, V>>()) },
};
unsafe {
(*cache.head).next = cache.head;
/// Returns the size of the type that `_val` points to in bytes.
#[inline]
-#[unstable = "the name of this function may change slightly before stabilizing"]
+#[stable]
pub fn size_of_val<T>(_val: &T) -> uint {
size_of::<T>()
}
/// Returns the ABI-required minimum alignment of the type of the value that
/// `_val` points to
#[inline]
-#[unstable = "the name of this function may change slightly before stabilizing"]
+#[stable]
pub fn min_align_of_val<T>(_val: &T) -> uint {
min_align_of::<T>()
}
/// as trait objects (in the future), returning the alignment for an arbitrary
/// value at runtime.
#[inline]
-#[unstable = "the name of this function may change slightly before stabilizing"]
+#[stable]
pub fn align_of_val<T>(_val: &T) -> uint {
align_of::<T>()
}
///
/// This is useful for FFI functions sometimes, but should generally be avoided.
#[inline]
-#[unstable = "the name of this function is subject to change"]
+#[stable]
pub unsafe fn zeroed<T>() -> T {
intrinsics::init()
}
///
/// This is useful for FFI functions sometimes, but should generally be avoided.
#[inline]
-#[unstable = "the name of this function is subject to change"]
+#[stable]
+pub unsafe fn uninitialized<T>() -> T {
+ intrinsics::uninit()
+}
+
+/// Deprecated, use `uninitialized` instead.
+#[inline]
+#[deprecated = "this function has been renamed to `uninitialized`"]
pub unsafe fn uninit<T>() -> T {
intrinsics::uninit()
}
/// contained at the location `dst`. This could leak allocations or resources,
/// so care must be taken to previously deallocate the value at `dst`.
#[inline]
-#[unstable = "the name of this function is subject to change"]
+#[stable]
pub unsafe fn overwrite<T>(dst: *mut T, src: T) {
intrinsics::move_val_init(&mut *dst, src)
}
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
// Give ourselves some scratch space to work with
- let mut t: T = uninit();
+ let mut t: T = uninitialized();
// Perform the swap, `&mut` pointers never alias
ptr::copy_nonoverlapping_memory(&mut t, &*x, 1);
/// fn swap<T>(x: &mut T, y: &mut T) {
/// unsafe {
/// // Give ourselves some scratch space to work with
-/// let mut t: T = mem::uninit();
+/// let mut t: T = mem::uninitialized();
///
/// // Perform the swap, `&mut` pointers never alias
/// ptr::copy_nonoverlapping_memory(&mut t, &*x, 1);
#[inline]
pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
// Give ourselves some scratch space to work with
- let mut tmp: T = mem::uninit();
+ let mut tmp: T = mem::uninitialized();
let t: *mut T = &mut tmp;
// Perform the swap
/// Reads the value from `*src` and returns it.
#[inline(always)]
pub unsafe fn read<T>(src: *T) -> T {
- let mut tmp: T = mem::uninit();
+ let mut tmp: T = mem::uninitialized();
copy_nonoverlapping_memory(&mut tmp, src, 1);
tmp
}
}
fn fstat(&mut self) -> IoResult<io::FileStat> {
- let mut stat: libc::stat = unsafe { mem::uninit() };
+ let mut stat: libc::stat = unsafe { mem::zeroed() };
match retry(|| unsafe { libc::fstat(self.fd(), &mut stat) }) {
0 => Ok(mkstat(&stat)),
_ => Err(super::last_error()),
}
pub fn stat(p: &CString) -> IoResult<io::FileStat> {
- let mut stat: libc::stat = unsafe { mem::uninit() };
+ let mut stat: libc::stat = unsafe { mem::zeroed() };
match retry(|| unsafe { libc::stat(p.with_ref(|p| p), &mut stat) }) {
0 => Ok(mkstat(&stat)),
_ => Err(super::last_error()),
}
pub fn lstat(p: &CString) -> IoResult<io::FileStat> {
- let mut stat: libc::stat = unsafe { mem::uninit() };
+ let mut stat: libc::stat = unsafe { mem::zeroed() };
match retry(|| unsafe { libc::lstat(p.with_ref(|p| p), &mut stat) }) {
0 => Ok(mkstat(&stat)),
_ => Err(super::last_error()),
}
fn fstat(&mut self) -> IoResult<io::FileStat> {
- let mut stat: libc::stat = unsafe { mem::uninit() };
+ let mut stat: libc::stat = unsafe { mem::zeroed() };
match unsafe { libc::fstat(self.fd(), &mut stat) } {
0 => Ok(mkstat(&stat)),
_ => Err(super::last_error()),
}
pub fn stat(p: &CString) -> IoResult<io::FileStat> {
- let mut stat: libc::stat = unsafe { mem::uninit() };
+ let mut stat: libc::stat = unsafe { mem::zeroed() };
as_utf16_p(p.as_str().unwrap(), |up| {
match unsafe { libc::wstat(up, &mut stat) } {
0 => Ok(mkstat(&stat)),
// The idea here is to avoid initializing threads that never
// need to be initialized, particularly for larger regexs with
// a lot of instructions.
- queue: unsafe { ::std::mem::uninit() },
- sparse: unsafe { ::std::mem::uninit() },
+ queue: unsafe { ::std::mem::uninitialized() },
+ sparse: unsafe { ::std::mem::uninitialized() },
size: 0,
}
}
// Unsafe function that handles possibly copying the &[u8] into a stack array.
unsafe fn with_c_str<T>(v: &[u8], checked: bool, f: |*libc::c_char| -> T) -> T {
if v.len() < BUF_LEN {
- let mut buf: [u8, .. BUF_LEN] = mem::uninit();
+ let mut buf: [u8, .. BUF_LEN] = mem::uninitialized();
slice::bytes::copy_memory(buf, v);
buf[v.len()] = 0;
pub fn page_size() -> uint {
use mem;
unsafe {
- let mut info = mem::uninit();
+ let mut info = mem::zeroed();
libc::GetSystemInfo(&mut info);
return info.dwPageSize as uint;
pub fn granularity() -> uint {
use mem;
unsafe {
- let mut info = mem::uninit();
+ let mut info = mem::zeroed();
libc::GetSystemInfo(&mut info);
return info.dwAllocationGranularity as uint;
pub type rust_thread_return = *u8;
pub unsafe fn create(stack: uint, p: Box<proc():Send>) -> rust_thread {
- let mut native: libc::pthread_t = mem::uninit();
- let mut attr: libc::pthread_attr_t = mem::uninit();
+ let mut native: libc::pthread_t = mem::zeroed();
+ let mut attr: libc::pthread_attr_t = mem::zeroed();
assert_eq!(pthread_attr_init(&mut attr), 0);
assert_eq!(pthread_attr_setdetachstate(&mut attr,
PTHREAD_CREATE_JOINABLE), 0);
enum v {}
pub fn main() {
- let y: v = unsafe { ::std::mem::uninit() };
+ let y: v = unsafe { ::std::mem::uninitialized() };
}
pub fn main() {
unsafe {
- let _x: Foo = mem::uninit();
- let _x: [Foo, ..2] = mem::uninit();
+ let _x: Foo = mem::uninitialized();
+ let _x: [Foo, ..2] = mem::uninitialized();
}
}