- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.cpp
More file actions
Latest commit
24 lines (20 loc) · 461 Bytes
/
Copy pathruntime.cpp
File metadata and controls
24 lines (20 loc) · 461 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<cstdio>
#include<cstdlib>
extern"C" {
char *code(void *context, char *mem);
voidbf_putchar(void *context, int c);
intbf_getchar(void *context);
}
voidbf_putchar(void *context, int c) {
putchar(c);
}
intbf_getchar(void *context) {
int c = getchar();
if (c == -1) return0;
return c;
}
intmain(int argc, char **argv) {
auto mem = static_cast<char*>(calloc(4096, 1));
code(nullptr, mem);
free(mem);
}