X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=hs-boehmgc.git;a=blobdiff_plain;f=gc-7.2%2Ftests%2Fleak_test.c;fp=gc-7.2%2Ftests%2Fleak_test.c;h=ae0a9af3878af59361517402d83f435f5e141102;hp=0000000000000000000000000000000000000000;hb=324587ba93dc77f37406d41fd2a20d0e0d94fb1d;hpb=2a4ea609491b225a1ceb06da70396e93916f137a diff --git a/gc-7.2/tests/leak_test.c b/gc-7.2/tests/leak_test.c new file mode 100644 index 0000000..ae0a9af --- /dev/null +++ b/gc-7.2/tests/leak_test.c @@ -0,0 +1,25 @@ +#include "leak_detector.h" + +int main(void) { + int *p[10]; + int i; + GC_set_find_leak(1); /* for new collect versions not compiled */ + /* with -DFIND_LEAK. */ + + GC_INIT(); /* Needed if thread-local allocation is enabled. */ + /* FIXME: This is not ideal. */ + for (i = 0; i < 10; ++i) { + p[i] = malloc(sizeof(int)+i); + } + CHECK_LEAKS(); + for (i = 1; i < 10; ++i) { + free(p[i]); + } + for (i = 0; i < 9; ++i) { + p[i] = malloc(sizeof(int)+i); + } + CHECK_LEAKS(); + CHECK_LEAKS(); + CHECK_LEAKS(); + return 0; +}