summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorivmai <ivmai>2010-05-13 07:10:43 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:53 +0200
commit3861e04750e68398502d4faf8e9bca183a537140 (patch)
tree9ea85c7986f63d7b5915a0260e307e6f36827888 /tests
parent1616e6e0375141dd68eeca066c64cffd3afc75dc (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/leak_test.c12
-rw-r--r--tests/thread_leak_test.c15
2 files changed, 13 insertions, 14 deletions
diff --git a/tests/leak_test.c b/tests/leak_test.c
index d6a60d4..ae0a9af 100644
--- a/tests/leak_test.c
+++ b/tests/leak_test.c
@@ -1,13 +1,13 @@
#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);
}
@@ -22,4 +22,4 @@ main() {
CHECK_LEAKS();
CHECK_LEAKS();
return 0;
-}
+}
diff --git a/tests/thread_leak_test.c b/tests/thread_leak_test.c
index f2c15e9..57a22bb 100644
--- a/tests/thread_leak_test.c
+++ b/tests/thread_leak_test.c
@@ -8,8 +8,6 @@
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);
}
@@ -18,23 +16,24 @@ void * test(void * arg) {
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);
}
}