blob: 32b2d1a158be4c732f80674f45e566f822049574 (
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
30
|
extern malloc = (i64) => *void;
extern free = (*void) => void;
import "!stdlib.pry";
let main = () => i64 {
let x = cast(*i8, malloc(24));
(*(x+cast(*i8, 0))) = 10;
(*(x+cast(*i8, 1))) = 20;
(*(x+cast(*i8, 2))) = 40;
printf("%p\n", x);
printf("%d\n", *(x+cast(*i8, 0)));
printf("%d\n", *(x+cast(*i8, 1)));
printf("%d\n", *(x+cast(*i8, 2)));
free(cast(*void, x));
return 0;
};
/*
Expected stdout:
${SOMEPOINTER}
10
20
40
Expected return: 0
*/
|