blob: 8b1bf08ca5bd2310c52f28bf0107c20ba51d9dd7 (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <stdlib.h>
// All sizes are divisible by 16 -- no slop.
int* ignore1(void)
{
// Allocating/freeing in an ignored function: ignored.
int* ignored_x1 = malloc(400);
int* ignored_x2 = malloc(400);
free(ignored_x2);
return ignored_x1;
}
void ignore2(int* x, int* ignored_x)
{
// Growing/shrinking a non-ignored block in an ignored function: ignored.
x = realloc(x, 800);
x = realloc(x, 400);
// Growing/shrinking an ignored block in an ignored function: ignored.
ignored_x = realloc(ignored_x, 800);
ignored_x = realloc(ignored_x, 400);
}
int main(void)
{
int* x;
int* ignored_x;
// Not ignored.
x = malloc(400);
// Get an ignored block.
ignored_x = ignore1();
// Growing/shrinking a non-ignored block in a non-ignored function:
// not ignored.
x = realloc(x, 800);
x = realloc(x, 400);
// Growing/shrinking an ignored block in a non-ignored function: ignored.
ignored_x = realloc(ignored_x, 800);
ignored_x = realloc(ignored_x, 400);
ignore2(x, ignored_x);
x = realloc(ignored_x, 0); // equivalent to 'free(ignored_x)'.
return 0;
}
|