njn | 47363ab | 2003-04-21 13:24:40 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include "../memcheck.h" |
| 4 | |
| 5 | int main(void) |
| 6 | { |
| 7 | int x; |
| 8 | int y = 0; |
| 9 | int* reachable; |
| 10 | int* dubious; |
| 11 | int* leaked; |
| 12 | int n_reachable = 0; |
| 13 | int n_dubious = 0; |
| 14 | int n_leaked = 0; |
| 15 | int n_suppressed = 0; |
| 16 | int errs; |
| 17 | |
| 18 | /* Error counting */ |
| 19 | printf("errors: %d\n", VALGRIND_COUNT_ERRORS); |
| 20 | |
| 21 | if (x == 0) { |
| 22 | y++; |
| 23 | } else { |
| 24 | y--; |
| 25 | } |
| 26 | |
| 27 | printf("errors: %d\n", VALGRIND_COUNT_ERRORS); |
| 28 | |
| 29 | /* Leak checking */ |
| 30 | VALGRIND_DO_LEAK_CHECK; |
| 31 | VALGRIND_COUNT_LEAKS(n_leaked, n_dubious, n_reachable, n_suppressed); |
| 32 | printf("leaks: %dB, %dB, %dB, %dB\n", |
| 33 | n_leaked, n_dubious, n_reachable, n_suppressed); |
| 34 | |
| 35 | leaked = malloc(77); |
| 36 | leaked = 0; |
| 37 | |
| 38 | dubious = malloc(88); |
| 39 | dubious += 10; |
| 40 | |
| 41 | reachable = malloc(99); |
| 42 | |
| 43 | VALGRIND_DO_LEAK_CHECK; |
| 44 | VALGRIND_COUNT_LEAKS(n_leaked, n_dubious, n_reachable, n_suppressed); |
| 45 | printf("leaks: %dB, %dB, %dB, %dB\n", |
| 46 | n_leaked, n_dubious, n_reachable, n_suppressed); |
| 47 | |
| 48 | printf("errors: %d\n", VALGRIND_COUNT_ERRORS); |
| 49 | |
| 50 | return 0; |
| 51 | } |