提交 f5ab112e 编写于 作者: J James Miller

Replace init() with uninit() where appropriate

上级 050c744c
......@@ -25,7 +25,7 @@ pub mod rusti {
/// Casts the value at `src` to U. The two types must have the same length.
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
let mut dest: U = unstable::intrinsics::init();
let mut dest: U = unstable::intrinsics::uninit();
{
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
let src_ptr: *u8 = rusti::transmute(src);
......
......@@ -591,8 +591,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
}
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
unsafe {
// FIXME #4204: Should be uninit() - we don't need this zeroed
let mut val = intrinsics::init();
let mut val = intrinsics::uninit();
val <-> *valptr;
raw::set_len(v, ln - 1u);
val
......@@ -666,8 +665,7 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
unsafe {
do as_mut_buf(rhs) |p, len| {
for uint::range(0, len) |i| {
// FIXME #4204 Should be uninit() - don't need to zero
let mut x = intrinsics::init();
let mut x = intrinsics::uninit();
x <-> *ptr::mut_offset(p, i);
push(&mut *v, x);
}
......@@ -683,8 +681,7 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
unsafe {
// This loop is optimized out for non-drop types.
for uint::range(newlen, oldlen) |i| {
// FIXME #4204 Should be uninit() - don't need to zero
let mut dropped = intrinsics::init();
let mut dropped = intrinsics::uninit();
dropped <-> *ptr::mut_offset(p, i);
}
}
......@@ -709,9 +706,7 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
// last_written < next_to_read < ln
if *ptr::mut_offset(p, next_to_read) ==
*ptr::mut_offset(p, last_written) {
// FIXME #4204 Should be uninit() - don't need to
// zero
let mut dropped = intrinsics::init();
let mut dropped = intrinsics::uninit();
dropped <-> *ptr::mut_offset(p, next_to_read);
} else {
last_written += 1;
......
......@@ -139,7 +139,7 @@ fn from_vec(xs: ~[T]) -> PriorityQueue<T> {
while pos > start {
let parent = (pos - 1) >> 1;
if new > self.data[parent] {
let mut x = rusti::init();
let mut x = rusti::uninit();
x <-> self.data[parent];
rusti::move_val_init(&mut self.data[pos], x);
pos = parent;
......@@ -162,7 +162,7 @@ fn from_vec(xs: ~[T]) -> PriorityQueue<T> {
if right < end && !(self.data[child] > self.data[right]) {
child = right;
}
let mut x = rusti::init();
let mut x = rusti::uninit();
x <-> self.data[child];
rusti::move_val_init(&mut self.data[pos], x);
pos = child;
......
......@@ -51,7 +51,7 @@ fn finalize(&self) {
unsafe {
(*self.ptr).count -= 1;
if (*self.ptr).count == 0 {
let mut x = intrinsics::init();
let mut x = intrinsics::uninit();
x <-> *self.ptr;
free(self.ptr as *c_void)
}
......@@ -159,7 +159,7 @@ fn finalize(&self) {
unsafe {
(*self.ptr).count -= 1;
if (*self.ptr).count == 0 {
let mut x = rusti::init();
let mut x = rusti::uninit();
x <-> *self.ptr;
free(self.ptr as *c_void)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册