2010-05-13 Ivan Maidanski <ivmai@mail.ru> (mostly really Uros Bizjak)
authorivmai <ivmai>
Thu, 13 May 2010 05:10:43 +0000 (05:10 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:53 +0000 (21:06 +0400)
* 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.

ChangeLog
tests/leak_test.c
tests/thread_leak_test.c

index 43e8a12..a6f4f32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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,
index d6a60d4..ae0a9af 100644 (file)
@@ -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;
-}       
+}
index f2c15e9..57a22bb 100644 (file)
@@ -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);
         }
     }