1
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #include "../memcheck.h"
6
main1(void)7 int main1 ( void )
8 {
9 int xxx, i;
10 for (i = 0; i < 10; i++) (void) VALGRIND_CHECK_VALUE_IS_DEFINED(xxx);
11 return 0;
12 }
13
main(void)14 int main ( void )
15 {
16 int i, sum, m;
17 char* aa = calloc(100,1);
18 sum = 0;
19
20 (void) VALGRIND_CHECK_MEM_IS_DEFINED(aa,100);
21
22 m = VALGRIND_MAKE_MEM_UNDEFINED( &aa[49], 1 );
23 (void) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(aa,100);
24
25 printf("m_na: returned value is %d\n", m );
26
27 for (i = 0; i < 100; i++)
28 sum += aa[i];
29 printf("sum is %s\n", sum > 0 ? "positive" : "non-positive");
30
31 m = VALGRIND_DISCARD(m);
32 printf("m_rm: returned value is %d\n", m );
33
34 for (i = 0; i < 100; i++)
35 sum += aa[i];
36 printf("sum is %s\n", sum > 0 ? "positive" : "non-positive");
37
38 return 0;
39 }
40