coverity: use some event tags and ensure some shift expression size promotion
[valgrind.git] / perf / many-xpts.c
blobe5e3e86c3a225cbffbb683fcb5346afb564481c4
1 #include <stdlib.h>
3 #define nth_bit(x, n) ((x >> n) & 1)
4 #define Fn(N, Np1) \
5 void* a##N(int x) { return ( nth_bit(x, N) ? a##Np1(x) : a##Np1(x) ); }
7 // This test allocates a lot of heap memory, and every allocation features a
8 // different stack trace -- the stack traces are effectively a
9 // representation of the number 'i', where each function represents a bit in
10 // 'i', and if it's a 1 the first function is called, and if it's a 0 the
11 // second function is called.
13 void* a999(int x)
15 return malloc(100);
18 Fn(17, 999)
19 Fn(16, 17)
20 Fn(15, 16)
21 Fn(14, 15)
22 Fn(13, 14)
23 Fn(12, 13)
24 Fn(11, 12)
25 Fn(10, 11)
26 Fn( 9, 10)
27 Fn( 8, 9)
28 Fn( 7, 8)
29 Fn( 6, 7)
30 Fn( 5, 6)
31 Fn( 4, 5)
32 Fn( 3, 4)
33 Fn( 2, 3)
34 Fn( 1, 2)
35 Fn( 0, 1)
37 int main(void)
39 int i;
41 // Create a large XTree.
42 for (i = 0; i < (1 << 18); i++)
43 a0(i);
45 // Do a lot of allocations so it gets dup'd a lot of times.
46 for (i = 0; i < 100000; i++) {
47 free(a1(234));
48 free(a2(111));
51 return 0;