Commit | Line | Data |
---|---|---|
e6ef4111 PMF |
1 | #include <string.h> |
2 | #include <stdlib.h> | |
3 | ||
4 | #define N_ITER 1000 | |
5 | ||
6 | int main() | |
7 | { | |
8 | int i; | |
9 | const char teststr[] = "Hello World! 1234567890abc"; | |
10 | void *ptrs[N_ITER]; | |
11 | ||
12 | for(i=0; i<N_ITER; i++) { | |
13 | ptrs[i] = malloc(i+1000); | |
14 | ||
15 | memcpy(ptrs[i], teststr, sizeof(teststr)); | |
16 | ||
17 | if(i%2 == 0) { | |
18 | free(ptrs[i]); | |
19 | } | |
20 | } | |
21 | ||
22 | for(i=0; i<N_ITER; i++) { | |
23 | if(i%2 == 1) | |
24 | free(ptrs[i]); | |
25 | } | |
26 | ||
27 | return 0; | |
28 | } |