mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
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::libc::{c_void, size_t, malloc, free};
|
||||||
use core::unstable::intrinsics;
|
use core::unstable::intrinsics;
|
||||||
|
use core::util;
|
||||||
|
|
||||||
// a wrapper around the handle returned by the foreign code
|
// a wrapper around the handle returned by the foreign code
|
||||||
pub struct Unique<T> {
|
pub struct Unique<T> {
|
||||||
@ -184,7 +185,8 @@ impl<T: Owned> Drop for Unique<T> {
|
|||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut x = intrinsics::init(); // dummy value to swap in
|
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)
|
free(self.ptr as *c_void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@ fn thread_ring(i: uint,
|
|||||||
// Send/Receive lots of messages.
|
// Send/Receive lots of messages.
|
||||||
for uint::range(0, count) |j| {
|
for uint::range(0, count) |j| {
|
||||||
//error!("task %?, iter %?", i, j);
|
//error!("task %?, iter %?", i, j);
|
||||||
let num_chan2 = replace(&mut num_chan, None);
|
let num_chan2 = util::replace(&mut num_chan, None);
|
||||||
let num_port2 = replace(&mut num_port, None);
|
let num_port2 = util::replace(&mut num_port, None);
|
||||||
num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
|
num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
|
||||||
let port = num_port2.unwrap();
|
let port = num_port2.unwrap();
|
||||||
match recv(port) {
|
match recv(port) {
|
||||||
|
Loading…
Reference in New Issue
Block a user