diff options
author | rpj <rpj> | 2002-01-31 12:31:31 +0000 |
---|---|---|
committer | rpj <rpj> | 2002-01-31 12:31:31 +0000 |
commit | a8c06648831a235908be753f816e691e87637589 (patch) | |
tree | 99e60047c9ea1aa916fd076ce2f32a75df2b50ed | |
parent | 75f8ad67d45d48b9cdde5a298083881790c76c73 (diff) |
Fix critical section init.
-rw-r--r-- | mutex.c | 37 |
1 files changed, 18 insertions, 19 deletions
@@ -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); |