Skip to content

Commit 4fb643b

Browse files
committed
---
yaml --- r: 30545 b: refs/heads/incoming c: 24c8969 h: refs/heads/master i: 30543: 3a1505e v: v3
1 parent 8599a1e commit 4fb643b

File tree

2 files changed

+7
-55
lines changed

2 files changed

+7
-55
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: ce773352d06f490fb1bfb5057035e93effcf5781
9+
refs/heads/incoming: 24c89693f0556ba4b455df358a9136f7873776bf
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/cleanup.rs

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use libc::{c_char, c_void, intptr_t, uintptr_t};
22
use ptr::{mut_null, null, to_unsafe_ptr};
33
use repr::BoxRepr;
4-
use rt::rt_free;
54
use sys::TypeDesc;
65
use unsafe::transmute;
76

@@ -67,7 +66,12 @@ struct Task {
6766
* This runs at task death to free all boxes.
6867
*/
6968

70-
unsafe fn do_annihilate() {
69+
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
70+
#[cfg(notest)]
71+
#[lang="annihilate"]
72+
pub unsafe fn annihilate() {
73+
use rt::rt_free;
74+
7175
let task: *Task = transmute(rustrt::rust_get_task());
7276

7377
// Pass 1: Make all boxes immortal.
@@ -105,61 +109,9 @@ unsafe fn do_annihilate() {
105109
}
106110
}
107111

108-
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
109-
#[cfg(notest)]
110-
#[lang="annihilate"]
111-
pub unsafe fn annihilate() {
112-
do_annihilate();
113-
}
114-
115-
#[cfg(test)]
116-
pub unsafe fn annihilate() {
117-
do_annihilate();
118-
}
119-
120112
/// Bindings to the runtime
121113
extern mod rustrt {
122114
#[rust_stack]
123115
/*priv*/ fn rust_get_task() -> *c_void;
124116
}
125117

126-
/*
127-
* Tests
128-
*/
129-
130-
#[cfg(test)]
131-
mod tests {
132-
struct Knot {
133-
mut a: Option<@Knot>
134-
}
135-
136-
struct Blah {
137-
x: int,
138-
drop { io::println("Blah!"); }
139-
}
140-
141-
#[test]
142-
fn test_box_annihilation() {
143-
let knot = @Knot { a: None };
144-
knot.a = Some(knot);
145-
146-
let x = @~"foo";
147-
148-
let blah = @Blah { x: 3 };
149-
150-
let f_ref = @mut None;
151-
let f = || { util::ignore(f_ref); };
152-
*f_ref = Some(f);
153-
154-
unsafe { annihilate(); }
155-
156-
unsafe {
157-
unsafe::forget(knot);
158-
unsafe::forget(x);
159-
unsafe::forget(blah);
160-
unsafe::forget(f_ref);
161-
unsafe::forget(f);
162-
}
163-
}
164-
}
165-

0 commit comments

Comments
 (0)