~ubuntu-branches/ubuntu/quantal/libgc/quantal

« back to all changes in this revision

Viewing changes to tests/thread_leak_test.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-02-19 12:19:56 UTC
  • mfrom: (1.3.2 upstream) (0.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110219121956-67rb69xlt5nud3v2
Tags: 1:7.1-5
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#define GC_LINUX_THREADS
 
1
#ifndef GC_THREADS
 
2
#  define GC_THREADS
 
3
#endif /* GC_THREADS */
2
4
#include "leak_detector.h"
3
5
#include <pthread.h>
4
6
#include <stdio.h>
15
17
    for (i = 1; i < 10; ++i) {
16
18
        free(p[i]);
17
19
    }
 
20
    return 0;
18
21
}       
19
22
 
20
23
#define NTHREADS 5
24
27
    pthread_t t[NTHREADS];
25
28
    int code;
26
29
 
 
30
    GC_INIT();
27
31
    for (i = 0; i < NTHREADS; ++i) {
28
32
        if ((code = pthread_create(t + i, 0, test, 0)) != 0) {
29
33
            printf("Thread creation failed %d\n", code);
37
41
    CHECK_LEAKS();
38
42
    CHECK_LEAKS();
39
43
    CHECK_LEAKS();
 
44
    return 0;
40
45
}