+2010-05-13 Ivan Maidanski <ivmai@mail.ru> (mostly really Uros Bizjak)
+
+ * tests/leak_test.c (main): Explicitly define as returning int
+ (to prevent a spurious test failure on some Linux/alpha targets).
+ * tests/thread_leak_test.c (main): Ditto.
+ * tests/thread_leak_test.c: Initialize GC_find_leak in the main
+ thread (before GC_INIT) only.
+ * tests/leak_test.c (main): Use GC_set_find_leak() instead of
+ accessing GC_find_leak directly.
+ * tests/thread_leak_test.c (main): Ditto.
+
2010-05-05 Ivan Maidanski <ivmai@mail.ru>
* include/gc.h (GC_find_leak, GC_finalize_on_demand,
#include "leak_detector.h"
-main() {
+int main(void) {
int *p[10];
int i;
- GC_find_leak = 1; /* for new collect versions not compiled */
- /* with -DFIND_LEAK. */
+ 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. */
+ 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();
CHECK_LEAKS();
return 0;
-}
+}
void * test(void * arg) {
int *p[10];
int i;
- GC_find_leak = 1; /* for new collect versions not compiled */
- /* with -DFIND_LEAK. */
for (i = 0; i < 10; ++i) {
p[i] = malloc(sizeof(int)+i);
}
free(p[i]);
}
return 0;
-}
+}
#define NTHREADS 5
-main() {
+int main(void) {
int i;
pthread_t t[NTHREADS];
int code;
-
+ GC_set_find_leak(1); /* for new collect versions not compiled */
+ /* with -DFIND_LEAK. */
GC_INIT();
for (i = 0; i < NTHREADS; ++i) {
- if ((code = pthread_create(t + i, 0, test, 0)) != 0) {
- printf("Thread creation failed %d\n", code);
+ if ((code = pthread_create(t + i, 0, test, 0)) != 0) {
+ printf("Thread creation failed %d\n", code);
}
}
for (i = 0; i < NTHREADS; ++i) {
- if ((code = pthread_join(t[i], 0)) != 0) {
+ if ((code = pthread_join(t[i], 0)) != 0) {
printf("Thread join failed %lu\n", code);
}
}