blob: 2dad81b554e2c160f8efc9962600a2959f2eaac7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// The same C under two C libraries (glibc linked dynamically, musl
// statically): what startup, malloc and stdio turn into, seen as syscalls.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Volatile, or the compiler proves the allocations away.
static char *volatile small, *volatile big;
int main(void) {
small = malloc(64);
big = malloc(1 << 20);
strcpy(small, "small");
memset(big, 'b', 1 << 20);
printf("%s %c\n", small, big[4096]);
free(big);
free(small);
return 0;
}
|