3 #include "../memcheck.h"
10 static void breakme() {};
17 fprintf(stderr
, "expecting details 10 bytes reachable\n"); fflush(stderr
); breakme();
18 VALGRIND_DO_LEAK_CHECK
;
20 fprintf(stderr
, "expecting to have NO details\n"); fflush(stderr
); breakme();
21 VALGRIND_DO_ADDED_LEAK_CHECK
;
25 fprintf(stderr
, "expecting details +10 bytes lost, +21 bytes reachable\n"); fflush(stderr
); breakme();
26 VALGRIND_DO_ADDED_LEAK_CHECK
;
28 for (i
= 0; i
< 2; i
++)
29 b32_33
[i
] = malloc (32+i
);
30 fprintf(stderr
, "expecting details +65 bytes reachable\n"); fflush(stderr
); breakme();
31 VALGRIND_DO_ADDED_LEAK_CHECK
;
33 fprintf(stderr
, "expecting to have NO details\n"); fflush(stderr
); breakme();
34 VALGRIND_DO_ADDED_LEAK_CHECK
;
37 fprintf(stderr
, "expecting details +10 bytes reachable\n"); fflush(stderr
); breakme();
38 VALGRIND_DO_ADDED_LEAK_CHECK
;
41 fprintf(stderr
, "expecting details -10 bytes reachable, +10 bytes lost\n"); fflush(stderr
); breakme();
42 VALGRIND_DO_CHANGED_LEAK_CHECK
;
45 fprintf(stderr
, "expecting details -10 bytes lost, +10 bytes reachable\n"); fflush(stderr
); breakme();
46 VALGRIND_DO_CHANGED_LEAK_CHECK
;
49 fprintf(stderr
, "expecting details 32 (+32) bytes lost, 33 (-32) bytes reachable\n"); fflush(stderr
); breakme();
50 VALGRIND_DO_CHANGED_LEAK_CHECK
;
52 for (i
= 0; i
< 2; i
++)
53 b42_43
[i
] = malloc (42+i
);
56 fprintf(stderr
, "expecting details 42 (+42) bytes lost, 43 (+43) bytes reachable\n"); fflush(stderr
); breakme();
57 VALGRIND_DO_NEW_LEAK_CHECK
;
60 fprintf(stderr
, "expecting to have NO details\n"); fflush(stderr
); breakme();
61 VALGRIND_DO_NEW_LEAK_CHECK
;
63 fprintf(stderr
, "finished\n");
68 DECLARE_LEAK_COUNTERS
;
70 GET_INITIAL_LEAK_COUNTS
;
72 f(); // see leak-cases.c
75 GET_FINAL_LEAK_COUNTS
;
77 PRINT_LEAK_COUNTS(stderr
);