about summary refs log tree commit diff
path: root/examples/18.src
blob: be5b9674eee2602cc6323b8eaa685f225771198b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extern printf = (*i64, varargs) => void;
extern malloc = (i64) => *i64;
extern free = (*i64) => void;

let main = () => i64 {
	let x = malloc(24);
	(*(x+0)) = 10;
	(*(x+1)) = 20;
	(*(x+2)) = 40;
	printf("%p\n", x);
	printf("%d\n", *(x+0));
	printf("%d\n", *(x+1));
	printf("%d\n", *(x+2));
	free(x);
	return 0;
};

/*

Expected stdout:

${SOMEPOINTER}
10
20
40

Expected return: 0

*/