aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/quarantine.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/quarantine.zc')
-rw-r--r--tests/programs/quarantine.zc25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/programs/quarantine.zc b/tests/programs/quarantine.zc
index 5e3e188..061c4da 100644
--- a/tests/programs/quarantine.zc
+++ b/tests/programs/quarantine.zc
@@ -1,25 +1,28 @@
+namespace;
+include rt;
+
// free quarantines the block. a stale alias still reads it, and freeing
// through the alias does nothing because the header already says free.
// unchecked so the analyzer doesn't reject the use after free.
unchecked fn main() {
- let p = new(4), q, r, i = 0, t, bad = 0;
+ let p = rt.new(4), q, r, i = 0, t, bad = 0;
p[0] = 111; p[1] = 222; p[2] = 333; p[3] = 444;
q = p;
r = p + 2;
- free(p);
- while (i < 400) { t = new(4); t[0] = 999; t[1] = 888; t[2] = 777; t[3] = 666; i++; }
+ rt.free(p);
+ while (i < 400) { t = rt.new(4); t[0] = 999; t[1] = 888; t[2] = 777; t[3] = 666; i++; }
if (q[0] != 111 || q[1] != 222 || r[0] != 333 || r[1] != 444) bad = 1;
- free(q);
+ rt.free(q);
if (q[0] != 111 || q[1] != 222) bad = 2;
- gc(); // q still points at the block, so the sweep must not reuse it
+ rt.gc(); // q still points at the block, so the sweep must not reuse it
if (q[0] != 111 || r[0] != 333) bad = 3;
p = 0; q = 0; r = 0; t = 0;
- scrub();
- gc();
- t = new(4);
+ rt.scrub();
+ rt.gc();
+ t = rt.new(4);
t[0] = 1234;
- put_n(bad); put_c(' ');
- put_n(t[0]); put_c(10);
- free(t);
+ rt.put_n(bad); rt.put_c(' ');
+ rt.put_n(t[0]); rt.put_c(10);
+ rt.free(t);
return 0;
}