drd: Add a consistency check
[valgrind.git] / memcheck / tests / undef_malloc_args.c
blob99e27999c26d69aa5bf37bb5c1238e4b84a366e1
1 #include <stdlib.h>
2 //#include <malloc.h>
3 #include "../memcheck.h"
4 int main (int argc, char*argv[])
6 size_t def_size = 1<<20;
7 char *p;
8 char *new_p;
10 if (argc > 10000) def_size = def_size * 2;
13 size_t size = def_size;
14 (void) VALGRIND_MAKE_MEM_UNDEFINED(&size, 1);
15 p = malloc(size);
18 (void) VALGRIND_MAKE_MEM_UNDEFINED(&p, 1);
19 new_p = realloc(p, def_size);
21 (void) VALGRIND_MAKE_MEM_UNDEFINED(&new_p, 1);
22 new_p = realloc(new_p, def_size);
24 (void) VALGRIND_MAKE_MEM_UNDEFINED(&new_p, 1);
25 free (new_p);
28 size_t nmemb = 1;
29 (void) VALGRIND_MAKE_MEM_UNDEFINED(&nmemb, 1);
30 new_p = calloc(nmemb, def_size);
31 free (new_p);
33 #if 0
35 size_t alignment = 1;
36 (void) VALGRIND_MAKE_MEM_UNDEFINED(&alignment, 1);
37 new_p = memalign(alignment, def_size);
38 free(new_p);
42 size_t nmemb = 16;
43 size_t size = def_size;
44 (void) VALGRIND_MAKE_MEM_UNDEFINED(&size, 1);
45 new_p = memalign(nmemb, size);
46 free(new_p);
50 size_t size = def_size;
51 (void) VALGRIND_MAKE_MEM_UNDEFINED(&size, 1);
52 new_p = valloc(size);
53 free (new_p);
55 #endif
56 return 0;