aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/memdebug_interior.zc
blob: 8464f2cf08384714baa9902350440025f8d8cea1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
namespace;
include rt;

// memdebug finds the block of an interior pointer however deep it is: buf[255]
// of a 256-word block is 255 words past its header, beyond the old 64-word scan.
memdebug on;
fn main() {
	let buf = rt.new(256), small = rt.new(4);
	buf[255] = 7;
	buf[100] = 3;
	small[3] = 2;
	rt.put_n(buf[255]); rt.put_c(32);
	rt.put_n(buf[100]); rt.put_c(32);
	rt.put_n(small[3]); rt.put_c(10);
	rt.free(small);
	rt.free(buf);
	return 0;
}