Fix tests with the swap operator
This commit is contained in:
parent
63c7e2f991
commit
60803e5fc8
@ -151,6 +151,7 @@ wrapping `malloc` and `free`:
|
||||
~~~~
|
||||
use core::libc::{c_void, size_t, malloc, free};
|
||||
use core::unstable::intrinsics;
|
||||
use core::util;
|
||||
|
||||
// a wrapper around the handle returned by the foreign code
|
||||
pub struct Unique<T> {
|
||||
@ -184,7 +185,8 @@ impl<T: Owned> Drop for Unique<T> {
|
||||
fn finalize(&self) {
|
||||
unsafe {
|
||||
let mut x = intrinsics::init(); // dummy value to swap in
|
||||
x <-> *self.ptr; // moving the object out is needed to call the destructor
|
||||
// moving the object out is needed to call the destructor
|
||||
util::replace_ptr(self.ptr, x);
|
||||
free(self.ptr as *c_void)
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ fn thread_ring(i: uint,
|
||||
// Send/Receive lots of messages.
|
||||
for uint::range(0, count) |j| {
|
||||
//error!("task %?, iter %?", i, j);
|
||||
let num_chan2 = replace(&mut num_chan, None);
|
||||
let num_port2 = replace(&mut num_port, None);
|
||||
let num_chan2 = util::replace(&mut num_chan, None);
|
||||
let num_port2 = util::replace(&mut num_port, None);
|
||||
num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
|
||||
let port = num_port2.unwrap();
|
||||
match recv(port) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user