2
/* Test for correct functioning of the --malloc-fill and --free-fill
3
flags. Needs --malloc-fill=0x55 and --free-fill=0x77. */
14
fprintf(stderr, "test simple malloc/free:\n");
16
a = malloc(10 * sizeof(int)); assert(a);
17
fprintf(stderr, "(should be malloc-filled) a[4] = %x\n", a[4]);
20
fprintf(stderr, "(should be free-filled) a[5] = %x\n", a[5]);
24
fprintf(stderr, "test realloc-larger:\n");
26
r = malloc(30 * sizeof(int)); assert(r);
27
fprintf(stderr, "(should be malloc-filled) r[25] = %x\n", r[25]);
31
r = realloc(r, 40 * sizeof(int)); assert(r);
33
fprintf(stderr, "(should be free-filled) oldr[26] = %x\n", oldr[26]);
34
fprintf(stderr, "(should be malloc-filled) r[35] = %x\n", r[35]);
40
fprintf(stderr, "test realloc-smaller:\n");
42
r = malloc(30 * sizeof(int)); assert(r);
43
fprintf(stderr, "(should be malloc-filled) r[25] = %x\n", r[25]);
47
r = realloc(r, 20 * sizeof(int)); assert(r);
49
fprintf(stderr, "(should be free-filled) oldr[26] = %x\n", oldr[26]);
55
fprintf(stderr, "test calloc:\n");
56
a = calloc(100, sizeof(int)); assert(r);
58
fprintf(stderr, "(should be zero) a[42] = %x\n", a[42]);