From a8c06648831a235908be753f816e691e87637589 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 31 Jan 2002 12:31:31 +0000 Subject: Fix critical section init. --- mutex.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'mutex.c') diff --git a/mutex.c b/mutex.c index e493b7f..c7a3250 100644 --- a/mutex.c +++ b/mutex.c @@ -132,29 +132,28 @@ pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) if (mx == NULL) { result = ENOMEM; - goto FAIL0; } - - mx->lock_idx = PTW32_MUTEX_LOCK_IDX_INIT; - mx->recursive_count = 0; - mx->kind = (attr == NULL || *attr == NULL - ? PTHREAD_MUTEX_DEFAULT - : (*attr)->kind); - mx->ownerThread = NULL; - - if( 0 != sem_init( &mx->wait_sema, 0, 0 )) - { - result = EAGAIN; - } - - if (result != 0 && mx != NULL) + else { - free(mx); - mx = NULL; + mx->lock_idx = PTW32_MUTEX_LOCK_IDX_INIT; + mx->recursive_count = 0; + mx->kind = (attr == NULL || *attr == NULL + ? PTHREAD_MUTEX_DEFAULT + : (*attr)->kind); + mx->ownerThread = NULL; + + if ( 0 != sem_init( &mx->wait_sema, 0, 0 )) + { + result = EAGAIN; + free(mx); + mx = NULL; + } + else + { + InitializeCriticalSection( &mx->wait_cs ); + } } -FAIL0: - InitializeCriticalSection( &mx->wait_cs ); *mutex = mx; return(result); -- cgit v1.2.3