Skip to content

Commit 93e7b04

Browse files
committed
---
yaml --- r: 21837 b: refs/heads/snap-stage3 c: 24c8969 h: refs/heads/master i: 21835: d6797ee v: v3
1 parent 18cc02b commit 93e7b04

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ce773352d06f490fb1bfb5057035e93effcf5781
4+
refs/heads/snap-stage3: 24c89693f0556ba4b455df358a9136f7873776bf
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)