aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/buddy.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/buddy.zc')
-rw-r--r--tests/programs/buddy.zc23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/programs/buddy.zc b/tests/programs/buddy.zc
index ab351d2..c92a790 100644
--- a/tests/programs/buddy.zc
+++ b/tests/programs/buddy.zc
@@ -1,16 +1,19 @@
+namespace;
+include rt;
+
// the buddy allocator: 20000 small blocks, freed, merge back into one big one
let keep[20000];
fn main() {
let i = 0, p;
- while (i < 20000) { keep[i] = new(2); i++; } // 20000 8-word blocks
- put_n(largest_free()); put_c(' ');
- i = 0; while (i < 20000) { free(keep[i]); keep[i] = 0; i++; }
- scrub(); // stale stack words would keep the quarantined blocks
- gc();
- put_n(largest_free()); put_c(' ');
- p = new(200000); // only possible if the small blocks merged back
- put_n(osize(p) >= 200000); put_c(' ');
- free(d*p);
- put_n(live_objects()); put_c(10);
+ while (i < 20000) { keep[i] = rt.new(2); i++; } // 20000 8-word blocks
+ rt.put_n(rt.largest_free()); rt.put_c(' ');
+ i = 0; while (i < 20000) { rt.free(keep[i]); keep[i] = 0; i++; }
+ rt.scrub(); // stale stack words would keep the quarantined blocks
+ rt.gc();
+ rt.put_n(rt.largest_free()); rt.put_c(' ');
+ p = rt.new(200000); // only possible if the small blocks merged back
+ rt.put_n(rt.osize(p) >= 200000); rt.put_c(' ');
+ rt.free(d*p);
+ rt.put_n(rt.live_objects()); rt.put_c(10);
return 0;
}