Back to index

plt-scheme  4.2.1
Defines | Functions
thread_leak_test.c File Reference
#include "leak_detector.h"
#include <pthread.h>
#include <stdio.h>

Go to the source code of this file.

Defines

#define GC_LINUX_THREADS
#define NTHREADS   5

Functions

voidtest (void *arg)
 main ()

Define Documentation

Definition at line 1 of file thread_leak_test.c.

#define NTHREADS   5

Definition at line 20 of file thread_leak_test.c.


Function Documentation

main ( void  )

Definition at line 22 of file thread_leak_test.c.

       {
    int i;
    pthread_t t[NTHREADS];
    int code;

    for (i = 0; i < NTHREADS; ++i) {
       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) {
            printf("Thread join failed %lu\n", code);
        }
    }
    CHECK_LEAKS();
    CHECK_LEAKS();
    CHECK_LEAKS();
}

Here is the call graph for this function:

void* test ( void arg)

Definition at line 6 of file thread_leak_test.c.

                        {
    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);
    }
    CHECK_LEAKS();
    for (i = 1; i < 10; ++i) {
        free(p[i]);
    }
}       

Here is the caller graph for this function: