4 #include "../memcheck.h"
6 /* Program demonstrating copying of metadata in memcheck. */
10 int* a
= malloc(10 * sizeof(int));
11 int* b
= malloc(10 * sizeof(int));
12 int* v
= malloc(10 * sizeof(int));
15 for (i
= 0; i
< 10; i
++) {
20 /* a[0 .. 4] and [6 .. 9] are defined, [5] is undefined. */
21 for (i
= 0; i
< 10; i
++)
24 /* b[0 .. 9] is defined. */
26 /* Get metadata for a and put it in v. */
27 res
= VALGRIND_GET_VBITS(a
, v
, 10*sizeof(int) );
28 printf("result of GET is %d (1 for success)\n", res
);
30 for (i
= 0; i
< 10; i
++)
31 printf("%d 0x%08x\n", i
, v
[i
]);
34 res
= VALGRIND_SET_VBITS(b
, v
, 10*sizeof(int) );
35 printf("result of SET is %d (1 for success)\n", res
);
37 /* Now we should have that b[5] is undefined since a[5] is
40 for (i
= 0; i
< 10; i
++)
43 /* V should yelp at this point, that sum is undefined. */