summaryrefslogtreecommitdiff
path: root/mutex.c
diff options
context:
space:
mode:
authorrpj <rpj>2001-10-15 08:47:10 +0000
committerrpj <rpj>2001-10-15 08:47:10 +0000
commitd0abe46d41d3c8db1772337e4160ca200b9dbcff (patch)
tree03bdc6e8c816a999ef66d6a05a52166dba7f7cb8 /mutex.c
parent50d2dd36c9a30460b32a4c9a3b4b2c456a255467 (diff)
* spin.c (pthread_spin_lock): PTHREAD_SPINLOCK_INITIALIZER
was causing a program fault. (pthread_spin_init): Could have alloced memory without freeing under some error conditions. * mutex.c (pthread_mutex_init): Move memory allocation of mutex struct after checking for PROCESS_SHARED.
Diffstat (limited to 'mutex.c')
-rw-r--r--mutex.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/mutex.c b/mutex.c
index 49a1a18..be039ac 100644
--- a/mutex.c
+++ b/mutex.c
@@ -93,14 +93,6 @@ pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
return EINVAL;
}
- mx = (pthread_mutex_t) calloc(1, sizeof(*mx));
-
- if (mx == NULL)
- {
- result = ENOMEM;
- goto FAIL0;
- }
-
if (attr != NULL
&& *attr != NULL
&& (*attr)->pshared == PTHREAD_PROCESS_SHARED
@@ -118,16 +110,22 @@ pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
#error ERROR [__FILE__, line __LINE__]: Process shared mutexes are not supported yet.
-
#else
- result = ENOSYS;
- goto FAIL0;
+ return ENOSYS;
#endif /* _POSIX_THREAD_PROCESS_SHARED */
}
+ mx = (pthread_mutex_t) calloc(1, sizeof(*mx));
+
+ 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