summaryrefslogtreecommitdiff
path: root/mutex.c
diff options
context:
space:
mode:
authorrpj <rpj>2002-01-31 12:31:31 +0000
committerrpj <rpj>2002-01-31 12:31:31 +0000
commita8c06648831a235908be753f816e691e87637589 (patch)
tree99e60047c9ea1aa916fd076ce2f32a75df2b50ed /mutex.c
parent75f8ad67d45d48b9cdde5a298083881790c76c73 (diff)
Fix critical section init.
Diffstat (limited to 'mutex.c')
-rw-r--r--mutex.c37
1 files changed, 18 insertions, 19 deletions
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);