4 #include "leak_detector.h"
13 void * test(void * arg
)
15 DWORD WINAPI
test(LPVOID arg
)
20 for (i
= 0; i
< 10; ++i
) {
21 p
[i
] = malloc(sizeof(int)+i
);
24 for (i
= 1; i
< 10; ++i
) {
30 return (DWORD
)(GC_word
)arg
;
39 pthread_t t
[NTHREADS
];
46 GC_find_leak
= 1; /* for new collect versions not compiled */
48 for (i
= 0; i
< NTHREADS
; ++i
) {
50 code
= pthread_create(t
+ i
, 0, test
, 0);
52 t
[i
] = CreateThread(NULL
, 0, test
, 0, 0, &thread_id
);
53 code
= t
[i
] != NULL
? 0 : (int)GetLastError();
56 printf("Thread creation failed %d\n", code
);
59 for (i
= 0; i
< NTHREADS
; ++i
) {
61 code
= pthread_join(t
[i
], 0);
63 code
= WaitForSingleObject(t
[i
], INFINITE
) == WAIT_OBJECT_0
? 0 :
67 printf("Thread join failed %d\n", code
);