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] = 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; }