Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / big_blocks_freed_list.c
blob9f2528904303a70357db40f013e7a15161c0b67e
1 #include <stdlib.h>
2 /* To be run with --freelist-vol=1000000 --freelist-big-blocks=50000 */
3 static void jumped(void)
7 int main(int argc, char *argv[])
9 char *semi_big = NULL;
10 char *big = NULL;
11 char *small = NULL;
12 char *other_small = NULL;
13 int i;
14 int j;
16 /* Verify that access via a dangling pointer to a big block bigger than
17 the free list is found by memcheck (still on the free list). */
18 semi_big = malloc (900000);
19 big = malloc (1000015);
20 free(semi_big);
21 free(big);
22 if (big[1000] > 0x0) jumped();
23 if (semi_big[1000] > 0x0) jumped();
25 /* Then verify that dangling pointers for small blocks is not hampered
26 by doing big alloc/free. */
27 small = malloc (10000);
28 free(small);
30 /* We should still have a nice error msg for the semi_big
31 but not for the big block, which has been removed from the free list
32 with the malloc of small above. */
33 if (big[2000] > 0x0) jumped();
34 if (semi_big[2000] > 0x0) jumped();
36 big = NULL;
39 big = malloc (1000015);
40 free(big);
41 if (small[10] > 0x0) jumped();
43 /* Do not common up the below in a loop. We
44 want a different error/stack trace for each of
45 these. */
46 if (big[10] > 0x0) jumped();
50 for (i = 0; i < 100; i++) {
51 other_small = malloc(10000);
52 for (j = 0; j < 10000; j++)
53 other_small[j] = 0x1;
55 if (small[10] > 0x0) jumped();
56 return 0;