X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_mutex.c;h=b493c4d44e0581eb02e4c8c6b1c214beeb43405a;hb=78f83db7f84f7f400855fc576abe8e5978b975df;hp=4a6912f1812283b590ee7df5f9384c91fd34e964;hpb=95d8822d8b4c4a3563bf51c7c718350eb2babd20;p=userspace-rcu.git diff --git a/tests/test_mutex.c b/tests/test_mutex.c index 4a6912f..b493c4d 100644 --- a/tests/test_mutex.c +++ b/tests/test_mutex.c @@ -70,7 +70,7 @@ struct test_array { int a; }; -static pthread_mutex_t lock; +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static volatile int test_go, test_stop; @@ -357,12 +357,12 @@ int main(int argc, char **argv) "main", (unsigned long) pthread_self(), (unsigned long) gettid()); - tid_reader = malloc(sizeof(*tid_reader) * nr_readers); - tid_writer = malloc(sizeof(*tid_writer) * nr_writers); - count_reader = malloc(sizeof(*count_reader) * nr_readers); - count_writer = malloc(sizeof(*count_writer) * nr_writers); - tot_nr_reads = malloc(sizeof(*tot_nr_reads) * nr_readers); - tot_nr_writes = malloc(sizeof(*tot_nr_writes) * nr_writers); + tid_reader = calloc(nr_readers, sizeof(*tid_reader)); + tid_writer = calloc(nr_writers, sizeof(*tid_writer)); + count_reader = calloc(nr_readers, sizeof(*count_reader)); + count_writer = calloc(nr_writers, sizeof(*count_writer)); + tot_nr_reads = calloc(nr_readers, sizeof(*tot_nr_reads)); + tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes)); next_aff = 0;