Import boehm-gc snapshot, taken from
[official-gcc.git] / boehm-gc / tests / leak_test.c
blobae0a9af3878af59361517402d83f435f5e141102
1 #include "leak_detector.h"
3 int main(void) {
4 int *p[10];
5 int i;
6 GC_set_find_leak(1); /* for new collect versions not compiled */
7 /* with -DFIND_LEAK. */
9 GC_INIT(); /* Needed if thread-local allocation is enabled. */
10 /* FIXME: This is not ideal. */
11 for (i = 0; i < 10; ++i) {
12 p[i] = malloc(sizeof(int)+i);
14 CHECK_LEAKS();
15 for (i = 1; i < 10; ++i) {
16 free(p[i]);
18 for (i = 0; i < 9; ++i) {
19 p[i] = malloc(sizeof(int)+i);
21 CHECK_LEAKS();
22 CHECK_LEAKS();
23 CHECK_LEAKS();
24 return 0;